From 0a303ea2c06dc49d70b218c57fda6a077b7c64da Mon Sep 17 00:00:00 2001 From: Wouter den Breejen Date: Fri, 25 May 2007 12:27:36 +0000 Subject: [PATCH] before changing db schema --- configure.ac | 1 + src/libstore/build.cc | 1 - src/libstore/local-store.cc | 11 +++ src/nix-state/Makefile.am | 14 ++++ src/nix-state/help.txt | 58 +++++++++++++++ src/nix-state/help.txt.hh | 1 + src/nix-state/nix-state | 117 ++++++++++++++++++++++++++++++ src/nix-state/nix-state.cc | 122 ++++++++++++++++++++++++++++++++ src/nix-state/statecommitTMP.sh | 78 ++++++++++++++++++++ 9 files changed, 402 insertions(+), 1 deletion(-) create mode 100644 src/nix-state/Makefile.am create mode 100644 src/nix-state/help.txt create mode 100644 src/nix-state/help.txt.hh create mode 100755 src/nix-state/nix-state create mode 100644 src/nix-state/nix-state.cc create mode 100755 src/nix-state/statecommitTMP.sh diff --git a/configure.ac b/configure.ac index 3305aeb9a..bb9741638 100644 --- a/configure.ac +++ b/configure.ac @@ -278,6 +278,7 @@ AC_CONFIG_FILES([Makefile src/libstore/Makefile src/libmain/Makefile src/nix-store/Makefile + src/nix-state/Makefile src/nix-hash/Makefile src/libexpr/Makefile src/nix-instantiate/Makefile diff --git a/src/libstore/build.cc b/src/libstore/build.cc index d511e041b..f9891e5f2 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1377,7 +1377,6 @@ void DerivationGoal::startBuilder() tmpDir = createTempDir(); /* Create the state directory where the component can store it's state files place */ - //printMsg(lvlError, format("STATE: `%1%'") % ); //We only create state dirs when state is enabled and when the dirs need to be created before the installation if(drv.stateOutputs.size() != 0) if(drv.stateOutputs.find("state")->second.getCreateDirsBeforeInstall()) diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index cd83b8350..f5aae39c8 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -72,6 +72,14 @@ static TableId dbSubstitutes = 0; static TableId dbDerivers = 0; +/* dbStateCounters :: StatePath -> Int + + This table lists the state folders that state managed components + and are of type interval. +*/ +static TableId dbStateCounters = 0; + + bool Substitute::operator == (const Substitute & sub) const { return program == sub.program @@ -352,6 +360,9 @@ void queryReferences(const Transaction & txn, const Path & storePath, PathSet & references) { Paths references2; + + //WOUTER EDIT + if (!isRealisablePath(txn, storePath)) throw Error(format("path `%1%' is not valid") % storePath); nixDB.queryStrings(txn, dbReferences, storePath, references2); diff --git a/src/nix-state/Makefile.am b/src/nix-state/Makefile.am new file mode 100644 index 000000000..9be2b1caa --- /dev/null +++ b/src/nix-state/Makefile.am @@ -0,0 +1,14 @@ +bin_PROGRAMS = nix-state + +nix_state_SOURCES = nix-state.cc help.txt +nix_state_LDADD = ../libmain/libmain.la ../libstore/libstore.la ../libutil/libutil.la \ + ../boost/format/libformat.la ${bdb_lib} ${aterm_lib} + +nix-state.o: help.txt.hh + +%.txt.hh: %.txt + ../bin2c/bin2c helpText < $< > $@ || (rm $@ && exit 1) + +AM_CXXFLAGS = \ + -I$(srcdir)/.. ${bdb_include} $(aterm_include) -I$(srcdir)/../libutil \ + -I$(srcdir)/../libstore -I$(srcdir)/../libmain diff --git a/src/nix-state/help.txt b/src/nix-state/help.txt new file mode 100644 index 000000000..1f0691b66 --- /dev/null +++ b/src/nix-state/help.txt @@ -0,0 +1,58 @@ +Usage: nix-state [OPTIONS...] [ARGUMENTS...] + +`nix-store' is a tool to manipulate the Nix store. + +Operations: + + --realise / -r: ensure path validity; if a derivation, ensure that + validity of the outputs + --add / -A: copy a path to the Nix store + --delete: safely delete paths from the Nix store + --query / -q: query information + --read-log / -l: print build log of given store paths + + --register-substitutes: register a substitute expression (dangerous!) + --clear-substitutes: clear all substitutes + --register-validity: register path validity (dangerous!) + --check-validity: check path validity + + --gc: run the garbage collector + + --dump: dump a path as a Nix archive + --restore: restore a path from a Nix archive + + --init: initialise the Nix database + --verify: verify Nix structures + + --version: output version information + --help: display help + +Query flags: + + --outputs: query the output paths of a Nix derivation (default) + --requisites / -R: print all paths necessary to realise a path + --references: print all paths referenced by the given path + --referrers: print all paths directly refering to the given path + --referrers-closure: print all paths (in)directly refering to the given path + --tree: print a tree showing the dependency graph of the given paths + --graph: print a dot graph rooted at given paths + +Query switches (not applicable to all queries): + + --use-output: perform query on output of derivation, not derivation itself + --force-realise: realise the path before performing the query + --include-outputs: in `-R' on a derivation, include requisites of outputs + +Garbage collector options: + + --print-roots: print GC roots and exit + --print-live: print live paths and exit + --print-dead: print dead paths and exit + --delete: delete dead paths (default) + +Options: + + --verbose / -v: verbose operation (may be repeated) + --keep-failed / -K: keep temporary directories of failed builds + + --add-root: add garbage collector roots for the result diff --git a/src/nix-state/help.txt.hh b/src/nix-state/help.txt.hh new file mode 100644 index 000000000..04e3850a5 --- /dev/null +++ b/src/nix-state/help.txt.hh @@ -0,0 +1 @@ +static unsigned char helpText[] = {0x55, 0x73, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x5b, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x20, 0x5b, 0x41, 0x52, 0x47, 0x55, 0x4d, 0x45, 0x4e, 0x54, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x0a, 0x0a, 0x60, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x27, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x20, 0x74, 0x6f, 0x20, 0x6d, 0x61, 0x6e, 0x69, 0x70, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x0a, 0x0a, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x73, 0x65, 0x20, 0x2f, 0x20, 0x2d, 0x72, 0x3a, 0x20, 0x65, 0x6e, 0x73, 0x75, 0x72, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x3b, 0x20, 0x69, 0x66, 0x20, 0x61, 0x20, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x65, 0x6e, 0x73, 0x75, 0x72, 0x65, 0x20, 0x74, 0x68, 0x61, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x61, 0x64, 0x64, 0x20, 0x2f, 0x20, 0x2d, 0x41, 0x3a, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x61, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x3a, 0x20, 0x73, 0x61, 0x66, 0x65, 0x6c, 0x79, 0x20, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x20, 0x2f, 0x20, 0x2d, 0x71, 0x3a, 0x20, 0x71, 0x75, 0x65, 0x72, 0x79, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x61, 0x64, 0x2d, 0x6c, 0x6f, 0x67, 0x20, 0x2f, 0x20, 0x2d, 0x6c, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x20, 0x6c, 0x6f, 0x67, 0x20, 0x6f, 0x66, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x2d, 0x73, 0x75, 0x62, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x65, 0x73, 0x3a, 0x20, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x20, 0x61, 0x20, 0x73, 0x75, 0x62, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x65, 0x20, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x64, 0x61, 0x6e, 0x67, 0x65, 0x72, 0x6f, 0x75, 0x73, 0x21, 0x29, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x2d, 0x73, 0x75, 0x62, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x65, 0x73, 0x3a, 0x20, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x73, 0x75, 0x62, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x65, 0x73, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x2d, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x3a, 0x20, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x20, 0x28, 0x64, 0x61, 0x6e, 0x67, 0x65, 0x72, 0x6f, 0x75, 0x73, 0x21, 0x29, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x2d, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x3a, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x67, 0x63, 0x3a, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x67, 0x61, 0x72, 0x62, 0x61, 0x67, 0x65, 0x20, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x64, 0x75, 0x6d, 0x70, 0x3a, 0x20, 0x64, 0x75, 0x6d, 0x70, 0x20, 0x61, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x61, 0x73, 0x20, 0x61, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3a, 0x20, 0x72, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x61, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x69, 0x6e, 0x69, 0x74, 0x3a, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x73, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x3a, 0x20, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x73, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x68, 0x65, 0x6c, 0x70, 0x3a, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x20, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x3a, 0x20, 0x71, 0x75, 0x65, 0x72, 0x79, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x29, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x71, 0x75, 0x69, 0x73, 0x69, 0x74, 0x65, 0x73, 0x20, 0x2f, 0x20, 0x2d, 0x52, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x20, 0x6e, 0x65, 0x63, 0x65, 0x73, 0x73, 0x61, 0x72, 0x79, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x73, 0x65, 0x20, 0x61, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x73, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6c, 0x79, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x73, 0x2d, 0x63, 0x6c, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x20, 0x28, 0x69, 0x6e, 0x29, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6c, 0x79, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x74, 0x72, 0x65, 0x65, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x61, 0x20, 0x74, 0x72, 0x65, 0x65, 0x20, 0x73, 0x68, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x20, 0x67, 0x72, 0x61, 0x70, 0x68, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x67, 0x72, 0x61, 0x70, 0x68, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x61, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x67, 0x72, 0x61, 0x70, 0x68, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x65, 0x64, 0x20, 0x61, 0x74, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x20, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x65, 0x73, 0x20, 0x28, 0x6e, 0x6f, 0x74, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x29, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x73, 0x65, 0x2d, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x70, 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x71, 0x75, 0x65, 0x72, 0x79, 0x20, 0x6f, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x74, 0x73, 0x65, 0x6c, 0x66, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x2d, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x73, 0x65, 0x3a, 0x20, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x73, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x70, 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71, 0x75, 0x65, 0x72, 0x79, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x2d, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x3a, 0x20, 0x69, 0x6e, 0x20, 0x60, 0x2d, 0x52, 0x27, 0x20, 0x6f, 0x6e, 0x20, 0x61, 0x20, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x72, 0x65, 0x71, 0x75, 0x69, 0x73, 0x69, 0x74, 0x65, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x0a, 0x0a, 0x47, 0x61, 0x72, 0x62, 0x61, 0x67, 0x65, 0x20, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2d, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x47, 0x43, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x65, 0x78, 0x69, 0x74, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2d, 0x6c, 0x69, 0x76, 0x65, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x6c, 0x69, 0x76, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x65, 0x78, 0x69, 0x74, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2d, 0x64, 0x65, 0x61, 0x64, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x64, 0x65, 0x61, 0x64, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x65, 0x78, 0x69, 0x74, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x3a, 0x20, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x20, 0x64, 0x65, 0x61, 0x64, 0x20, 0x70, 0x61, 0x74, 0x68, 0x73, 0x20, 0x28, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x76, 0x65, 0x72, 0x62, 0x6f, 0x73, 0x65, 0x20, 0x2f, 0x20, 0x2d, 0x76, 0x3a, 0x20, 0x76, 0x65, 0x72, 0x62, 0x6f, 0x73, 0x65, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x6d, 0x61, 0x79, 0x20, 0x62, 0x65, 0x20, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x29, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x6b, 0x65, 0x65, 0x70, 0x2d, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x20, 0x2f, 0x20, 0x2d, 0x4b, 0x3a, 0x20, 0x6b, 0x65, 0x65, 0x70, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x72, 0x79, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x61, 0x64, 0x64, 0x2d, 0x72, 0x6f, 0x6f, 0x74, 0x3a, 0x20, 0x61, 0x64, 0x64, 0x20, 0x67, 0x61, 0x72, 0x62, 0x61, 0x67, 0x65, 0x20, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x0a, }; diff --git a/src/nix-state/nix-state b/src/nix-state/nix-state new file mode 100755 index 000000000..3db47ec03 --- /dev/null +++ b/src/nix-state/nix-state @@ -0,0 +1,117 @@ +#! /bin/sh + +# nix-state - temporary wrapper script for .libs/nix-state +# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06) +# +# The nix-state program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/nix/var/nix/profiles/per-user/root/profile/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /root/dev/nix-state/src/nix-state; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/root/bin:/nix/var/nix/profiles/per-user/root/profile/bin:/nix/var/nix/profiles/per-user/root/profile/sbin:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/var/setuid-wrappers:/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin:/home/share/bin:/home/share/bin\"; export PATH; g++ -I./.. -I/root/.nix-profile/include -I/root/.nix-profile/include -I./../libutil -I./../libstore -I./../libmain -D_FILE_OFFSET_BITS=64 -g -O2 -o \$progdir/\$file nix-state.o ../libmain/.libs/libmain.so -L/tmp/nix-14177-0/build/i686-pc-linux-gnu/libstdc++-v3/src -L/tmp/nix-14177-0/build/i686-pc-linux-gnu/libstdc++-v3/src/.libs ../libstore/.libs/libstore.so /root/dev/nix-state/src/libutil/.libs/libutil.so ../libutil/.libs/libutil.so /root/dev/nix-state/src/boost/format/.libs/libformat.so ../boost/format/.libs/libformat.so /nix/store/kpqz9a4clx96538rr0zmsy3v40iqd88g-gcc-4.1.1/lib/libstdc++.so -L/root/.nix-profile/lib -ldb_cxx /nix/store/pkmzbb613wa8cwngx8jjb5jaic8yhyzs-aterm-2.4.2-fixes/lib/libATerm -lpthread -Wl,--rpath -Wl,/root/dev/nix-state/src/libmain/.libs -Wl,--rpath -Wl,/root/dev/nix-state/src/libstore/.libs -Wl,--rpath -Wl,/root/dev/nix-state/src/libutil/.libs -Wl,--rpath -Wl,/root/dev/nix-state/src/boost/format/.libs -Wl,--rpath -Wl,/nix/store/kpqz9a4clx96538rr0zmsy3v40iqd88g-gcc-4.1.1/lib -Wl,--rpath -Wl,/nix/store/pkmzbb613wa8cwngx8jjb5jaic8yhyzs-aterm-2.4.2-fixes/lib -Wl,--rpath -Wl,/nixstate/nix/lib/nix -Wl,--rpath -Wl,/nix/store/kpqz9a4clx96538rr0zmsy3v40iqd88g-gcc-4.1.1/lib -Wl,--rpath -Wl,/nix/store/pkmzbb613wa8cwngx8jjb5jaic8yhyzs-aterm-2.4.2-fixes/lib)" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' ../libmain/libmain.la ../libstore/libstore.la /root/dev/nix-state/src/libutil/libutil.la ../libutil/libutil.la /root/dev/nix-state/src/boost/format/libformat.la ../boost/format/libformat.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/sh "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /nix/var/nix/profiles/per-user/root/profile/bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /nix/var/nix/profiles/per-user/root/profile/bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'nix-state' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /nix/var/nix/profiles/per-user/root/profile/bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $echo "$0: cannot exec $program ${1+"$@"}" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: \`$progdir/$program' does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/src/nix-state/nix-state.cc b/src/nix-state/nix-state.cc new file mode 100644 index 000000000..42e63c165 --- /dev/null +++ b/src/nix-state/nix-state.cc @@ -0,0 +1,122 @@ +#include +#include + +#include "globals.hh" +#include "misc.hh" +#include "archive.hh" +#include "shared.hh" +#include "db.hh" +#include "util.hh" +#include "help.txt.hh" + + +using namespace nix; +using std::cin; +using std::cout; + + +typedef void (* Operation) (Strings opFlags, Strings opArgs); + + +void printHelp() +{ + cout << string((char *) helpText, sizeof helpText); +} + + +static Path gcRoot; +static int rootNr = 0; +static bool indirectRoot = false; + + +//Look up the references of all (runtime) dependencies that maintain have state +void commitReferencesClosure(){ + + Database nixDB; + + try { + nixDB.open(nixDBPath); + } catch (DbNoPermission & e) { + printMsg(lvlTalkative, "cannot access Nix database; continuing anyway"); + //readOnlyMode = true; + return; + } + + Paths referencesKeys; + Transaction txn(nixDB); + TableId dbReferences = nixDB.openTable("references"); + + nixDB.enumTable(txn, dbReferences, referencesKeys); + for (Paths::iterator i = referencesKeys.begin(); i != referencesKeys.end(); ++i) + { + printMsg(lvlError, format("NIX-STATE: `%1%'") % *i); + } + + + + + + + /* + Transaction txn; + createStoreTransaction(txn); + for (DerivationOutputs::iterator i = drv.outputs.begin(); + i != drv.outputs.end(); ++i) + { + registerValidPath(txn, i->second.path, + contentHashes[i->second.path], + allReferences[i->second.path], + drvPath); + } + txn.commit(); + */ +} + + + +//Call the appropiate commit scripts with variables like interval + + + + + +/* Scan the arguments; find the operation, set global flags, put all + other flags in a list, and put all other arguments in another + list. */ +void run(Strings args) +{ + Strings opFlags, opArgs; + Operation op = 0; + + for (Strings::iterator i = args.begin(); i != args.end(); ) { + string arg = *i++; + + Operation oldOp = op; + /* + if (arg == "--realise" || arg == "-r") + op = opRealise; + else if (arg == "--add" || arg == "-A") + op = opAdd; + else if (arg == "--add-fixed") + op = opAddFixed; + else if (arg == "--print-fixed-path") + op = opPrintFixedPath; + else if (arg[0] == '-') + opFlags.push_back(arg); + else + opArgs.push_back(arg); + + if (oldOp && oldOp != op) + throw UsageError("only one operation may be specified"); + */ + } + + commitReferencesClosure(); + + //if (!op) throw UsageError("no operation specified"); + + //op(opFlags, opArgs); +} + + +string programId = "nix-state"; diff --git a/src/nix-state/statecommitTMP.sh b/src/nix-state/statecommitTMP.sh new file mode 100755 index 000000000..a0bffe8be --- /dev/null +++ b/src/nix-state/statecommitTMP.sh @@ -0,0 +1,78 @@ +#! /bin/sh + +#TODO EXCLUDE PATHS AND MAKE PARAMETERS AND STORE OBJECT! + +svnbin=/nix/var/nix/profiles/per-user/root/profile/bin/svn +subversionedpaths=( /nix/state/v6rr3yi5ilgn3k0kwxkk633ap4z0m1zi-hellohardcodedstateworld-1.0/ /nix/state/v6rr3yi5ilgn3k0kwxkk633ap4z0m1zi-hellohardcodedstateworld-1.0/log/ ) +subversionedpathsInterval=( 0 0 ) +nonversionedpaths=( /nix/state/v6rr3yi5ilgn3k0kwxkk633ap4z0m1zi-hellohardcodedstateworld-1.0/cache/ /nix/state/v6rr3yi5ilgn3k0kwxkk633ap4z0m1zi-hellohardcodedstateworld-1.0/log/test/ /nix/state/v6rr3yi5ilgn3k0kwxkk633ap4z0m1zi-hellohardcodedstateworld-1.0/log/test2/test2/ /nix/state/v6rr3yi5ilgn3k0kwxkk633ap4z0m1zi-hellohardcodedstateworld-1.0/logging/ ) +checkouts=( "/nix/var/nix/profiles/per-user/root/profile/bin/svn checkout file:///nix/staterepos/99dj5zg1ginj5as75nkb0psnp02krv2s-hellohardcodedstateworld-1.0 /nix/state/v6rr3yi5ilgn3k0kwxkk633ap4z0m1zi-hellohardcodedstateworld-1.0/" "/nix/var/nix/profiles/per-user/root/profile/bin/svn checkout file:///nix/staterepos/9ph3nd4irpvgs66h24xjvxrwpnrwy9n0-hellohardcodedstateworld-1.0 /nix/state/v6rr3yi5ilgn3k0kwxkk633ap4z0m1zi-hellohardcodedstateworld-1.0/log/" ) + +# if a dir exists, get his rev. number or check it out again (maybe the dir was deleted) + +i=0 +for path in ${subversionedpaths[@]} +do + if test -d $path; then + cd $path; + output=$($svnbin stat 2>&1 | grep "is not a working copy"); + if [ "$output" != "" ] ; then #if dirs exists but is not yet an svn dir: create repos + ${checkouts[$i]}; + fi + + repos=$(svn info | grep "Repository Root" | sed 's/Repository Root: //'); # get the revision number of the repository + revision=$(svn info $repos | grep "Revision: " | sed 's/Revision: //'); + interval=${subversionedpathsInterval[$i]}; + + #TODO BUG !!!!!!!! THE REVISION DOESNT GO UP WE NEED A DB CONNECTION OR A FILE TO HOLD A COUNTER ...! + + if [ "$interval" = "0" ] || [ "$($revision % $interval)" = "0" ]; then # if we dont have an interval or the interval is due... commit + + allsubdirs=( $(echo *) ); + subdirs=(); + for subdir in ${allsubdirs[@]} #add all, exlucding explicity stated direct versioned-subdirs or explicity stated nonversioned-subdirs + do #this is only to prevent some warnings, ultimately we would like svn add to have a option 'exclude dirs' + subdir="$(pwd)/$subdir/"; + exclude=0; + + for svnp in ${subversionedpaths[@]} + do + if [ "$svnp" = "$subdir" ]; then + exclude=1; + fi + done + + for nonvp in ${nonversionedpaths[@]} + do + if [ "$nonvp" = "$subdir" ]; then + exclude=1; + fi + done + + if [ $exclude = 0 ]; then + subdirs[${#subdirs[*]}]=$subdir + fi + done + + if [ "$subdirs" != "" ]; then + svn add $subdirs; + + for revpath in ${nonversionedpaths[@]} #revert sub-sub* dirs that havent been excluded + do + if test -d $revpath; then + if [ "${revpath:0:${#path}}" == "$path" ]; then + #echo "$path revert $revpath"; + svn revert $revpath; + fi + fi + done + svn -m "" commit; + fi + + fi + + cd - &> /dev/null; + fi + let "i+=1" +done +