Commit | Line | Data |
---|---|---|
69cfce50 LC |
1 | #!/bin/sh |
2 | ||
233e7676 | 3 | # GNU Guix --- Functional package management for GNU |
70d1ce9a | 4 | # Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> |
69cfce50 | 5 | # |
233e7676 | 6 | # This file is part of GNU Guix. |
69cfce50 | 7 | # |
233e7676 | 8 | # GNU Guix is free software; you can redistribute it and/or modify it |
69cfce50 LC |
9 | # under the terms of the GNU General Public License as published by |
10 | # the Free Software Foundation; either version 3 of the License, or (at | |
11 | # your option) any later version. | |
12 | # | |
233e7676 | 13 | # GNU Guix is distributed in the hope that it will be useful, but |
69cfce50 LC |
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
233e7676 | 19 | # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
69cfce50 LC |
20 | |
21 | # Usage: ./test-env COMMAND ARG... | |
22 | # | |
23 | # Run the daemon in the build directory, and run COMMAND within | |
24 | # `pre-inst-env'. This is used to run unit tests with the just-built | |
25 | # daemon, unless `--disable-daemon' was passed at configure time. | |
26 | ||
27 | if [ -x "@abs_top_builddir@/guix-daemon" ] | |
28 | then | |
e1b7096a | 29 | NIX_SETUID_HELPER="@abs_top_builddir@/nix-setuid-helper" # normally unused |
69cfce50 | 30 | NIX_STORE_DIR="@GUIX_TEST_ROOT@/store" |
8ad49499 LC |
31 | |
32 | # Do that because store.scm calls `canonicalize-path' on it. | |
33 | mkdir -p "$NIX_STORE_DIR" | |
34 | ||
35 | # Canonicalize the store directory name in an attempt to avoid symlinks in | |
36 | # it or its parent directories. See <http://bugs.gnu.org/17935>. | |
37 | NIX_STORE_DIR="`cd "@GUIX_TEST_ROOT@/store"; pwd -P`" | |
38 | ||
69cfce50 | 39 | NIX_LOCALSTATE_DIR="@GUIX_TEST_ROOT@/var" |
aa2480e5 | 40 | NIX_LOG_DIR="@GUIX_TEST_ROOT@/var/log/guix" |
69cfce50 LC |
41 | NIX_DB_DIR="@GUIX_TEST_ROOT@/db" |
42 | NIX_ROOT_FINDER="@abs_top_builddir@/nix/scripts/list-runtime-roots" | |
8a9451c8 LC |
43 | |
44 | # Choose a PID-dependent name to allow for parallel builds. Note | |
45 | # that the directory name must be chosen so that the socket's file | |
46 | # name is less than 108-char long (the size of `sun_path' in glibc). | |
47 | # Currently, in Nix builds, we're at ~106 chars... | |
f65cf81a | 48 | NIX_STATE_DIR="@GUIX_TEST_ROOT@/var/$$" |
8a9451c8 | 49 | |
526382ff LC |
50 | # The configuration directory, for import/export signing keys. |
51 | NIX_CONF_DIR="@GUIX_TEST_ROOT@/etc" | |
52 | if [ ! -d "$NIX_CONF_DIR" ] | |
53 | then | |
54 | # Copy the keys so that the secret key has the right permissions (the | |
55 | # daemon errors out when this is not the case.) | |
56 | mkdir -p "$NIX_CONF_DIR" | |
57 | cp "@abs_top_srcdir@/tests/signing-key.sec" \ | |
58 | "@abs_top_srcdir@/tests/signing-key.pub" \ | |
59 | "$NIX_CONF_DIR" | |
60 | chmod 400 "$NIX_CONF_DIR/signing-key.sec" | |
61 | fi | |
62 | ||
f65cf81a LC |
63 | # A place to store data of the substituter. |
64 | GUIX_BINARY_SUBSTITUTE_URL="file://$NIX_STATE_DIR/substituter-data" | |
65 | rm -rf "$NIX_STATE_DIR/substituter-data" | |
66 | mkdir -p "$NIX_STATE_DIR/substituter-data" | |
67 | ||
e9c6c584 NK |
68 | # For a number of tests, we want to allow unsigned narinfos, for |
69 | # simplicity. | |
70 | GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES=yes | |
71 | ||
eba783b7 LC |
72 | # Place for the substituter's cache. |
73 | XDG_CACHE_HOME="$NIX_STATE_DIR/cache-$$" | |
74 | ||
f65cf81a | 75 | export NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR \ |
69cfce50 | 76 | NIX_LOCALSTATE_DIR NIX_LOG_DIR NIX_STATE_DIR NIX_DB_DIR \ |
eba783b7 | 77 | NIX_ROOT_FINDER NIX_SETUID_HELPER GUIX_BINARY_SUBSTITUTE_URL \ |
e9c6c584 | 78 | GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES \ |
70d1ce9a | 79 | NIX_CONF_DIR XDG_CACHE_HOME |
69cfce50 | 80 | |
69cfce50 LC |
81 | # Launch the daemon without chroot support because is may be |
82 | # unavailable, for instance if we're not running as root. | |
f65cf81a LC |
83 | "@abs_top_builddir@/pre-inst-env" \ |
84 | "@abs_top_builddir@/guix-daemon" --disable-chroot & | |
69cfce50 LC |
85 | |
86 | daemon_pid=$! | |
87 | trap "kill $daemon_pid ; rm -rf $NIX_STATE_DIR" EXIT | |
88 | fi | |
89 | ||
a7a4e6a4 LC |
90 | storedir="@storedir@" |
91 | prefix="@prefix@" | |
92 | datarootdir="@datarootdir@" | |
93 | datadir="@datadir@" | |
94 | localstatedir="@localstatedir@" | |
95 | export storedir prefix datarootdir datadir localstatedir | |
96 | ||
69cfce50 LC |
97 | "@abs_top_builddir@/pre-inst-env" "$@" |
98 | exit $? |