Whitespace

This commit is contained in:
Eelco Dolstra 2012-12-03 18:19:49 +01:00
parent 8eed07cda4
commit 4bb4d5479a
3 changed files with 58 additions and 60 deletions

View file

@ -115,13 +115,13 @@ static void getAllExprs(EvalState & state,
necessary to prevent it from showing up in channels (which necessary to prevent it from showing up in channels (which
are implemented using profiles). */ are implemented using profiles). */
if (*i == "manifest.nix") continue; if (*i == "manifest.nix") continue;
Path path2 = path + "/" + *i; Path path2 = path + "/" + *i;
struct stat st; struct stat st;
if (stat(path2.c_str(), &st) == -1) if (stat(path2.c_str(), &st) == -1)
continue; // ignore dangling symlinks in ~/.nix-defexpr continue; // ignore dangling symlinks in ~/.nix-defexpr
if (isNixExpr(path2)) { if (isNixExpr(path2)) {
/* Strip off the `.nix' filename suffix (if applicable), /* Strip off the `.nix' filename suffix (if applicable),
otherwise the attribute cannot be selected with the otherwise the attribute cannot be selected with the
@ -165,7 +165,7 @@ static void loadDerivations(EvalState & state, Path nixExprPath,
{ {
Value v; Value v;
findAlongAttrPath(state, pathPrefix, autoArgs, loadSourceExpr(state, nixExprPath), v); findAlongAttrPath(state, pathPrefix, autoArgs, loadSourceExpr(state, nixExprPath), v);
getDerivations(state, v, pathPrefix, autoArgs, elems, true); getDerivations(state, v, pathPrefix, autoArgs, elems, true);
/* Filter out all derivations not applicable to the current /* Filter out all derivations not applicable to the current
@ -266,7 +266,7 @@ static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
int d = 1; int d = 1;
Newest::iterator k = newest.find(drvName.name); Newest::iterator k = newest.find(drvName.name);
if (k != newest.end()) { if (k != newest.end()) {
d = j->first.system == k->second.first.system ? 0 : d = j->first.system == k->second.first.system ? 0 :
j->first.system == settings.thisSystem ? 1 : j->first.system == settings.thisSystem ? 1 :
@ -303,7 +303,7 @@ static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
elems.push_back(j->first); elems.push_back(j->first);
} }
} }
/* Check that all selectors have been used. */ /* Check that all selectors have been used. */
for (DrvNames::iterator i = selectors.begin(); for (DrvNames::iterator i = selectors.begin();
i != selectors.end(); ++i) i != selectors.end(); ++i)
@ -328,7 +328,7 @@ static void queryInstSources(EvalState & state,
InstallSourceType type = instSource.type; InstallSourceType type = instSource.type;
if (type == srcUnknown && args.size() > 0 && isPath(args.front())) if (type == srcUnknown && args.size() > 0 && isPath(args.front()))
type = srcStorePaths; type = srcStorePaths;
switch (type) { switch (type) {
/* Get the available user environment elements from the /* Get the available user environment elements from the
@ -344,7 +344,7 @@ static void queryInstSources(EvalState & state,
instSource.systemFilter, instSource.autoArgs, "", allElems); instSource.systemFilter, instSource.autoArgs, "", allElems);
elems = filterBySelector(state, allElems, args, newestOnly); elems = filterBySelector(state, allElems, args, newestOnly);
break; break;
} }
@ -355,7 +355,7 @@ static void queryInstSources(EvalState & state,
argument `x: x.bar' is equivalent to `(x: x.bar) argument `x: x.bar' is equivalent to `(x: x.bar)
(import ./foo.nix)' = `(import ./foo.nix).bar'. */ (import ./foo.nix)' = `(import ./foo.nix).bar'. */
case srcNixExprs: { case srcNixExprs: {
Expr * e1 = loadSourceExpr(state, instSource.nixExprPath); Expr * e1 = loadSourceExpr(state, instSource.nixExprPath);
foreach (Strings::const_iterator, i, args) { foreach (Strings::const_iterator, i, args) {
@ -364,10 +364,10 @@ static void queryInstSources(EvalState & state,
Value v; state.eval(call, v); Value v; state.eval(call, v);
getDerivations(state, v, "", instSource.autoArgs, elems, true); getDerivations(state, v, "", instSource.autoArgs, elems, true);
} }
break; break;
} }
/* The available user environment elements are specified as a /* The available user environment elements are specified as a
list of store paths (which may or may not be list of store paths (which may or may not be
derivations). */ derivations). */
@ -398,10 +398,10 @@ static void queryInstSources(EvalState & state,
elems.push_back(elem); elems.push_back(elem);
} }
break; break;
} }
/* Get the available user environment elements from another /* Get the available user environment elements from another
user environment. These are then filtered as in the user environment. These are then filtered as in the
`srcNixExprDrvs' case. */ `srcNixExprDrvs' case. */
@ -477,9 +477,9 @@ static void installDerivations(Globals & globals,
while (true) { while (true) {
string lockToken = optimisticLockProfile(profile); string lockToken = optimisticLockProfile(profile);
DrvInfos installedElems = queryInstalled(globals.state, profile); DrvInfos installedElems = queryInstalled(globals.state, profile);
DrvInfos allElems(newElems); DrvInfos allElems(newElems);
foreach (DrvInfos::iterator, i, installedElems) { foreach (DrvInfos::iterator, i, installedElems) {
DrvName drvName(i->name); DrvName drvName(i->name);
@ -495,9 +495,9 @@ static void installDerivations(Globals & globals,
foreach (DrvInfos::iterator, i, newElems) foreach (DrvInfos::iterator, i, newElems)
printMsg(lvlInfo, format("installing `%1%'") % i->name); printMsg(lvlInfo, format("installing `%1%'") % i->name);
printMissing(globals.state, newElems); printMissing(globals.state, newElems);
if (globals.dryRun) return; if (globals.dryRun) return;
if (createUserEnv(globals.state, allElems, if (createUserEnv(globals.state, allElems,
@ -536,7 +536,7 @@ static void upgradeDerivations(Globals & globals,
while (true) { while (true) {
string lockToken = optimisticLockProfile(globals.profile); string lockToken = optimisticLockProfile(globals.profile);
DrvInfos installedElems = queryInstalled(globals.state, globals.profile); DrvInfos installedElems = queryInstalled(globals.state, globals.profile);
/* Fetch all derivations from the input file. */ /* Fetch all derivations from the input file. */
@ -586,7 +586,7 @@ static void upgradeDerivations(Globals & globals,
} }
} }
} }
if (bestElem != availElems.end() && if (bestElem != availElems.end() &&
i->queryOutPath(globals.state) != i->queryOutPath(globals.state) !=
bestElem->queryOutPath(globals.state)) bestElem->queryOutPath(globals.state))
@ -602,9 +602,9 @@ static void upgradeDerivations(Globals & globals,
throw; throw;
} }
} }
printMissing(globals.state, newElems); printMissing(globals.state, newElems);
if (globals.dryRun) return; if (globals.dryRun) return;
if (createUserEnv(globals.state, newElems, if (createUserEnv(globals.state, newElems,
@ -694,7 +694,7 @@ static void opSet(Globals & globals,
if (elems.size() != 1) if (elems.size() != 1)
throw Error("--set requires exactly one derivation"); throw Error("--set requires exactly one derivation");
DrvInfo & drv(elems.front()); DrvInfo & drv(elems.front());
if (drv.queryDrvPath(globals.state) != "") { if (drv.queryDrvPath(globals.state) != "") {
@ -777,10 +777,10 @@ typedef list<Strings> Table;
void printTable(Table & table) void printTable(Table & table)
{ {
unsigned int nrColumns = table.size() > 0 ? table.front().size() : 0; unsigned int nrColumns = table.size() > 0 ? table.front().size() : 0;
vector<unsigned int> widths; vector<unsigned int> widths;
widths.resize(nrColumns); widths.resize(nrColumns);
foreach (Table::iterator, i, table) { foreach (Table::iterator, i, table) {
assert(i->size() == nrColumns); assert(i->size() == nrColumns);
Strings::iterator j; Strings::iterator j;
@ -789,7 +789,7 @@ void printTable(Table & table)
if (j->size() > widths[column]) widths[column] = j->size(); if (j->size() > widths[column]) widths[column] = j->size();
} }
foreach (Table::iterator, i, table) { foreach (Table::iterator, i, table) {
Strings::iterator j; Strings::iterator j;
unsigned int column; unsigned int column;
for (j = i->begin(), column = 0; j != i->end(); ++j, ++column) { for (j = i->begin(), column = 0; j != i->end(); ++j, ++column) {
@ -817,10 +817,10 @@ static VersionDiff compareVersionAgainstSet(
const DrvInfo & elem, const DrvInfos & elems, string & version) const DrvInfo & elem, const DrvInfos & elems, string & version)
{ {
DrvName name(elem.name); DrvName name(elem.name);
VersionDiff diff = cvUnavail; VersionDiff diff = cvUnavail;
version = "?"; version = "?";
for (DrvInfos::const_iterator i = elems.begin(); i != elems.end(); ++i) { for (DrvInfos::const_iterator i = elems.begin(); i != elems.end(); ++i) {
DrvName name2(i->name); DrvName name2(i->name);
if (name.name == name2.name) { if (name.name == name2.name) {
@ -858,7 +858,7 @@ static void opQuery(Globals & globals,
typedef vector< map<string, string> > ResultSet; typedef vector< map<string, string> > ResultSet;
Strings remaining; Strings remaining;
string attrPath; string attrPath;
bool printStatus = false; bool printStatus = false;
bool printName = true; bool printName = true;
bool printAttrPath = false; bool printAttrPath = false;
@ -898,7 +898,7 @@ static void opQuery(Globals & globals,
if (remaining.size() == 0) if (remaining.size() == 0)
printMsg(lvlInfo, "warning: you probably meant to specify the argument '*' to show all packages"); printMsg(lvlInfo, "warning: you probably meant to specify the argument '*' to show all packages");
/* Obtain derivation information from the specified source. */ /* Obtain derivation information from the specified source. */
DrvInfos availElems, installedElems; DrvInfos availElems, installedElems;
@ -916,7 +916,7 @@ static void opQuery(Globals & globals,
DrvInfos & otherElems(source == sInstalled ? availElems : installedElems); DrvInfos & otherElems(source == sInstalled ? availElems : installedElems);
/* Sort them by name. */ /* Sort them by name. */
/* !!! */ /* !!! */
vector<DrvInfo> elems2; vector<DrvInfo> elems2;
@ -924,11 +924,11 @@ static void opQuery(Globals & globals,
elems2.push_back(*i); elems2.push_back(*i);
sort(elems2.begin(), elems2.end(), cmpElemByName); sort(elems2.begin(), elems2.end(), cmpElemByName);
/* We only need to know the installed paths when we are querying /* We only need to know the installed paths when we are querying
the status of the derivation. */ the status of the derivation. */
PathSet installed; /* installed paths */ PathSet installed; /* installed paths */
if (printStatus) { if (printStatus) {
for (DrvInfos::iterator i = installedElems.begin(); for (DrvInfos::iterator i = installedElems.begin();
i != installedElems.end(); ++i) i != installedElems.end(); ++i)
@ -951,17 +951,17 @@ static void opQuery(Globals & globals,
substitutablePaths = store->querySubstitutablePaths(paths); substitutablePaths = store->querySubstitutablePaths(paths);
} }
/* Print the desired columns, or XML output. */ /* Print the desired columns, or XML output. */
Table table; Table table;
std::ostringstream dummy; std::ostringstream dummy;
XMLWriter xml(true, *(xmlOutput ? &cout : &dummy)); XMLWriter xml(true, *(xmlOutput ? &cout : &dummy));
XMLOpenElement xmlRoot(xml, "items"); XMLOpenElement xmlRoot(xml, "items");
foreach (vector<DrvInfo>::iterator, i, elems2) { foreach (vector<DrvInfo>::iterator, i, elems2) {
try { try {
if (i->hasFailed()) continue; if (i->hasFailed()) continue;
startNest(nest, lvlDebug, format("outputting query result `%1%'") % i->attrPath); startNest(nest, lvlDebug, format("outputting query result `%1%'") % i->attrPath);
if (globals.prebuiltOnly && !isPrebuilt(globals.state, *i)) continue; if (globals.prebuiltOnly && !isPrebuilt(globals.state, *i)) continue;
@ -1090,7 +1090,7 @@ static void opQuery(Globals & globals,
} else if (j->second.type == MetaValue::tpStrings) { } else if (j->second.type == MetaValue::tpStrings) {
attrs2["type"] = "strings"; attrs2["type"] = "strings";
XMLOpenElement m(xml, "meta", attrs2); XMLOpenElement m(xml, "meta", attrs2);
foreach (Strings::iterator, k, j->second.stringValues) { foreach (Strings::iterator, k, j->second.stringValues) {
XMLAttrs attrs3; XMLAttrs attrs3;
attrs3["value"] = *k; attrs3["value"] = *k;
xml.writeEmptyElement("string", attrs3); xml.writeEmptyElement("string", attrs3);
@ -1136,7 +1136,7 @@ static void switchGeneration(Globals & globals, int dstGen)
{ {
PathLocks lock; PathLocks lock;
lockProfile(lock, globals.profile); lockProfile(lock, globals.profile);
int curGen; int curGen;
Generations gens = findGenerations(globals.profile, curGen); Generations gens = findGenerations(globals.profile, curGen);
@ -1156,9 +1156,9 @@ static void switchGeneration(Globals & globals, int dstGen)
printMsg(lvlInfo, format("switching from generation %1% to %2%") printMsg(lvlInfo, format("switching from generation %1% to %2%")
% curGen % dst.number); % curGen % dst.number);
if (globals.dryRun) return; if (globals.dryRun) return;
switchLink(globals.profile, dst.path); switchLink(globals.profile, dst.path);
} }
@ -1201,7 +1201,7 @@ static void opListGenerations(Globals & globals,
PathLocks lock; PathLocks lock;
lockProfile(lock, globals.profile); lockProfile(lock, globals.profile);
int curGen; int curGen;
Generations gens = findGenerations(globals.profile, curGen); Generations gens = findGenerations(globals.profile, curGen);
@ -1225,7 +1225,7 @@ static void deleteGeneration2(Globals & globals, unsigned int gen)
printMsg(lvlInfo, format("removing generation %1%") % gen); printMsg(lvlInfo, format("removing generation %1%") % gen);
deleteGeneration(globals.profile, gen); deleteGeneration(globals.profile, gen);
} }
} }
@ -1237,7 +1237,7 @@ static void opDeleteGenerations(Globals & globals,
PathLocks lock; PathLocks lock;
lockProfile(lock, globals.profile); lockProfile(lock, globals.profile);
int curGen; int curGen;
Generations gens = findGenerations(globals.profile, curGen); Generations gens = findGenerations(globals.profile, curGen);
@ -1272,13 +1272,13 @@ void run(Strings args)
{ {
Strings opFlags, opArgs, remaining; Strings opFlags, opArgs, remaining;
Operation op = 0; Operation op = 0;
Globals globals; Globals globals;
globals.instSource.type = srcUnknown; globals.instSource.type = srcUnknown;
globals.instSource.nixExprPath = getDefNixExprPath(); globals.instSource.nixExprPath = getDefNixExprPath();
globals.instSource.systemFilter = "*"; globals.instSource.systemFilter = "*";
globals.dryRun = false; globals.dryRun = false;
globals.preserveInstalled = false; globals.preserveInstalled = false;
globals.prebuiltOnly = false; globals.prebuiltOnly = false;
@ -1353,7 +1353,7 @@ void run(Strings args)
? absPath(readLink(profileLink), dirOf(profileLink)) ? absPath(readLink(profileLink), dirOf(profileLink))
: canonPath(settings.nixStateDir + "/profiles/default"); : canonPath(settings.nixStateDir + "/profiles/default");
} }
store = openStore(); store = openStore();
op(globals, remaining, opFlags, opArgs); op(globals, remaining, opFlags, opArgs);

View file

@ -41,7 +41,7 @@ Generations findGenerations(Path profile, int & curGen)
Path profileDir = dirOf(profile); Path profileDir = dirOf(profile);
string profileName = baseNameOf(profile); string profileName = baseNameOf(profile);
Strings names = readDirectory(profileDir); Strings names = readDirectory(profileDir);
for (Strings::iterator i = names.begin(); i != names.end(); ++i) { for (Strings::iterator i = names.begin(); i != names.end(); ++i) {
int n; int n;
@ -116,7 +116,7 @@ void switchLink(Path link, Path target)
{ {
/* Hacky. */ /* Hacky. */
if (dirOf(target) == dirOf(link)) target = baseNameOf(target); if (dirOf(target) == dirOf(link)) target = baseNameOf(target);
Path tmp = canonPath(dirOf(link) + "/.new_" + baseNameOf(link)); Path tmp = canonPath(dirOf(link) + "/.new_" + baseNameOf(link));
if (symlink(target.c_str(), tmp.c_str()) != 0) if (symlink(target.c_str(), tmp.c_str()) != 0)
throw SysError(format("creating symlink `%1%'") % tmp); throw SysError(format("creating symlink `%1%'") % tmp);
@ -146,4 +146,3 @@ string optimisticLockProfile(const Path & profile)
} }

View file

@ -91,15 +91,15 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
default: abort(); default: abort();
} }
} }
vMeta.attrs->sort(); vMeta.attrs->sort();
v.attrs->sort(); v.attrs->sort();
/* This is only necessary when installing store paths, e.g., /* This is only necessary when installing store paths, e.g.,
`nix-env -i /nix/store/abcd...-foo'. */ `nix-env -i /nix/store/abcd...-foo'. */
store->addTempRoot(i->queryOutPath(state)); store->addTempRoot(i->queryOutPath(state));
store->ensurePath(i->queryOutPath(state)); store->ensurePath(i->queryOutPath(state));
references.insert(i->queryOutPath(state)); references.insert(i->queryOutPath(state));
if (drvPath != "") references.insert(drvPath); if (drvPath != "") references.insert(drvPath);
} }
@ -123,13 +123,13 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
args.attrs->push_back(Attr(state.symbols.create("derivations"), &manifest)); args.attrs->push_back(Attr(state.symbols.create("derivations"), &manifest));
args.attrs->sort(); args.attrs->sort();
mkApp(topLevel, envBuilder, args); mkApp(topLevel, envBuilder, args);
/* Evaluate it. */ /* Evaluate it. */
debug("evaluating user environment builder"); debug("evaluating user environment builder");
DrvInfo topLevelDrv; DrvInfo topLevelDrv;
if (!getDerivation(state, topLevel, topLevelDrv, false)) if (!getDerivation(state, topLevel, topLevelDrv, false))
abort(); abort();
/* Realise the resulting store expression. */ /* Realise the resulting store expression. */
debug("building user environment"); debug("building user environment");
store->buildPaths(singleton<PathSet>(topLevelDrv.queryDrvPath(state)), state.repair); store->buildPaths(singleton<PathSet>(topLevelDrv.queryDrvPath(state)), state.repair);
@ -143,7 +143,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
printMsg(lvlError, format("profile `%1%' changed while we were busy; restarting") % profile); printMsg(lvlError, format("profile `%1%' changed while we were busy; restarting") % profile);
return false; return false;
} }
debug(format("switching to new user environment")); debug(format("switching to new user environment"));
Path generation = createGeneration(profile, topLevelDrv.queryOutPath(state)); Path generation = createGeneration(profile, topLevelDrv.queryOutPath(state));
switchLink(profile, generation); switchLink(profile, generation);
@ -181,7 +181,7 @@ static MetaInfo parseMeta(std::istream & str)
expect(str, "Bind("); expect(str, "Bind(");
MetaValue value; MetaValue value;
string name = parseString(str); string name = parseString(str);
expect(str, ","); expect(str, ",");
@ -207,7 +207,7 @@ static MetaInfo parseMeta(std::istream & str)
expect(str, ",NoPos)"); expect(str, ",NoPos)");
meta[name] = value; meta[name] = value;
} }
expect(str, ")"); expect(str, ")");
return meta; return meta;
@ -221,7 +221,7 @@ static void readLegacyManifest(const Path & path, DrvInfos & elems)
expect(str, "List(["); expect(str, "List([");
unsigned int n = 0; unsigned int n = 0;
while (!endOfList(str)) { while (!endOfList(str)) {
DrvInfo elem; DrvInfo elem;
expect(str, "Attrs(["); expect(str, "Attrs([");
@ -230,7 +230,7 @@ static void readLegacyManifest(const Path & path, DrvInfos & elems)
expect(str, "Bind("); expect(str, "Bind(");
string name = parseString(str); string name = parseString(str);
expect(str, ","); expect(str, ",");
if (name == "meta") elem.setMetaInfo(parseMeta(str)); if (name == "meta") elem.setMetaInfo(parseMeta(str));
else { else {
string value = parseStr(str); string value = parseStr(str);
@ -256,4 +256,3 @@ static void readLegacyManifest(const Path & path, DrvInfos & elems)
} }