about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/store.cc2
-rw-r--r--src/libstore/store.hh1
-rw-r--r--src/nix-store/help.txt4
-rw-r--r--src/nix-store/main.cc44
4 files changed, 34 insertions, 17 deletions
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index 03855408ed4d..e9d65404400e 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -247,7 +247,7 @@ void canonicalisePathMetaData(const Path & path)
 }
 
 
-static bool isValidPathTxn(const Transaction & txn, const Path & path)
+bool isValidPathTxn(const Transaction & txn, const Path & path)
 {
     string s;
     return nixDB.queryString(txn, dbValidPaths, path, s);
diff --git a/src/libstore/store.hh b/src/libstore/store.hh
index d5d8ea81eae8..4a37a66322aa 100644
--- a/src/libstore/store.hh
+++ b/src/libstore/store.hh
@@ -87,6 +87,7 @@ Path toStorePath(const Path & path);
 void canonicalisePathMetaData(const Path & path);
 
 /* Checks whether a path is valid. */ 
+bool isValidPathTxn(const Transaction & txn, const Path & path);
 bool isValidPath(const Path & path);
 
 /* Queries the hash of a valid path. */ 
diff --git a/src/nix-store/help.txt b/src/nix-store/help.txt
index b7d71ec4828f..30f94a051852 100644
--- a/src/nix-store/help.txt
+++ b/src/nix-store/help.txt
@@ -11,8 +11,8 @@ Operations:
 
   --substitute: register a substitute expression (dangerous!)
   --clear-substitutes: clear all substitutes
-  --validpath: register path validity (dangerous!)
-  --isvalid: check path validity
+  --register-validity: register path validity (dangerous!)
+  --check-validity: check path validity
 
   --dump: dump a path as a Nix archive
   --restore: restore a path from a Nix archive
diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc
index 543a84210bd2..f7b2233e42ae 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")