From 3fc0b0da5840c2d326ae0b749ed609c2e000a7c8 Mon Sep 17 00:00:00 2001 From: Wouter den Breejen Date: Sun, 20 May 2007 12:29:55 +0000 Subject: [PATCH] build error --- configure.ac | 16 +++++++++ install_full.sh | 29 +++++++++++++---- scripts/nix-pull.in | 6 ++++ src/libexpr/primops.cc | 56 ++++---------------------------- src/libmain/Makefile.am | 3 ++ src/libmain/shared.cc | 6 ++-- src/libstore/Makefile.am | 3 +- src/libstore/derivations-ast.def | 2 +- src/libstore/derivations.cc | 5 +-- src/libstore/globals.cc | 2 ++ src/libstore/globals.hh | 12 +++++-- src/libstore/store-api.cc | 2 +- src/libstore/store-api.hh | 3 ++ src/libutil/Makefile.am | 7 ++-- src/libutil/util.cc | 11 +++++-- src/libutil/util.hh | 2 +- tests/common.sh.in | 1 + tests/init.sh | 2 ++ 18 files changed, 97 insertions(+), 71 deletions(-) diff --git a/configure.ac b/configure.ac index 7a1c283a2..3305aeb9a 100644 --- a/configure.ac +++ b/configure.ac @@ -164,6 +164,16 @@ AC_ARG_WITH(store-dir, AC_HELP_STRING([--with-store-dir=PATH], storedir=$withval, storedir='${prefix}/store') AC_SUBST(storedir) +AC_ARG_WITH(store-state-dir, AC_HELP_STRING([--with-store-state-dir=PATH], + [path of the Nix state store]), + storestatedir=$withval, storestatedir='${prefix}/state') +AC_SUBST(storestatedir) + +AC_ARG_WITH(store-state-repos-dir, AC_HELP_STRING([--with-store-state-repos-dir=PATH], + [path of the Nix state store repository]), + storestatereposdir=$withval, storestatereposdir='${prefix}/staterepos') +AC_SUBST(storestatereposdir) + AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb=PATH], [prefix of Berkeley DB]), bdb=$withval, bdb=) @@ -178,6 +188,12 @@ fi AC_SUBST(bdb_lib) AC_SUBST(bdb_include) +NEED_PROG(svn, svn) +AC_ARG_WITH(svn-bin, AC_HELP_STRING([--with-svn-bin=PATH], + [path of svn, svnadmin]), + subversion=$withval, subversion=$(dirname $svn)) +AC_SUBST(subversion) + AC_ARG_WITH(aterm, AC_HELP_STRING([--with-aterm=PATH], [prefix of CWI ATerm library]), aterm=$withval, aterm=) diff --git a/install_full.sh b/install_full.sh index 6882d428d..8c9121cbf 100755 --- a/install_full.sh +++ b/install_full.sh @@ -1,6 +1,10 @@ #! /bin/sh -e +export nixstatepath=/nixstate/nix +export ACLOCAL_PATH=/root/.nix-profile/share/aclocal + if [ "$1" = "full" ]; then + nix-env-all-pkgs.sh -i gnum4 nix-env-all-pkgs.sh -i autoconf nix-env-all-pkgs.sh -i automake nix-env-all-pkgs.sh -i gnused @@ -16,10 +20,19 @@ if [ "$1" = "full" ]; then nix-env-all-pkgs.sh -i gdb #optional for debugging fi -export nixstatepath=/nixstate/nix -export ACLOCAL_PATH=/root/.nix-profile/share/aclocal +if [ "$1" = "full" ] || [ "$1" = "auto" ]; then + export AUTOCONF=autoconf + export AUTOHEADER=autoheader + export AUTOMAKE=automake + autoconf + autoreconf -f + aclocal + autoheader + automake +fi ./bootstrap.sh + ./configure --with-aterm=$HOME/.nix-profile \ --with-bzip2=$HOME/.nix-profile \ --with-bdb=$HOME/.nix-profile \ @@ -28,8 +41,12 @@ export ACLOCAL_PATH=/root/.nix-profile/share/aclocal --with-docbook-xsl=/root/.nix-profile/xml/xsl/docbook \ --prefix=$nixstatepath \ --with-store-dir=/nix/store \ + --with-store-state-dir=/nix/state \ + --with-store-state-repos-dir=/nix/staterepos \ --localstatedir=/nix/var + + #Options from the nix expr #--disable-init-state #--with-store-dir=/nix/store @@ -44,7 +61,7 @@ echo "New state nix version by wouter ..." > doc/manual/NEWS.txt make make install -for i in $nixstatepath/bin/*; do - echo "pathing $i" - patchelf --set-rpath ../lib/nix/:$(patchelf --print-rpath $i) $i -done +#for i in $nixstatepath/bin/*; do +# echo "pathing $i" +# patchelf --set-rpath ../lib/nix/:$(patchelf --print-rpath $i) $i +#done diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in index c2e022e12..5633204e1 100644 --- a/scripts/nix-pull.in +++ b/scripts/nix-pull.in @@ -24,6 +24,12 @@ $storeDir = "@storedir@" unless defined $storeDir; my $storeStateDir = $ENV{"NIX_STORE_STATE_DIR"}; $storeStateDir = "@storestatedir@" unless defined $storeStateDir; +my $storeStateReposDir = $ENV{"NIX_STORE_STATE_REPOS_DIR"}; +$storeStateReposDir = "@storestatereposdir@" unless defined $storeStateReposDir; + +my $subversion = $ENV{"NIX_SVN_BIN_DIR"}; +$subversion = "@subversion@" unless defined $subversion; + # Prevent access problems in shared-stored installations. umask 0022; diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 81d3b117e..63dc5ccd0 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -345,14 +345,6 @@ static Hash hashDerivationModulo(EvalState & state, Derivation drv) return hashTerm(unparseDerivation(drv)); } - -static Expr prim_mkStatePath2(EvalState & state, const ATermVector & args) -{ - PathSet context; - return makeStr("$statepath", context); -} - - /* Construct (as a unobservable side effect) a Nix derivation expression that performs the derivation described by the argument set. Returns the original set extended with the following @@ -561,19 +553,16 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args) drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash); /* Add the state path based on the outPath */ - string callingUser = "wouterdb"; //TODO: Change into variable - string statePrefix = "/nix/state/"; //TODO: Change into variable + string callingUser = "wouterdb"; //TODO: Change into variable + string componentHash = printHash(hashDerivationModulo(state, drv)); //hash of the component path + Hash statehash = hashString(htSHA256, stateIndentifier + callingUser + componentHash); //hash of the state path + Path stateOutPath = makeStatePath("stateOutput:statepath", statehash, drvName); // - //Path outPath = makeStatePath("stateOutput:statepath", hashDerivationModulo(state, drv), drvName); - - string componentHash = printHash(hashDerivationModulo(state, drv)); - Hash hash = hashString(htSHA256, stateIndentifier + callingUser + componentHash); //calculate state hash - string statePath = statePrefix + printHash(hash) + "/"; //make the state path - drv.env["statepath"] = statePath; + drv.env["statepath"] = stateOutPath; string enableStateS = "false"; if(enableState && disableState == false) enableStateS = "true"; - drv.stateOutputs["state"] = DerivationStateOutput(statePath, outputHashAlgo, outputHash, enableStateS, shareState, syncState); + drv.stateOutputs["state"] = DerivationStateOutput(stateOutPath, outputHashAlgo, outputHash, enableStateS, shareState, syncState); /* Write the resulting term into the Nix store directory. */ Path drvPath = writeDerivation(drv, drvName); @@ -649,39 +638,6 @@ static Expr prim_baseNameOf(EvalState & state, const ATermVector & args) } -/* ..... */ - -static Expr prim_mkStatePath(EvalState & state, const ATermVector & args) -{ - PathSet context; - string indentifier = coerceToString(state, args[0], context); - string subdir = coerceToString(state, args[1], context); - string callingUser = "wouterdb"; //TODO: Change into variable - string statePrefix = "/nix/state/"; //TODO: Change into variable - - //calculate state hash - Hash hash = hashString(htSHA256, indentifier + callingUser); - - //make the path - string path = statePrefix + printHash(hash) + "/"; - - if(subdir == "") - { - } - else - { - path = path + subdir; - } - - //PRE BUILD, After DRV Rewrite: - //ensureDir - //system("chown callingUser.root " + path); - - //share state location if nessesary - - return makeStr(path, context); -} - /* Return the directory of the given path, i.e., everything before the last slash. Return either a path or a string depending on the type of the argument. */ diff --git a/src/libmain/Makefile.am b/src/libmain/Makefile.am index e5d199e2c..dd1455df8 100644 --- a/src/libmain/Makefile.am +++ b/src/libmain/Makefile.am @@ -4,6 +4,9 @@ libmain_la_SOURCES = shared.cc shared.hh AM_CXXFLAGS = \ -DNIX_STORE_DIR=\"$(storedir)\" \ + -DNIX_STORE_STATE_DIR=\"$(storestatedir)\" \ + -DNIX_STORE_STATE_REPOS_DIR=\"$(storestatereposdir)\" \ + -DNIX_SVN_BIN_DIR=\"$(subversion)\" \ -DNIX_DATA_DIR=\"$(datadir)\" \ -DNIX_STATE_DIR=\"$(localstatedir)/nix\" \ -DNIX_LOG_DIR=\"$(localstatedir)/log/nix\" \ diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 7e7f165ef..f33f90ce2 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -87,11 +87,13 @@ static void initAndRun(int argc, char * * argv) { /* Setup Nix paths. */ nixStore = canonPath(getEnv("NIX_STORE_DIR", getEnv("NIX_STORE", NIX_STORE_DIR))); - nixStoreState = canonPath(getEnv("NIX_STORE_STATE_DIR", NIX_STORE_STATE_DIR)); //store state dir usually /nix/state + nixStoreState = canonPath(getEnv("NIX_STORE_STATE_DIR", NIX_STORE_STATE_DIR)); //store state dir usually /nix/state + nixStoreStateRepos = canonPath(getEnv("NIX_STORE_STATE_REPOS_DIR", NIX_STORE_STATE_REPOS_DIR)); //store state dir usually /nix/state nixDataDir = canonPath(getEnv("NIX_DATA_DIR", NIX_DATA_DIR)); nixLogDir = canonPath(getEnv("NIX_LOG_DIR", NIX_LOG_DIR)); - nixStateDir = canonPath(getEnv("NIX_STATE_DIR", NIX_STATE_DIR)); //nix global state dir + nixStateDir = canonPath(getEnv("NIX_STATE_DIR", NIX_STATE_DIR)); //nix global state dir nixDBPath = getEnv("NIX_DB_DIR", nixStateDir + "/db"); + nixSVNPath = getEnv("NIX_SVN_BIN_DIR", NIX_SVN_BIN_DIR); nixConfDir = canonPath(getEnv("NIX_CONF_DIR", NIX_CONF_DIR)); nixLibexecDir = canonPath(getEnv("NIX_LIBEXEC_DIR", NIX_LIBEXEC_DIR)); nixBinDir = canonPath(getEnv("NIX_BIN_DIR", NIX_BIN_DIR)); diff --git a/src/libstore/Makefile.am b/src/libstore/Makefile.am index 21b1545f6..8e3b3cc35 100644 --- a/src/libstore/Makefile.am +++ b/src/libstore/Makefile.am @@ -9,7 +9,8 @@ pkginclude_HEADERS = \ globals.hh db.hh references.hh pathlocks.hh \ worker-protocol.hh -libstore_la_LIBADD = ../libutil/libutil.la ../boost/format/libformat.la +libstore_la_LIBADD = ../libutil/libutil.la \ + ../boost/format/libformat.la BUILT_SOURCES = derivations-ast.cc derivations-ast.hh diff --git a/src/libstore/derivations-ast.def b/src/libstore/derivations-ast.def index e8e2d283a..603795693 100644 --- a/src/libstore/derivations-ast.def +++ b/src/libstore/derivations-ast.def @@ -8,7 +8,7 @@ Derive | ATermList ATermList ATermList ATermList ATermList string string ATermLi | string ATermList | ATerm | DerivationInput | | string string string string | ATerm | DerivationOutput | | string string string string string string string | ATerm | DerivationStateOutput | -| string string string string | ATerm | DerivationStateOutputDir | +| string string string | ATerm | DerivationStateOutputDir | Closure | ATermList ATermList | ATerm | OldClosure | | string ATermList | ATerm | OldClosureElem | diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index c26009bf7..2170b4ad5 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -102,8 +102,9 @@ Derivation parseDerivation(ATerm t) //parse state dirs part for (ATermIterator i(stateOutDirs); i; ++i) { ATerm id, path, type, interval; - if (!matchDerivationStateOutputDir(*i, id, path, type, interval)) + if (!matchDerivationStateOutputDir(*i, id, /*path,*/ type, interval)) throwBadDrv(t); + path = id; DerivationStateOutputDir stateOutDirs; stateOutDirs.path = aterm2String(path); stateOutDirs.type = aterm2String(type); @@ -175,7 +176,7 @@ ATerm unparseDerivation(const Derivation & drv) stateOutputDirs = ATinsert(stateOutputDirs, makeDerivationStateOutputDir( toATerm(i->first), - toATerm(i->second.path), + //toATerm(i->second.path), toATerm(i->second.type), toATerm(i->second.interval) )); diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 17f084143..91f88eab5 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -10,10 +10,12 @@ namespace nix { string nixStore = "/UNINIT"; string nixStoreState = "/UNINIT"; +string nixStoreStateRepos = "/UNINIT"; string nixDataDir = "/UNINIT"; string nixLogDir = "/UNINIT"; string nixStateDir = "/UNINIT"; string nixDBPath = "/UNINIT"; +string nixSVNPath = "/UNINIT"; string nixConfDir = "/UNINIT"; string nixLibexecDir = "/UNINIT"; string nixBinDir = "/UNINIT"; diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index af1076e9f..d37b56469 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -18,12 +18,21 @@ extern string nixDataDir; /* !!! fix */ /* nixLogDir is the directory where we log various operations. */ extern string nixLogDir; -/* nixStateDir is the directory where the state dirs of the components are stored. */ +/* nixStoreState is the directory where the state dirs of the components are stored. */ extern string nixStoreState; +/* nixStoreState is the directory where the repositorys of the state dirs of the components are stored. */ +extern string nixStoreStateRepos; + +/* nixStateDir is the directory where state is stored. */ +extern string nixStateDir; + /* nixDBPath is the path name of our Berkeley DB environment. */ extern string nixDBPath; +/* nixSVNPath is the path name of our SVN environment. */ +extern string nixSVNPath; + /* nixConfDir is the directory where configuration files are stored. */ extern string nixConfDir; @@ -35,7 +44,6 @@ extern string nixLibexecDir; /* nixBinDir is the directory where the main programs are stored. */ extern string nixBinDir; - /* Misc. global flags. */ /* Whether to keep temporary directories of failed builds. */ diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 197b9dda2..b878751a7 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -85,7 +85,7 @@ Path makeStatePath(const string & type, const Hash & hash, const string & suffix string s = type + ":sha256:" + printHash(hash) + ":" + nixStoreState + ":" + suffix; - checkStoreName(suffix); + checkStoreName(suffix); //should this be here? return nixStoreState + "/" + printHash32(compressHash(hashString(htSHA256, s), 20)) diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 8531eb040..e71c81d0e 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -204,6 +204,9 @@ Path makeStorePath(const string & type, Path makeFixedOutputPath(bool recursive, string hashAlgo, Hash hash, string name); +/* Constructs a unique store state path name. */ +Path makeStatePath(const string & type, const Hash & hash, const string & suffix); + /* This is the preparatory part of addToStore() and addToStoreFixed(); it computes the store path to which srcPath is to be copied. diff --git a/src/libutil/Makefile.am b/src/libutil/Makefile.am index bd0996543..c846e21c5 100644 --- a/src/libutil/Makefile.am +++ b/src/libutil/Makefile.am @@ -3,7 +3,7 @@ pkglib_LTLIBRARIES = libutil.la libutil_la_SOURCES = util.cc hash.cc serialise.cc \ archive.cc aterm.cc aterm-map.cc xml-writer.cc -libutil_la_LIBADD = ../boost/format/libformat.la +libutil_la_LIBADD = ../libstore/libstore.la ../boost/format/libformat.la pkginclude_HEADERS = util.hh hash.hh serialise.hh \ archive.hh aterm.hh aterm-map.hh xml-writer.hh types.hh @@ -13,4 +13,7 @@ libutil_la_SOURCES += \ md5.c md5.h sha1.c sha1.h sha256.c sha256.h md32_common.h endif -AM_CXXFLAGS = -Wall -I$(srcdir)/.. ${aterm_include} +AM_CXXFLAGS = -Wall \ + -I$(srcdir)/.. ${aterm_include} -I$(srcdir)/../libstore + + \ No newline at end of file diff --git a/src/libutil/util.cc b/src/libutil/util.cc index bcdc42208..3c1d0731f 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1,5 +1,9 @@ #include "config.h" +#include "util.hh" +#include "globals.hh" +#include "derivations.hh" + #ifdef __CYGWIN__ #include #endif @@ -14,9 +18,6 @@ #include #include -#include "util.hh" -#include "../libstore/derivations.hh" - extern char * * environ; @@ -371,6 +372,10 @@ Path createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De } sort(stateDirsVector.begin(), stateDirsVector.end()); + printMsg(lvlError, format("nixStoreState: `%1%'") % nixStoreState); + printMsg(lvlError, format("nixStoreStateRepos: `%1%'") % nixStoreStateRepos); + printMsg(lvlError, format("nixSVNPath `%1%'") % nixSVNPath); + for (vector::iterator i = stateDirsVector.begin(); i != stateDirsVector.end(); ++i) { DerivationStateOutputDir d = *(i); diff --git a/src/libutil/util.hh b/src/libutil/util.hh index a76823824..00e0e69c0 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -2,7 +2,7 @@ #define __UTIL_H #include "types.hh" -#include "../libstore/derivations.hh" +#include "derivations.hh" #include #include diff --git a/tests/common.sh.in b/tests/common.sh.in index 32759bab0..50316af14 100644 --- a/tests/common.sh.in +++ b/tests/common.sh.in @@ -7,6 +7,7 @@ if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store); then export NIX_IGNORE_SYMLINK_STORE=1 NIX_STORE_DIR=$TEST_ROOT/store fi +export NIX_STORE_STATE_DIR=$TEST_ROOT/state export NIX_DATA_DIR=$TEST_ROOT/data export NIX_LOCALSTATE_DIR=$TEST_ROOT/var export NIX_LOG_DIR=$TEST_ROOT/var/log/nix diff --git a/tests/init.sh b/tests/init.sh index 160cb6b0a..8a47bb081 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -10,6 +10,7 @@ fi mkdir "$TEST_ROOT" mkdir "$NIX_STORE_DIR" +mkdir "$NIX_STORE_STATE_DIR" mkdir "$NIX_DATA_DIR" mkdir "$NIX_LOCALSTATE_DIR" mkdir -p "$NIX_LOG_DIR"/drvs @@ -19,6 +20,7 @@ mkdir "$NIX_CONF_DIR" mkdir $NIX_BIN_DIR ln -s $nixstore $NIX_BIN_DIR/ +ln -s $storestatedir $NIX_BIN_DIR/ ln -s $nixinstantiate $NIX_BIN_DIR/ ln -s $nixhash $NIX_BIN_DIR/ ln -s $nixenv $NIX_BIN_DIR/