diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-04-08T14·05+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-04-08T14·05+0000 |
commit | cc6eafb3d0a53c8bb02746411d3d41403ce9eb83 (patch) | |
tree | cdf6363fb09c229923a6d0e72106b6b9c5f68e11 /src | |
parent | f7ef88df1fd6087deae02a53b8f18b64050f75db (diff) |
* FreeBSD / gcc 2.95 compatibility fixes.
* A script to generate prebuilt registration scripts.
Diffstat (limited to 'src')
-rw-r--r-- | src/fix.cc | 42 | ||||
-rwxr-xr-x | src/nix-regprebuilts | 17 | ||||
-rw-r--r-- | src/nix.cc | 7 |
3 files changed, 30 insertions, 36 deletions
diff --git a/src/fix.cc b/src/fix.cc index cb1990928469..bf335bc365b6 100644 --- a/src/fix.cc +++ b/src/fix.cc @@ -1,6 +1,9 @@ #include <iostream> #include <map> +#include <sys/types.h> +#include <sys/wait.h> + extern "C" { #include <aterm2.h> } @@ -23,13 +26,31 @@ void registerFile(string filename) } +/* Return the directory part of the given path, i.e., everything + before the final `/'. */ +string dirOf(string s) +{ + unsigned int pos = s.rfind('/'); + if (pos == string::npos) throw Error("invalid file name"); + return string(s, 0, pos); +} + + +/* Return the base name of the given path, i.e., everything following + the final `/'. */ +string baseNameOf(string s) +{ + unsigned int pos = s.rfind('/'); + if (pos == string::npos) throw Error("invalid file name"); + return string(s, pos + 1); +} + + /* Download object referenced by the given URL into the sources directory. Return the file name it was downloaded to. */ string fetchURL(string url) { - unsigned int pos = url.rfind('/'); - if (pos == string::npos) throw Error("invalid url"); - string filename(url, pos + 1); + string filename = baseNameOf(url); string fullname = nixSourcesDir + "/" + filename; /* !!! quoting */ string shellCmd = @@ -41,16 +62,6 @@ string fetchURL(string url) } -/* Return the directory part of the given path, i.e., everything - before the final `/'. */ -string dirOf(string s) -{ - unsigned int pos = s.rfind('/'); - if (pos == string::npos) throw Error("invalid file name"); - return string(s, 0, pos); -} - - /* Term evaluation functions. */ string evaluateStr(ATerm e) @@ -88,12 +99,13 @@ string evaluateFile(ATerm e, string dir) int res = system(cmd.c_str()); if (WEXITSTATUS(res) != 0) throw Error("cannot copy " + filename); + registerFile(nixSourcesDir + "/" + baseNameOf(filename)); return hashFile(filename); } else throw Error("invalid hash expression"); } -ATerm evaluatePkg(ATerm e, DescriptorMap & done) +string evaluatePkg(ATerm e, DescriptorMap & done) { char * s; if (ATmatch(e, "<str>", &s)) { @@ -113,7 +125,7 @@ ATerm evaluate(ATerm e, string dir, DescriptorMap & done) else if (ATmatch(e, "File(<term>)", &t)) return ATmake("File(<str>)", evaluateFile(t, dir).c_str()); else if (ATmatch(e, "Pkg(<term>)", &t)) - return ATmake("Pkg(<term>)", evaluatePkg(t, done)); + return ATmake("Pkg(<str>)", evaluatePkg(t, done).c_str()); else throw Error("invalid expression type"); } diff --git a/src/nix-regprebuilts b/src/nix-regprebuilts deleted file mode 100755 index 6c9c981eee29..000000000000 --- a/src/nix-regprebuilts +++ /dev/null @@ -1,17 +0,0 @@ -#! /usr/bin/perl -w - -my $dir = $ARGV[0]; - -foreach my $prebuilt (glob("$dir/*.tar.bz2")) { - - $prebuilt =~ /-([a-z0-9]+)-([a-z0-9]+).tar.bz2$/ - || die "invalid file name: $prebuilt"; - - my $pkgHash = $1; - my $prebuiltHash = $2; - - print "$pkgHash -> $prebuiltHash\n"; - - system "nix regprebuilt $pkgHash $prebuiltHash"; - system "nix regfile $prebuilt"; -} diff --git a/src/nix.cc b/src/nix.cc index 9e42917a49fe..9364baf6caa6 100644 --- a/src/nix.cc +++ b/src/nix.cc @@ -6,11 +6,12 @@ #include <map> #include <cstdio> +#include <errno.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/wait.h> -#include <db4/db_cxx.h> +#include <db_cxx.h> extern "C" { #include <aterm1.h> @@ -48,9 +49,7 @@ public: auto_ptr<Db2> openDB(const string & dbname, bool readonly) { - auto_ptr<Db2> db; - - db = auto_ptr<Db2>(new Db2(0, 0)); + auto_ptr<Db2> db(new Db2(0, 0)); db->open((nixHomeDir + "/var/nix/pkginfo.db").c_str(), dbname.c_str(), DB_HASH, readonly ? DB_RDONLY : DB_CREATE, 0666); |