about summary refs log tree commit diff
path: root/src/libstore/store-api.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-01-29T18·17+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-01-29T18·17+0000
commit66c51dc21558c6ac5149c5158df7e5b580029e84 (patch)
tree455b9e454c24e0c9d132f8881098e5d240250928 /src/libstore/store-api.cc
parent5b5a3af98372029f3a870cf18cc1442f1434be85 (diff)
* nix-store --dump-db / --load-db to dump/load the Nix DB.
* nix-store --register-validity: option to supply the content hash of
  each path.
* Removed compatibility with Nix <= 0.7 stores.

Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r--src/libstore/store-api.cc38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 22a66ccabd..b5bc85e182 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -151,11 +151,47 @@ Path computeStorePathForText(const string & suffix, const string & s,
 }
 
 
-ValidPathInfo decodeValidPathInfo(std::istream & str)
+/* Return a string accepted by decodeValidPathInfo() that
+   registers the specified paths as valid.  Note: it's the
+   responsibility of the caller to provide a closure. */
+string makeValidityRegistration(const PathSet & paths,
+    bool showDerivers, bool showHash)
+{
+    string s = "";
+    
+    for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) {
+        s += *i + "\n";
+
+        if (showHash)
+            s += printHash(store->queryPathHash(*i)) + "\n";
+
+        Path deriver = showDerivers ? store->queryDeriver(*i) : "";
+        s += deriver + "\n";
+
+        PathSet references;
+        store->queryReferences(*i, references);
+
+        s += (format("%1%\n") % references.size()).str();
+            
+        for (PathSet::iterator j = references.begin();
+             j != references.end(); ++j)
+            s += *j + "\n";
+    }
+
+    return s;
+}
+
+
+ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven)
 {
     ValidPathInfo info;
     getline(str, info.path);
     if (str.eof()) { info.path = ""; return info; }
+    if (hashGiven) {
+        string s;
+        getline(str, s);
+        info.hash = parseHash(htSHA256, s);
+    }
     getline(str, info.deriver);
     string s; int n;
     getline(str, s);