aboutsummaryrefslogtreecommitdiff
path: root/src/nix-store
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-03-08 01:24:59 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-03-08 01:24:59 +0100
commitbdd4646338da296fdf3a8f9dc3cf5aff1dafa163 (patch)
tree8bda49fe3eaef361a025c0f3b64ea51ea7728cbe /src/nix-store
parente73d9e948887621906363a35c980538294898a02 (diff)
Revert "Prevent config.h from being clobbered"
This reverts commit 28bba8c44f484eae38e8a15dcec73cfa999156f6.
Diffstat (limited to 'src/nix-store')
-rw-r--r--src/nix-store/nix-store.cc77
1 files changed, 39 insertions, 38 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index af4f264a6..151ed97e4 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -238,12 +238,6 @@ static void printTree(const Path & path,
PathSet references;
store->queryReferences(path, references);
-#if 0
- for (PathSet::iterator i = drv.inputSrcs.begin();
- i != drv.inputSrcs.end(); ++i)
- cout << format("%1%%2%\n") % (tailPad + treeConn) % *i;
-#endif
-
/* Topologically sort under the relation A < B iff A \in
closure(B). That is, if derivation A is an (possibly indirect)
input of B, then A is printed first. This has the effect of
@@ -251,7 +245,7 @@ static void printTree(const Path & path,
Paths sorted = topoSortPaths(*store, references);
reverse(sorted.begin(), sorted.end());
- for (Paths::iterator i = sorted.begin(); i != sorted.end(); ++i) {
+ foreach (Paths::iterator, i, sorted) {
Paths::iterator j = i; ++j;
printTree(*i, tailPad + treeConn,
j == sorted.end() ? tailPad + treeNull : tailPad + treeLine,
@@ -293,7 +287,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
else if (*i == "--resolve") query = qResolve;
else if (*i == "--roots") query = qRoots;
else if (*i == "--use-output" || *i == "-u") useOutput = true;
- else if (*i == "--force-realise" || *i == "-f") forceRealise = true;
+ else if (*i == "--force-realise" || *i == "--force-realize" || *i == "-f") forceRealise = true;
else if (*i == "--include-outputs") includeOutputs = true;
else throw UsageError(format("unknown flag `%1%'") % *i);
@@ -460,35 +454,42 @@ static void opReadLog(Strings opFlags, Strings opArgs)
foreach (Strings::iterator, i, opArgs) {
Path path = useDeriver(followLinksToStorePath(*i));
- Path logPath = (format("%1%/%2%/%3%") %
- settings.nixLogDir % drvsLogDir % baseNameOf(path)).str();
- Path logBz2Path = logPath + ".bz2";
-
- if (pathExists(logPath)) {
- /* !!! Make this run in O(1) memory. */
- string log = readFile(logPath);
- writeFull(STDOUT_FILENO, (const unsigned char *) log.data(), log.size());
- }
+ for (int j = 0; j <= 2; j++) {
+ if (j == 2) throw Error(format("build log of derivation `%1%' is not available") % path);
+
+ string baseName = baseNameOf(path);
+ Path logPath =
+ j == 0
+ ? (format("%1%/%2%/%3%/%4%") % settings.nixLogDir % drvsLogDir % string(baseName, 0, 2) % string(baseName, 2)).str()
+ : (format("%1%/%2%/%3%") % settings.nixLogDir % drvsLogDir % baseName).str();
+ Path logBz2Path = logPath + ".bz2";
+
+ if (pathExists(logPath)) {
+ /* !!! Make this run in O(1) memory. */
+ string log = readFile(logPath);
+ writeFull(STDOUT_FILENO, (const unsigned char *) log.data(), log.size());
+ break;
+ }
- else if (pathExists(logBz2Path)) {
- AutoCloseFD fd = open(logBz2Path.c_str(), O_RDONLY);
- FILE * f = 0;
- if (fd == -1 || (f = fdopen(fd.borrow(), "r")) == 0)
- throw SysError(format("opening file `%1%'") % logBz2Path);
- int err;
- BZFILE * bz = BZ2_bzReadOpen(&err, f, 0, 0, 0, 0);
- if (!bz) throw Error(format("cannot open bzip2 file `%1%'") % logBz2Path);
- unsigned char buf[128 * 1024];
- do {
- int n = BZ2_bzRead(&err, bz, buf, sizeof(buf));
- if (err != BZ_OK && err != BZ_STREAM_END)
- throw Error(format("error reading bzip2 file `%1%'") % logBz2Path);
- writeFull(STDOUT_FILENO, buf, n);
- } while (err != BZ_STREAM_END);
- BZ2_bzReadClose(&err, bz);
+ else if (pathExists(logBz2Path)) {
+ AutoCloseFD fd = open(logBz2Path.c_str(), O_RDONLY);
+ FILE * f = 0;
+ if (fd == -1 || (f = fdopen(fd.borrow(), "r")) == 0)
+ throw SysError(format("opening file `%1%'") % logBz2Path);
+ int err;
+ BZFILE * bz = BZ2_bzReadOpen(&err, f, 0, 0, 0, 0);
+ if (!bz) throw Error(format("cannot open bzip2 file `%1%'") % logBz2Path);
+ unsigned char buf[128 * 1024];
+ do {
+ int n = BZ2_bzRead(&err, bz, buf, sizeof(buf));
+ if (err != BZ_OK && err != BZ_STREAM_END)
+ throw Error(format("error reading bzip2 file `%1%'") % logBz2Path);
+ writeFull(STDOUT_FILENO, buf, n);
+ } while (err != BZ_STREAM_END);
+ BZ2_bzReadClose(&err, bz);
+ break;
+ }
}
-
- else throw Error(format("build log of derivation `%1%' is not available") % path);
}
}
@@ -514,7 +515,7 @@ static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
if (!store->isValidPath(info.path) || reregister) {
/* !!! races */
if (canonicalise)
- canonicalisePathMetaData(info.path);
+ canonicalisePathMetaData(info.path, -1);
if (!hashGiven) {
HashResult hash = hashPath(htSHA256, info.path);
info.hash = hash.first;
@@ -842,7 +843,7 @@ void run(Strings args)
Operation oldOp = op;
- if (arg == "--realise" || arg == "-r")
+ if (arg == "--realise" || arg == "--realize" || arg == "-r")
op = opRealise;
else if (arg == "--add" || arg == "-A")
op = opAdd;
@@ -884,7 +885,7 @@ void run(Strings args)
op = opVerifyPath;
else if (arg == "--repair-path")
op = opRepairPath;
- else if (arg == "--optimise")
+ else if (arg == "--optimise" || arg == "--optimize")
op = opOptimise;
else if (arg == "--query-failed-paths")
op = opQueryFailedPaths;