1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-10 13:03:55 +02:00

* 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.
This commit is contained in:
Eelco Dolstra 2003-05-26 09:44:18 +00:00
parent 13176d74cc
commit f8d91f20e6
6 changed files with 121 additions and 58 deletions

View file

@ -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());
}