* Descriptor importing in Fix.

This commit is contained in:
Eelco Dolstra 2003-04-08 15:36:54 +00:00
parent cc6eafb3d0
commit f56b7312b2
6 changed files with 48 additions and 14 deletions

View file

@ -11,4 +11,4 @@ AC_PROG_CC
AC_PROG_CXX AC_PROG_CXX
AC_CONFIG_FILES([Makefile src/Makefile]) AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT AC_OUTPUT

View file

@ -2,6 +2,7 @@
#include <map> #include <map>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
extern "C" { extern "C" {
@ -15,9 +16,17 @@ static string nixDescriptorDir;
static string nixSourcesDir; static string nixSourcesDir;
/* Mapping of Fix file names to the hashes of the resulting Nix
descriptors. */
typedef map<string, string> DescriptorMap; typedef map<string, string> DescriptorMap;
/* Forward declarations. */
string instantiateDescriptor(string filename,
DescriptorMap & done);
void registerFile(string filename) void registerFile(string filename)
{ {
int res = system(("nix regfile " + filename).c_str()); int res = system(("nix regfile " + filename).c_str());
@ -52,12 +61,15 @@ string fetchURL(string url)
{ {
string filename = baseNameOf(url); string filename = baseNameOf(url);
string fullname = nixSourcesDir + "/" + filename; string fullname = nixSourcesDir + "/" + filename;
/* !!! quoting */ struct stat st;
string shellCmd = if (stat(fullname.c_str(), &st)) {
"cd " + nixSourcesDir + " && wget --quiet -N \"" + url + "\""; /* !!! quoting */
int res = system(shellCmd.c_str()); string shellCmd =
if (WEXITSTATUS(res) != 0) "cd " + nixSourcesDir + " && wget --quiet -N \"" + url + "\"";
throw Error("cannot fetch " + url); int res = system(shellCmd.c_str());
if (WEXITSTATUS(res) != 0)
throw Error("cannot fetch " + url);
}
return fullname; return fullname;
} }
@ -101,17 +113,21 @@ string evaluateFile(ATerm e, string dir)
throw Error("cannot copy " + filename); throw Error("cannot copy " + filename);
registerFile(nixSourcesDir + "/" + baseNameOf(filename)); registerFile(nixSourcesDir + "/" + baseNameOf(filename));
return hashFile(filename); return hashFile(filename);
} else throw Error("invalid hash expression"); } else throw Error("invalid file expression");
} }
string evaluatePkg(ATerm e, DescriptorMap & done) string evaluatePkg(ATerm e, string dir, DescriptorMap & done)
{ {
char * s; char * s;
ATerm t;
if (ATmatch(e, "<str>", &s)) { if (ATmatch(e, "<str>", &s)) {
checkHash(s); checkHash(s);
return s; return s;
} else throw Error("invalid hash expression"); } else if (ATmatch(e, "Fix(<term>)", &t)) {
string filename = absPath(evaluateStr(t), dir); /* !!! */
return instantiateDescriptor(filename, done);
} else throw Error("invalid pkg expression");
} }
@ -125,7 +141,7 @@ ATerm evaluate(ATerm e, string dir, DescriptorMap & done)
else if (ATmatch(e, "File(<term>)", &t)) else if (ATmatch(e, "File(<term>)", &t))
return ATmake("File(<str>)", evaluateFile(t, dir).c_str()); return ATmake("File(<str>)", evaluateFile(t, dir).c_str());
else if (ATmatch(e, "Pkg(<term>)", &t)) else if (ATmatch(e, "Pkg(<term>)", &t))
return ATmake("Pkg(<str>)", evaluatePkg(t, done).c_str()); return ATmake("Pkg(<str>)", evaluatePkg(t, dir, done).c_str());
else throw Error("invalid expression type"); else throw Error("invalid expression type");
} }
@ -215,8 +231,8 @@ string instantiateDescriptor(string filename,
/* Register it with Nix. */ /* Register it with Nix. */
registerFile(outFilename); registerFile(outFilename);
done[filename] = outFilename; done[filename] = outHash;
return outFilename; return outHash;
} }

View file

@ -7,4 +7,4 @@ Descr(
, Bind("src", File(Url("http://www.cwi.nl/projects/MetaEnv/aterm/aterm-2.0.tar.gz"))) , Bind("src", File(Url("http://www.cwi.nl/projects/MetaEnv/aterm/aterm-2.0.tar.gz")))
, Bind("build", File(Local("../build/aterm-build.sh"))) , Bind("build", File(Local("../build/aterm-build.sh")))
] ]
) )

View file

@ -0,0 +1,10 @@
Descr(
[ Bind("pkgId", Str("glib-2.2.1"))
, Bind("releaseId", Str("1"))
, Bind("pkgconfig", Pkg(Fix("./pkgconfig-0.15.0.fix")))
, Bind("src", File(Url("ftp://ftp.gtk.org/pub/gtk/v2.2/glib-2.2.1.tar.bz2")))
, Bind("build", File(Local("../build/glib-build.sh")))
]
)

View file

@ -0,0 +1,8 @@
Descr(
[ Bind("pkgId", Str("pkgconfig-0.15.0"))
, Bind("releaseId", Str("1"))
, Bind("src", File(Url("http://www.freedesktop.org/software/pkgconfig/releases/pkgconfig-0.15.0.tar.gz")))
, Bind("build", File(Local("../build/pkgconfig-build.sh")))
]
)