aboutsummaryrefslogtreecommitdiff
path: root/nix/guix-register
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-09-23 21:24:18 +0200
committerLudovic Courtès <ludo@gnu.org>2013-09-23 23:56:35 +0200
commitcaf96debc257dee9ad8b0ea74cc6a8241c30dad4 (patch)
tree746a3a19fdb7b8462eb4e9466d182a11a4cc8136 /nix/guix-register
parenta4141d6d5326925174ef10a7d84ec72f03d6a6cb (diff)
downloadpatches-caf96debc257dee9ad8b0ea74cc6a8241c30dad4.tar
patches-caf96debc257dee9ad8b0ea74cc6a8241c30dad4.tar.gz
guix-register: Expect closures to refer to the original store.
* nix/guix-register/guix-register.cc (prefix): New variable. (parse_opt): Use it. (register_validity): Change 'info.path' to the final store name. Hash the final under its real path. * tests/guix-register.sh: Adjust the contents of $closure accordingly. Rename 'NIX_LOCALSTATE_DIR' to 'NIX_STATE_DIR'. Don't try to call 'valid-path?'. Add test using 'sqlite3'.
Diffstat (limited to 'nix/guix-register')
-rw-r--r--nix/guix-register/guix-register.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/nix/guix-register/guix-register.cc b/nix/guix-register/guix-register.cc
index 0a028f0cfe..8f9c3c86ab 100644
--- a/nix/guix-register/guix-register.cc
+++ b/nix/guix-register/guix-register.cc
@@ -62,6 +62,10 @@ static const struct argp_option options[] =
{ 0, 0, 0, 0, 0 }
};
+
+/* Prefix of the store being populated. */
+static std::string prefix;
+
/* Parse a single option. */
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
@@ -70,8 +74,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
{
case 'p':
{
- string prefix = canonPath (arg);
- settings.nixStore = prefix + NIX_STORE_DIR;
+ prefix = canonPath (arg);
+ settings.nixStore = NIX_STORE_DIR;
settings.nixDataDir = prefix + NIX_DATA_DIR;
settings.nixLogDir = prefix + NIX_LOG_DIR;
settings.nixStateDir = prefix + NIX_STATE_DIR;
@@ -128,15 +132,25 @@ register_validity (LocalStore *store, std::istream &input,
ValidPathInfo info = decodeValidPathInfo (input, hashGiven);
if (info.path == "")
break;
+
+ /* Rewrite the input to refer final name, as if we were in a chroot
+ under PREFIX. */
+ std::string final_prefix (NIX_STORE_DIR "/");
+ info.path = final_prefix + baseNameOf (info.path);
+
+ /* Keep its real path to canonicalize it and compute its hash. */
+ std::string real_path;
+ real_path = prefix + "/" + settings.nixStore + "/" + baseNameOf (info.path);
+
if (!store->isValidPath (info.path) || reregister)
{
/* !!! races */
if (canonicalise)
- canonicalisePathMetaData (info.path, -1);
+ canonicalisePathMetaData (real_path, -1);
if (!hashGiven)
{
- HashResult hash = hashPath (htSHA256, info.path);
+ HashResult hash = hashPath (htSHA256, real_path);
info.hash = hash.first;
info.narSize = hash.second;
}