about summary refs log tree commit diff
path: root/src/fix.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-05-26T09·44+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-05-26T09·44+0000
commitf8d91f20e6c88510282263715a1b87c99afad5a1 (patch)
treee76bee2541de9e7ccff08b403e938a8a04ff0bfb /src/fix.cc
parent13176d74cc522951e2c8ed6a878a04ddfce778ca (diff)
* Nix can now fetch prebuilts (and other files) from the network, iff
  a mapping from the hash to a url has been registered through `nix
  regurl'.

* Bug fix in nix: don't pollute stdout when running tar, it made
  nix-switch barf.

* Bug fix in nix-push-prebuilts: don't create a subdirectory on the
  target when rsync'ing.

Diffstat (limited to 'src/fix.cc')
-rw-r--r--src/fix.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/fix.cc b/src/fix.cc
index 286b552c381d..b26f8eb594bf 100644
--- a/src/fix.cc
+++ b/src/fix.cc
@@ -23,15 +23,24 @@ static bool verbose = false;
 typedef map<string, string> DescriptorMap;
 
 
-/* Forward declarations. */
-
 void registerFile(string filename)
 {
-    int res = system(("nix regfile " + filename).c_str());
+    int res = system(("nix regfile " + filename).c_str()); 
+    /* !!! escape */
     if (WEXITSTATUS(res) != 0)
         throw Error("cannot register " + filename + " with Nix");
 }
 
+
+void registerURL(string hash, string url)
+{
+    int res = system(("nix regurl " + hash + " " + url).c_str());
+    /* !!! escape */
+    if (WEXITSTATUS(res) != 0)
+        throw Error("cannot register " + hash + " -> " + url + " with Nix");
+}
+
+
 Error badTerm(const string & msg, ATerm e)
 {
     char * s = ATwriteToString(e);
@@ -152,6 +161,7 @@ ATerm evaluate(ATerm e, EvalContext ctx)
     else if (ATmatch(e, "Local(<term>)", &e2)) {
         string filename = absPath(evaluateStr(e2, ctx), ctx.dir); /* !!! */
         string hash = hashFile(filename);
+        registerFile(filename); /* !!! */
         return ATmake("File(<str>)", hash.c_str());
     }
 
@@ -161,12 +171,7 @@ ATerm evaluate(ATerm e, EvalContext ctx)
         string hash = evaluateStr(e2, ctx);
         checkHash(hash);
         string url = evaluateStr(e3, ctx);
-#if 0
-        if (verbose)
-            cerr << "fetching " << url << endl;
-        string filename = fetchURL(url);
-#endif
-        /* !!! register */
+        registerURL(hash, url);
         return ATmake("File(<str>)", hash.c_str());
     }