aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-07-28 12:28:39 +0200
committerLudovic Courtès <ludo@gnu.org>2020-07-28 14:41:05 +0200
commitc088aa2988ef82289c87ebfd6d07d8f1464dd8f0 (patch)
tree48433d9611da3311e6499b5b2ed72973cd5e65d8 /gnu
parentc6c0d5a22c2ee3d7164dab0129b2e4852a4ae76c (diff)
downloadguix-c088aa2988ef82289c87ebfd6d07d8f1464dd8f0.tar
guix-c088aa2988ef82289c87ebfd6d07d8f1464dd8f0.tar.gz
pack: "fakechroot" engine always creates its store.
Previously it would silently fail to create the /gnu/store symlink when the host has a read-only /gnu as is the case in these tests. * gnu/packages/aux-files/run-in-namespace.c (exec_with_loader): Unlink the ancestor of ORIGINAL_STORE under NEW_ROOT. Check the return value of 'symlink' when creating NEW_STORE. * tests/guix-pack-relocatable.sh: Check the contents of the store as seen by the wrapped executable, with all three engines, and with both "/gnu" and "/gnu/store" erased.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/aux-files/run-in-namespace.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/gnu/packages/aux-files/run-in-namespace.c b/gnu/packages/aux-files/run-in-namespace.c
index 7f7e5c6885..436c0b6286 100644
--- a/gnu/packages/aux-files/run-in-namespace.c
+++ b/gnu/packages/aux-files/run-in-namespace.c
@@ -441,10 +441,23 @@ exec_with_loader (const char *store, int argc, char *argv[])
char *new_root = mkdtemp (strdup ("/tmp/guix-exec-XXXXXX"));
mirror_directory ("/", new_root, make_symlink);
+ /* 'mirror_directory' created a symlink for the ancestor of ORIGINAL_STORE,
+ typically "/gnu". Remove that entry so we can create NEW_STORE
+ below. */
+ const char *slash = strchr (original_store + 1, '/');
+ const char *top = slash != NULL
+ ? strndupa (original_store, slash - original_store)
+ : original_store;
+ char *new_store_top = concat (new_root, top);
+ unlink (new_store_top);
+
+ /* Now create the store under NEW_ROOT. */
char *new_store = concat (new_root, original_store);
char *new_store_parent = dirname (strdup (new_store));
mkdir_p (new_store_parent);
- symlink (store, new_store);
+ err = symlink (store, new_store);
+ if (err < 0)
+ assert_perror (errno);
#ifdef GCONV_DIRECTORY
/* Tell libc where to find its gconv modules. This is necessary because