summaryrefslogtreecommitdiff
path: root/tests/guix-register.sh
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 /tests/guix-register.sh
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 'tests/guix-register.sh')
-rw-r--r--tests/guix-register.sh26
1 files changed, 19 insertions, 7 deletions
diff --git a/tests/guix-register.sh b/tests/guix-register.sh
index b76a1af54f..ca28fb0d95 100644
--- a/tests/guix-register.sh
+++ b/tests/guix-register.sh
@@ -38,9 +38,10 @@ cp -r "$to_copy" "$new_store_dir"
copied="$new_store_dir/`basename $to_copy`"
# Create a file representing a closure with zero references, and with an empty
-# "deriver" field.
+# "deriver" field. Note that we give the file name as it appears in the
+# original store, and 'guix-register' translates it to match the prefix.
cat >> "$closure" <<EOF
-$copied
+$to_copy
0
EOF
@@ -49,26 +50,37 @@ EOF
guix-register -p "$new_store" < "$closure"
# Doing it a second time shouldn't hurt.
-guix-register -p "$new_store" "$closure"
+guix-register --prefix "$new_store" "$closure"
# Now make sure this is recognized as valid.
NIX_IGNORE_SYMLINK_STORE=1
NIX_STORE_DIR="$new_store_dir"
-NIX_LOCALSTATE_DIR="$new_store$localstatedir"
+NIX_STATE_DIR="$new_store$localstatedir"
NIX_LOG_DIR="$new_store$localstatedir/log/nix"
NIX_DB_DIR="$new_store$localstatedir/nix/db"
-export NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR NIX_LOCALSTATE_DIR \
+export NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR NIX_STATE_DIR \
NIX_LOG_DIR NIX_DB_DIR
guix-daemon --disable-chroot &
subdaemon_pid=$!
exit_hook="kill $subdaemon_pid"
+final_name="$storedir/`basename $to_copy`"
+
# At this point the copy in $new_store must be valid, and unreferenced.
+# The database under $new_store uses the $final_name, but we can't use
+# that name in a 'valid-path?' query because 'assertStorePath' would kill
+# us because of the wrong prefix. So we just list dead paths instead.
guile -c "
(use-modules (guix store))
(define s (open-connection))
- (exit (and (valid-path? s \"$copied\")
- (equal? (list \"$copied\") (dead-paths s))))"
+ (exit (equal? (list \"$copied\") (dead-paths s)))"
+
+# When 'sqlite3' is available, check the name in the database.
+if type -P sqlite3
+then
+ echo "select * from ValidPaths where path=\"$final_name\";" | \
+ sqlite3 $NIX_DB_DIR/db.sqlite
+fi