1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-26 04:00:59 +01:00

Merged R9433

This commit is contained in:
Wouter den Breejen 2007-10-09 21:12:02 +00:00
parent 8b31968c61
commit 7d82fd16e9
4 changed files with 76 additions and 45 deletions

View file

@ -903,15 +903,14 @@ static Expr prim_hasAttr(EvalState & state, const ATermVector & args)
}
/* takes
* param: list of { attr="attr"; value=value }
* returns an attribute set
* */
/* Builds an attribute set from a list specifying (name, value)
pairs. To be precise, a list [{name = "name1"; value = value1;}
... {name = "nameN"; value = valueN;}] is transformed to {name1 =
value1; ... nameN = valueN;}. */
static Expr prim_listToAttrs(EvalState & state, const ATermVector & args)
{
try {
ATermMap res = ATermMap();
ATermList list;
list = evalList(state, args[0]);
for (ATermIterator i(list); i; ++i){
@ -919,16 +918,18 @@ static Expr prim_listToAttrs(EvalState & state, const ATermVector & args)
ATermList attrs;
Expr evaledExpr = evalExpr(state, *i);
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);
Expr r = makeSelect(evaledExpr, toATerm("value"));
res.set(toATerm(attr), makeAttrRHS(r, makeNoPos()));
}
else {
throw EvalError(format("passed list item is a %s (value: %s). Set { attr=\"name\"; value=nix expr; } expected.") % showType(evaledExpr) % showValue(evaledExpr));
else
throw TypeError(format("list element in `listToAttrs' is %s, expected a set { name = \"<name>\"; value = <value>; }")
% showType(evaledExpr));
}
} // for
return makeAttrs(res);
} catch (Error & e) {
e.addPrefix(format("in `listToAttrs':\n"));
throw;

View file

@ -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
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;
for (Roots::iterator i = rootMap.begin(); i != rootMap.end(); ++i)
roots.insert(i->second);
/* Add additional roots returned by the program specified by the
NIX_ROOT_FINDER environment variable. This is typically used
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;
for (PathSet::const_iterator i = roots.begin(); i != roots.end(); ++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();
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
previously ran the collector with `gcKeepDerivations'
turned off). */
Path deriver = store->queryDeriver(*i);
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) {
/* Hmz, identical to storePathRequisites in nix-store. */
for (PathSet::iterator i = livePaths.begin();
@ -619,7 +641,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
/* Okay, it's safe to delete. */
try {
unsigned long long freed;
deleteFromStore(*i, freed);
//deleteFromStore(*i, freed); //TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PUT BACK ON
bytesFreed += freed;
} catch (PathInUse & e) {
printMsg(lvlError, format("warning: %1%") % e.msg());

View file

@ -745,9 +745,18 @@ static Path queryDeriver(const Transaction & txn, const Path & storePath)
bool b = nixDB.queryString(txn, dbDerivers, storePath, deriver);
Derivation drv = derivationFromPathTxn(txn, deriver);
if (isStateDrv(drv))
throw Error(format("This deriver `%1%' is a state deriver, u should use queryDerivers instead of queryDeriver") % deriver);
/* Note that the deriver need not be valid (e.g., if we
previously ran the garbage collector with `gcKeepDerivations'
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)
return deriver;
@ -876,9 +885,9 @@ Hash LocalStore::queryPathHash(const Path & path)
return queryHash(noTxn, path);
}
Path queryStatePathDrvTxn(const Transaction & txn, const Path & statePath)
{
string s;
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; //query includes username and identifier ....??
nixDB.queryString(txn, dbValidStatePaths, statePath, s);
return s;
}

View file

@ -371,9 +371,8 @@ void writeStringToFile(const Path & path, const string & s)
LogType logType = ltPretty;
Verbosity verbosity = lvlInfo;
//Verbosity verbosity = lvlDebug;
//Verbosity verbosity = lvlVomit;
Verbosity verbosity = lvlInfo; //Default
//Verbosity verbosity = lvlVomit; //Debugging
static int nestingLevel = 0;