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

Merging the trunk back into my branch: just merged revision 8628

This commit is contained in:
Wouter den Breejen 2007-10-07 14:32:42 +00:00
parent d69dd855d5
commit 3800f55b54
12 changed files with 159 additions and 79 deletions

View file

@ -616,6 +616,9 @@ static char * deepestStack = (char *) -1; /* for measuring stack usage */
Expr evalExpr2(EvalState & state, Expr e)
{
/* When changing this function, make sure that you don't cause a
(large) increase in stack consumption! */
char x;
if (&x < deepestStack) deepestStack = &x;

View file

@ -12,6 +12,7 @@ namespace nix {
MakeError(EvalError, Error)
MakeError(AssertionError, EvalError)
MakeError(ThrownError, AssertionError)
MakeError(Abort, EvalError)
MakeError(TypeError, EvalError)

View file

@ -271,6 +271,14 @@ static Expr prim_abort(EvalState & state, const ATermVector & args)
}
static Expr prim_throw(EvalState & state, const ATermVector & args)
{
PathSet context;
throw ThrownError(format("user-thrown exception: `%1%'") %
evalString(state, args[0], context));
}
/* Return an environment variable. Use with care. */
static Expr prim_getEnv(EvalState & state, const ATermVector & args)
{
@ -1026,6 +1034,7 @@ void EvalState::addPrimOps()
addPrimOp("isNull", 1, prim_isNull);
addPrimOp("dependencyClosure", 1, prim_dependencyClosure);
addPrimOp("abort", 1, prim_abort);
addPrimOp("throw", 1, prim_throw);
addPrimOp("__getEnv", 1, prim_getEnv);
addPrimOp("relativise", 2, prim_relativise);

View file

@ -1466,6 +1466,7 @@ void verifyStore(bool checkContents)
nixDB.enumTable(txn, dbValidPaths, paths);
for (Paths::iterator i = paths.begin(); i != paths.end(); ++i) {
checkInterrupt();
if (!pathExists(*i)) {
printMsg(lvlError, format("store path `%1%' disappeared") % *i);
invalidateStorePath(txn, *i);

View file

@ -45,8 +45,14 @@ Upgrade flags:
--eq: "upgrade" if the current version is equal
--always: upgrade regardless of current version
Query types:
Query sources:
--installed: use installed derivations (default)
--available / -a: use derivations available in Nix expression
Query flags:
--xml: show output in XML format
--status / -s: print installed/present status
--no-name: hide derivation names
--attr / -A: shows the unambiguous attribute name of the
@ -55,11 +61,10 @@ Query types:
--compare-versions / -c: compare version to available or installed
--drv-path: print path of derivation
--out-path: print path of derivation output
Query sources:
--installed: use installed derivations (default)
--available / -a: use derivations available in Nix expression
--description: print description
--meta: print all meta attributes (only with --xml)
--prebuilt-only: only show derivations whose prebuilt binaries are
available on this machine or are downloadable
Options:

View file

@ -163,7 +163,6 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
ATermList manifest = ATempty;
ATermList inputs = ATempty;
ATermList stateIdentifiers = ATempty;
ATermList runtimeStateArgs = ATempty;
for (DrvInfos::const_iterator i = elems.begin();
i != elems.end(); ++i)
{
@ -195,8 +194,6 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
//Insert the new stateIdentifier into the stateIdentifiers Atermlist
stateIdentifiers = ATinsert(stateIdentifiers, makeStr(i->queryStateIdentifier(state)));
//Insert the new runtime state args into the runtimeStateArgs Atermlist
runtimeStateArgs = ATinsert(runtimeStateArgs, makeStr(i->queryRuntimeStateArgs(state)));
inputs = ATinsert(inputs, makeStr(i->queryOutPath(state)));
@ -220,15 +217,13 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
Expr topLevel = makeCall(envBuilder, makeAttrs(
ATinsert(
ATmakeList6(
ATmakeList5(
makeBind(toATerm("system"),
makeStr(thisSystem), makeNoPos()),
makeBind(toATerm("derivations"),
makeList(ATreverse(manifest)), makeNoPos()),
makeBind(toATerm("stateIdentifiers"),
makeList(ATreverse(stateIdentifiers)), makeNoPos()),
makeBind(toATerm("runtimeStateArgs"),
makeList(ATreverse(runtimeStateArgs)), makeNoPos()),
makeBind(toATerm("manifest"),
makeStr(manifestFile, singleton<PathSet>(manifestFile)), makeNoPos()),
makeBind(toATerm("nixBinDir"),
@ -536,9 +531,13 @@ static void installDerivations(Globals & globals,
for (DrvInfos::iterator i = installedElems.begin(); i != installedElems.end(); ++i)
{
DrvName drvName(i->name);
MetaInfo meta = i->queryMetaInfo(globals.state);
//We may need to share state
if (!globals.preserveInstalled && newNames.find(drvName.name) != newNames.end()){
if (!globals.preserveInstalled &&
newNames.find(drvName.name) != newNames.end() &&
meta["keep"] != "true"
){
//******** We're gonna check if the component and state indentifiers are the same,
// since we may need to share state in that case.
@ -709,6 +708,9 @@ static void upgradeDerivations(Globals & globals,
{
DrvName drvName(i->name);
MetaInfo meta = i->queryMetaInfo(globals.state);
if (meta["keep"] == "true") continue;
/* Find the derivation in the input Nix expression with the
same name and satisfying the version constraints specified
by upgradeType. If there are multiple matches, take the
@ -997,6 +999,8 @@ static void opQuery(Globals & globals,
bool printDrvPath = false;
bool printOutPath = false;
bool printDescription = false;
bool printMeta = false;
bool prebuiltOnly = false;
bool compareVersions = false;
bool xmlOutput = false;
@ -1013,8 +1017,10 @@ static void opQuery(Globals & globals,
else if (*i == "--compare-versions" || *i == "-c") compareVersions = true;
else if (*i == "--drv-path") printDrvPath = true;
else if (*i == "--out-path") printOutPath = true;
else if (*i == "--meta") printMeta = true;
else if (*i == "--installed") source = sInstalled;
else if (*i == "--available" || *i == "-a") source = sAvailable;
else if (*i == "--prebuilt-only" || *i == "-b") prebuiltOnly = true;
else if (*i == "--xml") xmlOutput = true;
else throw UsageError(format("unknown flag `%1%'") % *i);
@ -1080,6 +1086,12 @@ static void opQuery(Globals & globals,
/* For XML output. */
XMLAttrs attrs;
if (prebuiltOnly) {
if (!store->isValidPath(i->queryOutPath(globals.state)) &&
!store->hasSubstitutes(i->queryOutPath(globals.state)))
continue;
}
if (printStatus) {
bool hasSubs = store->hasSubstitutes(i->queryOutPath(globals.state));
@ -1167,7 +1179,18 @@ static void opQuery(Globals & globals,
}
if (xmlOutput)
xml.writeEmptyElement("item", attrs);
if (printMeta) {
XMLOpenElement item(xml, "item", attrs);
MetaInfo meta = i->queryMetaInfo(globals.state);
for (MetaInfo::iterator j = meta.begin(); j != meta.end(); ++j) {
XMLAttrs attrs2;
attrs2["name"] = j->first;
attrs2["value"] = j->second;
xml.writeEmptyElement("meta", attrs2);
}
}
else
xml.writeEmptyElement("item", attrs);
else
table.push_back(columns);

View file

@ -36,7 +36,7 @@ static void secureChown(uid_t uidFrom, gid_t gidFrom,
to. */
throw Error(error);
if (uidFrom != -1) {
if (uidFrom != (uid_t) -1) {
assert(uidFrom != 0);
if (st.st_uid != uidFrom)
throw Error(error);