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-11-19T23·27+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-11-19T23·27+0100
commit9de6bc5d05027363f968c20e53e8c3d5aa34f8b4 (patch)
treebb299b4c0dd936adb842dd58ab1b230b02db94ed /src/nix-store/nix-store.cc
parentbf3725da2a1e4e91fc34b5faeb55bb3c02f68674 (diff)
nix-store -r: Add ‘--ignore-unknown’ flag
This flag causes paths that do not have a known substitute to be
quietly ignored.  This is mostly useful for Charon, allowing it to
speed up deployment by letting a machine use substitutes for all
substitutable paths, instead of uploading them.  The latter is
frequently faster, e.g. if the target machine has a fast Internet
connection while the source machine is on a slow ADSL line.
Diffstat (limited to '')
-rw-r--r--src/nix-store/nix-store.cc34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index ca49e231c0..e973beda9f 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -94,28 +94,44 @@ static void opRealise(Strings opFlags, Strings opArgs)
 {
     bool dryRun = false;
     bool repair = false;
+    bool ignoreUnknown = false;
 
     foreach (Strings::iterator, i, opFlags)
         if (*i == "--dry-run") dryRun = true;
         else if (*i == "--repair") repair = true;
+        else if (*i == "--ignore-unknown") ignoreUnknown = true;
         else throw UsageError(format("unknown flag `%1%'") % *i);
 
+    Paths paths;
     foreach (Strings::iterator, i, opArgs)
-        *i = followLinksToStorePath(*i);
+        paths.push_back(followLinksToStorePath(*i));
+
+    unsigned long long downloadSize, narSize;
+    PathSet willBuild, willSubstitute, unknown;
+    queryMissing(*store, PathSet(paths.begin(), paths.end()),
+        willBuild, willSubstitute, unknown, downloadSize, narSize);
+
+    if (ignoreUnknown) {
+        Paths paths2;
+        foreach (Paths::iterator, i, paths)
+            if (unknown.find(*i) == unknown.end()) paths2.push_back(*i);
+        paths = paths2;
+        unknown = PathSet();
+    }
 
-    printMissing(*store, PathSet(opArgs.begin(), opArgs.end()));
+    printMissing(willBuild, willSubstitute, unknown, downloadSize, narSize);
 
     if (dryRun) return;
 
     /* Build all paths at the same time to exploit parallelism. */
-    PathSet paths(opArgs.begin(), opArgs.end());
-    store->buildPaths(paths, repair);
+    store->buildPaths(PathSet(paths.begin(), paths.end()), repair);
 
-    foreach (Paths::iterator, i, opArgs) {
-        PathSet paths = realisePath(*i, false);
-        foreach (PathSet::iterator, j, paths)
-            cout << format("%1%\n") % *j;
-    }
+    if (!ignoreUnknown)
+        foreach (Paths::iterator, i, paths) {
+            PathSet paths = realisePath(*i, false);
+            foreach (PathSet::iterator, j, paths)
+                cout << format("%1%\n") % *j;
+        }
 }