1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
4 # This file is part of GNU Guix.
6 # GNU Guix is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or (at
9 # your option) any later version.
11 # GNU Guix is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 # Test the 'guix shell' alias.
25 configdir
="t-guix-shell-config-$$"
26 tmpdir
="t-guix-shell-$$"
27 trap 'rm -r "$tmpdir" "$configdir"' EXIT
28 mkdir
"$tmpdir" "$configdir" "$configdir/guix"
30 XDG_CONFIG_HOME
="$(realpath $configdir)"
31 export XDG_CONFIG_HOME
33 guix shell
--bootstrap --pure guile-bootstrap
-- guile
--version
35 # '--ad-hoc' is a thing of the past.
36 ! guix shell
--ad-hoc guile-bootstrap
38 # Ignoring unauthorized files.
39 cat > "$tmpdir/guix.scm" <<EOF
40 This is a broken guix.scm file.
42 ! (cd "$tmpdir"; SHELL
="$(type -P true)" guix shell
--bootstrap 2> "stderr")
43 grep "not authorized" "$tmpdir/stderr"
46 # Authorize the directory.
47 echo "$(realpath "$tmpdir")" > "$configdir/guix/shell-authorized-directories"
49 # Ignoring 'manifest.scm' and 'guix.scm' in non-interactive use.
50 (cd "$tmpdir"; guix shell
--bootstrap -- true
)
51 mv "$tmpdir/guix.scm" "$tmpdir/manifest.scm"
52 (cd "$tmpdir"; guix shell
--bootstrap -- true
)
53 rm "$tmpdir/manifest.scm"
55 # Honoring the local 'manifest.scm' file.
56 cat > "$tmpdir/manifest.scm" <<EOF
57 (specifications->manifest '("guile-bootstrap"))
59 cat > "$tmpdir/fake-shell.sh" <<EOF
61 # This fake shell allows us to test interactive use.
62 exec echo "\$GUIX_ENVIRONMENT"
64 chmod +x
"$tmpdir/fake-shell.sh"
65 profile1
="$(cd "$tmpdir"; SHELL="$
(realpath fake-shell.sh
)" guix shell --bootstrap)"
66 profile2
="$(guix shell --bootstrap guile-bootstrap -- "$SHELL" -c 'echo $GUIX_ENVIRONMENT')"
68 test "$profile1" = "$profile2"
69 rm "$tmpdir/manifest.scm"
71 # Do not read manifest when passed '-q'.
72 echo "Broken manifest." > "$tmpdir/manifest.scm"
73 (cd "$tmpdir"; SHELL
="$(realpath fake-shell.sh)" guix shell
--bootstrap -q)
74 rm "$tmpdir/manifest.scm"
76 if guile
-c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev
/null
78 # Compute the build environment for the initial GNU Make.
79 guix shell
--bootstrap --no-substitutes --search-paths --pure \
80 -D -e '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/a"
82 # Make sure bootstrap binaries are in the profile.
83 profile
=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'`
85 # Make sure the bootstrap binaries are all listed where they belong.
86 grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a"
87 grep -E "^export C_INCLUDE_PATH=\"$profile/include\"" "$tmpdir/a"
88 grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a"
89 for dep
in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0
91 guix gc
--references "$profile" |
grep "$dep"
94 # 'make-boot0' itself must not be listed.
95 ! guix gc
--references "$profile" |
grep make-boot0
97 # Honoring the local 'guix.scm' file.
98 echo '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/guix.scm"
99 (cd "$tmpdir"; guix shell
--bootstrap --search-paths --pure > "b")
100 cmp "$tmpdir/a" "$tmpdir/b"
101 rm "$tmpdir/guix.scm"