mirror of
https://github.com/NixOS/nix
synced 2025-07-07 18:31:49 +02:00
* Autoconf / Automake configuration and building.
This commit is contained in:
parent
ab723e341a
commit
136c00e881
15 changed files with 639 additions and 1470 deletions
21
src/Makefile
21
src/Makefile
|
@ -1,21 +0,0 @@
|
|||
all: nix nix-instantiate
|
||||
|
||||
SYSTEM = $(shell ./config.guess)
|
||||
|
||||
nix: nix.o md5.o
|
||||
g++ -g -o $@ $^ -ldb_cxx-4 -lATerm
|
||||
|
||||
%.o: %.cc
|
||||
g++ -g -Wall -o $@ -c $< -DSYSTEM=\"$(SYSTEM)\"
|
||||
|
||||
%.o: %.c
|
||||
gcc -g -Wall -o $@ -c $< -DSYSTEM=\"$(SYSTEM)\"
|
||||
|
||||
md5.o: md5.c md5.h
|
||||
|
||||
nix-instantiate: nix-instantiate.in
|
||||
sed "s/@SYSTEM@/$(SYSTEM)/" < $^ > $@
|
||||
chmod +x $@
|
||||
|
||||
clean:
|
||||
rm -f *.o nix nix-instantiate
|
5
src/Makefile.am
Normal file
5
src/Makefile.am
Normal file
|
@ -0,0 +1,5 @@
|
|||
bin_PROGRAMS = nix
|
||||
|
||||
nix_SOURCES = nix.cc md5.c
|
||||
nix_CXXFLAGS = -DSYSTEM=\"@host@\"
|
||||
nix_LDADD = -ldb_cxx-4 -lATerm
|
1400
src/config.guess
vendored
1400
src/config.guess
vendored
File diff suppressed because it is too large
Load diff
|
@ -5,7 +5,7 @@ use FileHandle;
|
|||
use File::Spec;
|
||||
use Digest::MD5;
|
||||
|
||||
my $system = "@SYSTEM@";
|
||||
my $system = "@host@";
|
||||
|
||||
my $outdir = File::Spec->rel2abs($ARGV[0]);
|
||||
my $netdir = File::Spec->rel2abs($ARGV[1]);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#! /usr/bin/perl -w
|
||||
|
||||
my $dir = $ENV{"NIX"} . "/prebuilts";
|
||||
my $dir = $ARGV[0];
|
||||
|
||||
foreach my $prebuilt (glob("$dir/*.tar.bz2")) {
|
||||
|
||||
|
|
61
src/nix.cc
61
src/nix.cc
|
@ -24,53 +24,25 @@ extern "C" {
|
|||
#include "md5.h"
|
||||
}
|
||||
|
||||
#include "util.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define PKGINFO_ENVVAR "NIX_DB"
|
||||
#define PKGINFO_PATH "/pkg/sys/var/pkginfo"
|
||||
|
||||
#define PKGHOME_ENVVAR "NIX_PKGHOME"
|
||||
|
||||
|
||||
/* Database names. */
|
||||
static string dbRefs = "refs";
|
||||
static string dbInstPkgs = "pkginst";
|
||||
static string dbPrebuilts = "prebuilts";
|
||||
|
||||
|
||||
static string prog;
|
||||
static string dbfile = PKGINFO_PATH;
|
||||
|
||||
|
||||
static string pkgHome = "/pkg";
|
||||
|
||||
|
||||
/* The canonical system name, as returned by config.guess. */
|
||||
static string thisSystem = SYSTEM;
|
||||
|
||||
|
||||
class Error : public exception
|
||||
{
|
||||
string err;
|
||||
public:
|
||||
Error(string _err) { err = _err; }
|
||||
~Error() throw () { };
|
||||
const char * what() const throw () { return err.c_str(); }
|
||||
};
|
||||
|
||||
class UsageError : public Error
|
||||
{
|
||||
public:
|
||||
UsageError(string _err) : Error(_err) { };
|
||||
};
|
||||
|
||||
class BadRefError : public Error
|
||||
{
|
||||
public:
|
||||
BadRefError(string _err) : Error(_err) { };
|
||||
};
|
||||
|
||||
|
||||
typedef vector<string> Strings;
|
||||
/* The prefix of the Nix installation, and the environment variable
|
||||
that can be used to override the default. */
|
||||
static string nixHomeDir = "/nix";
|
||||
static string nixHomeDirEnvVar = "NIX";
|
||||
|
||||
|
||||
/* Wrapper classes that ensures that the database is closed upon
|
||||
|
@ -98,7 +70,7 @@ auto_ptr<Db2> openDB(const string & dbname, bool readonly)
|
|||
|
||||
db = auto_ptr<Db2>(new Db2(0, 0));
|
||||
|
||||
db->open(dbfile.c_str(), dbname.c_str(),
|
||||
db->open((nixHomeDir + "/var/nix/pkginfo.db").c_str(), dbname.c_str(),
|
||||
DB_HASH, readonly ? DB_RDONLY : DB_CREATE, 0666);
|
||||
|
||||
return db;
|
||||
|
@ -336,7 +308,7 @@ void installPkg(string hash)
|
|||
string id = getFromEnv(env, "id");
|
||||
|
||||
/* Construct a path for the installed package. */
|
||||
path = pkgHome + "/" + id + "-" + hash;
|
||||
path = nixHomeDir + "/pkg/" + id + "-" + hash;
|
||||
|
||||
/* Create the path. */
|
||||
if (mkdir(path.c_str(), 0777))
|
||||
|
@ -767,11 +739,8 @@ void run(Strings::iterator argCur, Strings::iterator argEnd)
|
|||
{
|
||||
umask(0022);
|
||||
|
||||
if (getenv(PKGINFO_ENVVAR))
|
||||
dbfile = getenv(PKGINFO_ENVVAR);
|
||||
|
||||
if (getenv(PKGHOME_ENVVAR))
|
||||
pkgHome = getenv(PKGHOME_ENVVAR);
|
||||
char * homeDir = getenv(nixHomeDirEnvVar.c_str());
|
||||
if (homeDir) nixHomeDir = homeDir;
|
||||
|
||||
/* Parse the global flags. */
|
||||
for ( ; argCur != argEnd; argCur++) {
|
||||
|
@ -779,8 +748,6 @@ void run(Strings::iterator argCur, Strings::iterator argEnd)
|
|||
if (arg == "-h" || arg == "--help") {
|
||||
printUsage();
|
||||
return;
|
||||
} else if (arg == "-d") {
|
||||
dbfile = optarg;
|
||||
} else if (arg[0] == '-') {
|
||||
throw UsageError("invalid option `" + arg + "'");
|
||||
} else break;
|
||||
|
@ -848,9 +815,9 @@ int main(int argc, char * * argv)
|
|||
while (argc--) args.push_back(*argv++);
|
||||
Strings::iterator argCur = args.begin(), argEnd = args.end();
|
||||
|
||||
prog = *argCur++;
|
||||
argCur++;
|
||||
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
run(argCur, argEnd);
|
||||
} catch (DbException e) {
|
||||
|
|
34
src/util.hh
Normal file
34
src/util.hh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef __UTIL_H
|
||||
#define __UTIL_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class Error : public exception
|
||||
{
|
||||
string err;
|
||||
public:
|
||||
Error(string _err) { err = _err; }
|
||||
~Error() throw () { };
|
||||
const char * what() const throw () { return err.c_str(); }
|
||||
};
|
||||
|
||||
class UsageError : public Error
|
||||
{
|
||||
public:
|
||||
UsageError(string _err) : Error(_err) { };
|
||||
};
|
||||
|
||||
class BadRefError : public Error
|
||||
{
|
||||
public:
|
||||
BadRefError(string _err) : Error(_err) { };
|
||||
};
|
||||
|
||||
|
||||
typedef vector<string> Strings;
|
||||
|
||||
|
||||
#endif /* !__UTIL_H */
|
Loading…
Add table
Add a link
Reference in a new issue