From f8d91f20e6c88510282263715a1b87c99afad5a1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 26 May 2003 09:44:18 +0000 Subject: * 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. --- src/fix.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/fix.cc') 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 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()", &e2)) { string filename = absPath(evaluateStr(e2, ctx), ctx.dir); /* !!! */ string hash = hashFile(filename); + registerFile(filename); /* !!! */ return ATmake("File()", 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()", hash.c_str()); } -- cgit 1.4.1