From bcc3862331125ba67dc96d1924d13e741bf9b07c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 9 Mar 2008 20:30:34 +0000 Subject: [PATCH] * Configure option --disable-old-db-compat to build without Berkeley DB, which is only needed for converting old databases. --- configure.ac | 21 ++++++++++++++++----- externals/Makefile.am | 8 ++++++++ src/libstore/db.cc | 6 ++++++ src/libstore/upgrade-schema.cc | 8 ++++++++ src/nix-env/nix-env.cc | 1 - src/nix-store/dotgraph.cc | 1 - src/nix-store/nix-store.cc | 1 - 7 files changed, 38 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 137f4dbf2..b6dcd16a1 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ if test "$STABLE" != "1"; then fi fi -AC_DEFINE_UNQUOTED(NIX_VERSION, ["$VERSION"], [version]) +AC_DEFINE_UNQUOTED(NIX_VERSION, ["$VERSION"], [Nix version.]) AC_PREFIX_DEFAULT(/nix) @@ -54,7 +54,7 @@ case $sys_name in esac AC_ARG_WITH(system, AC_HELP_STRING([--with-system=SYSTEM], - [platform identifier (e.g., `i686-linux')]), + [Platform identifier (e.g., `i686-linux').]), system=$withval, system="${machine_name}-${sys_name}") AC_MSG_RESULT($system) AC_SUBST(system) @@ -94,7 +94,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include using namespace std; static char buf[1024];]], [[cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));]])], - [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PUBSETBUF, 1, [whether pubsetbuf is available])], + [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PUBSETBUF, 1, [Whether pubsetbuf is available.])], AC_MSG_RESULT(no)) AC_LANG_POP(C++) @@ -176,8 +176,13 @@ AC_ARG_WITH(store-dir, AC_HELP_STRING([--with-store-dir=PATH], storedir=$withval, storedir='${prefix}/store') AC_SUBST(storedir) +AC_ARG_ENABLE(old-db-compat, AC_HELP_STRING([--disable-old-db-compat], + [disable support for converting from old Berkeley DB-based Nix stores]), + old_db_compat=$enableval, old_db_compat=yes) +AM_CONDITIONAL(OLD_DB_COMPAT, test "$old_db_compat" = "yes") + AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb=PATH], - [prefix of Berkeley DB]), + [prefix of Berkeley DB (for Nix <= 0.11 compatibility)]), bdb=$withval, bdb=) AM_CONDITIONAL(HAVE_BDB, test -n "$bdb") if test -z "$bdb"; then @@ -187,6 +192,12 @@ else bdb_lib="-L$bdb/lib -ldb_cxx" bdb_include="-I$bdb/include" fi +if test "$old_db_compat" = "no"; then + bdb_lib= + bdb_include= +else + AC_DEFINE(OLD_DB_COMPAT, 1, [Whether to support converting from old Berkeley DB-based Nix stores.])] +fi AC_SUBST(bdb_lib) AC_SUBST(bdb_include) @@ -215,7 +226,7 @@ if test -n "$openssl"; then LDFLAGS="-L$openssl/lib -lcrypto $LDFLAGS" CFLAGS="-I$openssl/include $CFLAGS" CXXFLAGS="-I$openssl/include $CXXFLAGS" - AC_DEFINE(HAVE_OPENSSL, 1, [whether to use OpenSSL]) + AC_DEFINE(HAVE_OPENSSL, 1, [Whether to use OpenSSL.]) fi AC_ARG_WITH(bzip2, AC_HELP_STRING([--with-bzip2=PATH], diff --git a/externals/Makefile.am b/externals/Makefile.am index 854a65268..981506ebb 100644 --- a/externals/Makefile.am +++ b/externals/Makefile.am @@ -2,6 +2,8 @@ DB = db-4.5.20 +if OLD_DB_COMPAT + $(DB).tar.gz: @echo "Nix requires Berkeley DB to build." @echo "Please download version 4.5.20 from" @@ -32,6 +34,12 @@ build-db: have-db touch build-db endif +else + +build-db: + +endif + # CWI ATerm diff --git a/src/libstore/db.cc b/src/libstore/db.cc index 59b9c0c8e..26e82d695 100644 --- a/src/libstore/db.cc +++ b/src/libstore/db.cc @@ -1,3 +1,7 @@ +#include "config.h" + +#ifdef OLD_DB_COMPAT + #include "db.hh" #include "util.hh" #include "pathlocks.hh" @@ -466,3 +470,5 @@ void Database::clearTable(const Transaction & txn, TableId table) } + +#endif diff --git a/src/libstore/upgrade-schema.cc b/src/libstore/upgrade-schema.cc index 6b8358582..c8a725f51 100644 --- a/src/libstore/upgrade-schema.cc +++ b/src/libstore/upgrade-schema.cc @@ -19,6 +19,8 @@ Hash parseHashField(const Path & path, const string & s); meta-information in files. */ void LocalStore::upgradeStore12() { +#if OLD_DB_COMPAT + if (!lockFile(globalLock, ltWrite, false)) { printMsg(lvlError, "waiting for exclusive access to the Nix store..."); lockFile(globalLock, ltWrite, true); @@ -88,6 +90,12 @@ void LocalStore::upgradeStore12() writeFile(schemaPath, (format("%1%") % nixSchemaVersion).str()); lockFile(globalLock, ltRead, true); + +#else + throw Error( + "Your Nix store has a database in Berkeley DB format. To convert\n" + "to the new format, please compile Nix with Berkeley DB support."); +#endif } diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 1af1a2f53..f561dc2e5 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -13,7 +13,6 @@ #include "common-opts.hh" #include "xml-writer.hh" #include "store-api.hh" -#include "db.hh" #include "util.hh" #include diff --git a/src/nix-store/dotgraph.cc b/src/nix-store/dotgraph.cc index 989945600..83df9e9cd 100644 --- a/src/nix-store/dotgraph.cc +++ b/src/nix-store/dotgraph.cc @@ -1,7 +1,6 @@ #include "dotgraph.hh" #include "util.hh" #include "store-api.hh" -#include "db.hh" #include diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index ff3d5d277..df027fcc7 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -7,7 +7,6 @@ #include "shared.hh" #include "dotgraph.hh" #include "local-store.hh" -#include "db.hh" #include "util.hh" #include "help.txt.hh"