about summary refs log tree commit diff
path: root/src/nix-store/main.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-03-23T11·25+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-03-23T11·25+0000
commitf20f08156031f04a60025bc7a41dd3fcc117baa7 (patch)
tree92fc4f9a07f3504ffc936a2b5b796d527fdd6436 /src/nix-store/main.cc
parenta1e00bf6aa8eb581ff4d47a6287800cf224c6a41 (diff)
* nix-store: `--isvalid' -> `--check-validity', `--validpath' ->
  `--register-validity'.
* `nix-store --register-validity': read arguments from stdin, and
  allow the references and deriver to be set.

Diffstat (limited to 'src/nix-store/main.cc')
-rw-r--r--src/nix-store/main.cc44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc
index 543a84210b..f7b2233e42 100644
--- a/src/nix-store/main.cc
+++ b/src/nix-store/main.cc
@@ -355,8 +355,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
 static void opSubstitute(Strings opFlags, Strings opArgs)
 {
     if (!opFlags.empty()) throw UsageError("unknown flag");
-    if (!opArgs.empty())
-        throw UsageError("no arguments expected");
+    if (!opArgs.empty()) throw UsageError("no arguments expected");
 
     Transaction txn;
     createStoreTransaction(txn);
@@ -369,8 +368,7 @@ static void opSubstitute(Strings opFlags, Strings opArgs)
         if (cin.eof()) break;
         getline(cin, sub.deriver);
         getline(cin, sub.program);
-        string s;
-        int n;
+        string s; int n;
         getline(cin, s);
         if (!string2Int(s, n)) throw Error("number expected");
         while (n--) {
@@ -402,20 +400,38 @@ static void opClearSubstitutes(Strings opFlags, Strings opArgs)
 }
 
 
-static void opValidPath(Strings opFlags, Strings opArgs)
+static void opRegisterValidity(Strings opFlags, Strings opArgs)
 {
     if (!opFlags.empty()) throw UsageError("unknown flag");
-    
+    if (!opArgs.empty()) throw UsageError("no arguments expected");
+
     Transaction txn;
     createStoreTransaction(txn);
-    for (Strings::iterator i = opArgs.begin();
-         i != opArgs.end(); ++i)
-        registerValidPath(txn, *i, hashPath(htSHA256, *i), PathSet(), "");
+
+    while (1) {
+        Path path;
+        Path deriver;
+        PathSet references;
+        getline(cin, path);
+        if (cin.eof()) break;
+        getline(cin, deriver);
+        string s; int n;
+        getline(cin, s);
+        if (!string2Int(s, n)) throw Error("number expected");
+        while (n--) {
+            getline(cin, s);
+            references.insert(s);
+        }
+        if (!cin || cin.eof()) throw Error("missing input");
+        if (!isValidPathTxn(txn, path))
+            registerValidPath(txn, path, hashPath(htSHA256, path), references, deriver);
+    }
+
     txn.commit();
 }
 
 
-static void opIsValid(Strings opFlags, Strings opArgs)
+static void opCheckValidity(Strings opFlags, Strings opArgs)
 {
     if (!opFlags.empty()) throw UsageError("unknown flag");
 
@@ -545,10 +561,10 @@ void run(Strings args)
             op = opSubstitute;
         else if (arg == "--clear-substitutes")
             op = opClearSubstitutes;
-        else if (arg == "--validpath")
-            op = opValidPath;
-        else if (arg == "--isvalid")
-            op = opIsValid;
+        else if (arg == "--register-validity")
+            op = opRegisterValidity;
+        else if (arg == "--check-validity")
+            op = opCheckValidity;
         else if (arg == "--gc")
             op = opGC;
         else if (arg == "--dump")