mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Merged R9433
This commit is contained in:
parent
8b31968c61
commit
7d82fd16e9
4 changed files with 76 additions and 45 deletions
|
|
@ -903,15 +903,14 @@ static Expr prim_hasAttr(EvalState & state, const ATermVector & args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* takes
|
/* Builds an attribute set from a list specifying (name, value)
|
||||||
* param: list of { attr="attr"; value=value }
|
pairs. To be precise, a list [{name = "name1"; value = value1;}
|
||||||
* returns an attribute set
|
... {name = "nameN"; value = valueN;}] is transformed to {name1 =
|
||||||
* */
|
value1; ... nameN = valueN;}. */
|
||||||
static Expr prim_listToAttrs(EvalState & state, const ATermVector & args)
|
static Expr prim_listToAttrs(EvalState & state, const ATermVector & args)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
ATermMap res = ATermMap();
|
ATermMap res = ATermMap();
|
||||||
|
|
||||||
ATermList list;
|
ATermList list;
|
||||||
list = evalList(state, args[0]);
|
list = evalList(state, args[0]);
|
||||||
for (ATermIterator i(list); i; ++i){
|
for (ATermIterator i(list); i; ++i){
|
||||||
|
|
@ -919,16 +918,18 @@ static Expr prim_listToAttrs(EvalState & state, const ATermVector & args)
|
||||||
ATermList attrs;
|
ATermList attrs;
|
||||||
Expr evaledExpr = evalExpr(state, *i);
|
Expr evaledExpr = evalExpr(state, *i);
|
||||||
if (matchAttrs(evaledExpr, attrs)){
|
if (matchAttrs(evaledExpr, attrs)){
|
||||||
Expr e = evalExpr(state, makeSelect(evaledExpr, toATerm("attr")));
|
Expr e = evalExpr(state, makeSelect(evaledExpr, toATerm("name")));
|
||||||
string attr = evalStringNoCtx(state,e);
|
string attr = evalStringNoCtx(state,e);
|
||||||
Expr r = makeSelect(evaledExpr, toATerm("value"));
|
Expr r = makeSelect(evaledExpr, toATerm("value"));
|
||||||
res.set(toATerm(attr), makeAttrRHS(r, makeNoPos()));
|
res.set(toATerm(attr), makeAttrRHS(r, makeNoPos()));
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
throw EvalError(format("passed list item is a %s (value: %s). Set { attr=\"name\"; value=nix expr; } expected.") % showType(evaledExpr) % showValue(evaledExpr));
|
throw TypeError(format("list element in `listToAttrs' is %s, expected a set { name = \"<name>\"; value = <value>; }")
|
||||||
|
% showType(evaledExpr));
|
||||||
}
|
}
|
||||||
} // for
|
|
||||||
return makeAttrs(res);
|
return makeAttrs(res);
|
||||||
|
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addPrefix(format("in `listToAttrs':\n"));
|
e.addPrefix(format("in `listToAttrs':\n"));
|
||||||
throw;
|
throw;
|
||||||
|
|
|
||||||
|
|
@ -456,12 +456,13 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
|
|
||||||
/* Find the roots. Since we've grabbed the GC lock, the set of
|
/* Find the roots. Since we've grabbed the GC lock, the set of
|
||||||
permanent roots cannot increase now. */
|
permanent roots cannot increase now. */
|
||||||
Roots rootMap = ignoreLiveness ? Roots() : nix::findRoots(true); //TODO Also find state roots? TODO include sharing of state.
|
Roots rootMap = ignoreLiveness ? Roots() : nix::findRoots(true); //TODO Also find state roots --> nah ? TODO include sharing of state.
|
||||||
|
|
||||||
PathSet roots;
|
PathSet roots;
|
||||||
for (Roots::iterator i = rootMap.begin(); i != rootMap.end(); ++i)
|
for (Roots::iterator i = rootMap.begin(); i != rootMap.end(); ++i)
|
||||||
roots.insert(i->second);
|
roots.insert(i->second);
|
||||||
|
|
||||||
|
|
||||||
/* Add additional roots returned by the program specified by the
|
/* Add additional roots returned by the program specified by the
|
||||||
NIX_ROOT_FINDER environment variable. This is typically used
|
NIX_ROOT_FINDER environment variable. This is typically used
|
||||||
to add running programs to the set of roots (to prevent them
|
to add running programs to the set of roots (to prevent them
|
||||||
|
|
@ -479,7 +480,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
PathSet livePaths;
|
PathSet livePaths;
|
||||||
for (PathSet::const_iterator i = roots.begin(); i != roots.end(); ++i){
|
for (PathSet::const_iterator i = roots.begin(); i != roots.end(); ++i){
|
||||||
printMsg(lvlError, format("CHECK '%1%'") % *i);
|
printMsg(lvlError, format("CHECK '%1%'") % *i);
|
||||||
computeFSClosure(canonPath(*i), livePaths, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO DELETE STATE??
|
computeFSClosure(canonPath(*i), livePaths, true, false, 0); //TODO !!!!!!!!!! ALSO STATEPATHS TRUE???
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -487,16 +488,37 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
for (PathSet::iterator i = livePaths.begin();
|
for (PathSet::iterator i = livePaths.begin();
|
||||||
i != livePaths.end(); ++i)
|
i != livePaths.end(); ++i)
|
||||||
{
|
{
|
||||||
printMsg(lvlError, format("CHECK2 '%1%'") % *i);
|
if (store->isStateComponent(*i)){
|
||||||
|
printMsg(lvlError, format("CHECK-STATE-STORE '%1%'") % *i);
|
||||||
|
//we select ALL state Derivations here
|
||||||
|
PathSet derivers = store->queryDerivers(*i, "*", "*");
|
||||||
|
|
||||||
|
for (PathSet::const_iterator j = derivers.begin(); j != derivers.end(); ++j)
|
||||||
|
// We send each drv to computeFSClosure
|
||||||
|
if (*j != "" && store->isValidPath(*j))
|
||||||
|
computeFSClosure(*j, livePaths, true, false, 0); //TODO !!!!!!!!!! ALSO STATEPATHS TRUE???
|
||||||
|
}
|
||||||
|
else if (store->isValidPath(*i)){
|
||||||
|
printMsg(lvlError, format("CHECK-STORE '%1%'") % *i);
|
||||||
|
Path deriver = store->queryDeriver(*i);
|
||||||
|
printMsg(lvlError, format("CHECK-STORE DRV '%1%'") % deriver);
|
||||||
|
|
||||||
/* Note that the deriver need not be valid (e.g., if we
|
/* Note that the deriver need not be valid (e.g., if we
|
||||||
previously ran the collector with `gcKeepDerivations'
|
previously ran the collector with `gcKeepDerivations'
|
||||||
turned off). */
|
turned off). */
|
||||||
Path deriver = store->queryDeriver(*i);
|
|
||||||
if (deriver != "" && store->isValidPath(deriver))
|
if (deriver != "" && store->isValidPath(deriver))
|
||||||
computeFSClosure(deriver, livePaths, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
computeFSClosure(deriver, livePaths, true, false, 0); //TODO !!!!!!!!!! ALSO STATEPATHS TRUE???
|
||||||
|
}
|
||||||
|
|
||||||
|
//else if (store->isValidStatePath(*i)){
|
||||||
|
|
||||||
|
else
|
||||||
|
throw Error(format("path `%1%' is not a valid state/store path") % *i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printMsg(lvlError, format("STAGE X"));
|
||||||
|
|
||||||
if (gcKeepOutputs) {
|
if (gcKeepOutputs) {
|
||||||
/* Hmz, identical to storePathRequisites in nix-store. */
|
/* Hmz, identical to storePathRequisites in nix-store. */
|
||||||
for (PathSet::iterator i = livePaths.begin();
|
for (PathSet::iterator i = livePaths.begin();
|
||||||
|
|
@ -619,7 +641,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
/* Okay, it's safe to delete. */
|
/* Okay, it's safe to delete. */
|
||||||
try {
|
try {
|
||||||
unsigned long long freed;
|
unsigned long long freed;
|
||||||
deleteFromStore(*i, freed);
|
//deleteFromStore(*i, freed); //TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PUT BACK ON
|
||||||
bytesFreed += freed;
|
bytesFreed += freed;
|
||||||
} catch (PathInUse & e) {
|
} catch (PathInUse & e) {
|
||||||
printMsg(lvlError, format("warning: %1%") % e.msg());
|
printMsg(lvlError, format("warning: %1%") % e.msg());
|
||||||
|
|
|
||||||
|
|
@ -745,9 +745,18 @@ static Path queryDeriver(const Transaction & txn, const Path & storePath)
|
||||||
|
|
||||||
bool b = nixDB.queryString(txn, dbDerivers, storePath, deriver);
|
bool b = nixDB.queryString(txn, dbDerivers, storePath, deriver);
|
||||||
|
|
||||||
Derivation drv = derivationFromPathTxn(txn, deriver);
|
/* Note that the deriver need not be valid (e.g., if we
|
||||||
if (isStateDrv(drv))
|
previously ran the garbage collector with `gcKeepDerivations'
|
||||||
throw Error(format("This deriver `%1%' is a state deriver, u should use queryDerivers instead of queryDeriver") % deriver);
|
turned off). */
|
||||||
|
if(deriver == ""){
|
||||||
|
printMsg(lvlTalkative, format("WARNING: Path '%1%' has no deriver anymore") % storePath);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
//Derivation drv = derivationFromPathTxn(txn, deriver); //We cant do this (at this point) since the drv might not exist ....
|
||||||
|
//if (isStateDrv(drv))
|
||||||
|
// throw Error(format("This deriver `%1%' is a state deriver, u should use queryDerivers instead of queryDeriver") % deriver);
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
return deriver;
|
return deriver;
|
||||||
|
|
@ -876,9 +885,9 @@ Hash LocalStore::queryPathHash(const Path & path)
|
||||||
return queryHash(noTxn, path);
|
return queryHash(noTxn, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Path queryStatePathDrvTxn(const Transaction & txn, const Path & statePath)
|
Path queryStatePathDrvTxn(const Transaction & txn, const Path & statePath) //TODO !!!!!!!!!!!!!!!!!!!!!! A STATEPATH CAN HAVE MORE THEN JUST ONE DRV!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
{
|
{ //SOLUTION: make dbValidStatePaths :: statepath --> storepath
|
||||||
string s;
|
string s; //query includes username and identifier ....??
|
||||||
nixDB.queryString(txn, dbValidStatePaths, statePath, s);
|
nixDB.queryString(txn, dbValidStatePaths, statePath, s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -371,9 +371,8 @@ void writeStringToFile(const Path & path, const string & s)
|
||||||
|
|
||||||
|
|
||||||
LogType logType = ltPretty;
|
LogType logType = ltPretty;
|
||||||
Verbosity verbosity = lvlInfo;
|
Verbosity verbosity = lvlInfo; //Default
|
||||||
//Verbosity verbosity = lvlDebug;
|
//Verbosity verbosity = lvlVomit; //Debugging
|
||||||
//Verbosity verbosity = lvlVomit;
|
|
||||||
|
|
||||||
static int nestingLevel = 0;
|
static int nestingLevel = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue