about summary refs log tree commit diff
path: root/src/nix-store/nix-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-27T15·09-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-27T15·09-0400
commite94806d03098f1d6e654542500bbea1eaa0ec60b (patch)
tree4e967f3d39a984d86bb93849d76cab92512a07ce /src/nix-store/nix-store.cc
parent9c2decaa1935ae4bf99a9b723d4eab188f8f88ef (diff)
parenta9e6752bbd888ab8fbc1cda6e4d539b2858c4cef (diff)
Merge branch 'master' into no-manifests
Diffstat (limited to 'src/nix-store/nix-store.cc')
-rw-r--r--src/nix-store/nix-store.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 5ada79713636..d3a707f0d8f4 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -64,15 +64,19 @@ static PathSet realisePath(const Path & path)
     if (isDerivation(path)) {
         store->buildPaths(singleton<PathSet>(path));
         Derivation drv = derivationFromPath(*store, path);
+        rootNr++;
 
         PathSet outputs;
         foreach (DerivationOutputs::iterator, i, drv.outputs) {
             Path outPath = i->second.path;
             if (gcRoot == "")
                 printGCWarning();
-            else
-                outPath = addPermRoot(*store, outPath,
-                    makeRootName(gcRoot, rootNr), indirectRoot);
+            else {
+                Path rootName = gcRoot;
+                if (rootNr > 1) rootName += "-" + int2String(rootNr);
+                if (i->first != "out") rootName += "-" + i->first;
+                outPath = addPermRoot(*store, outPath, rootName, indirectRoot);
+            }
             outputs.insert(outPath);
         }
         return outputs;
@@ -544,10 +548,9 @@ static void opCheckValidity(Strings opFlags, Strings opArgs)
 }
 
 
-static string showBytes(unsigned long long bytes, unsigned long long blocks)
+static string showBytes(unsigned long long bytes)
 {
-    return (format("%d bytes (%.2f MiB, %d blocks)")
-        % bytes % (bytes / (1024.0 * 1024.0)) % blocks).str();
+    return (format("%.2f MiB") % (bytes / (1024.0 * 1024.0))).str();
 }
 
 
@@ -562,7 +565,7 @@ struct PrintFreed
         if (show)
             cout << format("%1% store paths deleted, %2% freed\n")
                 % results.paths.size()
-                % showBytes(results.bytesFreed, results.blocksFreed);
+                % showBytes(results.bytesFreed);
     }
 };
 
@@ -583,7 +586,7 @@ static void opGC(Strings opFlags, Strings opArgs)
         else if (*i == "--delete") options.action = GCOptions::gcDeleteDead;
         else if (*i == "--max-freed") {
             long long maxFreed = getIntArg<long long>(*i, i, opFlags.end());
-            options.maxFreed = maxFreed >= 1 ? maxFreed : 1;
+            options.maxFreed = maxFreed >= 0 ? maxFreed : 0;
         }
         else throw UsageError(format("bad sub-operation `%1%' in GC") % *i);
 
@@ -735,7 +738,7 @@ static void showOptimiseStats(OptimiseStats & stats)
 {
     printMsg(lvlError,
         format("%1% freed by hard-linking %2% files; there are %3% files with equal contents out of %4% files in total")
-        % showBytes(stats.bytesFreed, stats.blocksFreed)
+        % showBytes(stats.bytesFreed)
         % stats.filesLinked
         % stats.sameContents
         % stats.totalFiles);