1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2021-2022 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 # Rejecting unsupported packages.
39 ! guix shell
-s armhf-linux intelmetool
-n
41 # Ignoring unauthorized files.
42 cat > "$tmpdir/guix.scm" <<EOF
43 This is a broken guix.scm file.
45 ! (cd "$tmpdir"; SHELL
="$(type -P true)" guix shell
--bootstrap 2> "stderr")
46 grep "not authorized" "$tmpdir/stderr"
49 # Authorize the directory.
50 echo "$(realpath "$tmpdir")" > "$configdir/guix/shell-authorized-directories"
52 # Ignoring 'manifest.scm' and 'guix.scm' in non-interactive use.
53 (cd "$tmpdir"; guix shell
--bootstrap -- true
)
54 mv "$tmpdir/guix.scm" "$tmpdir/manifest.scm"
55 (cd "$tmpdir"; guix shell
--bootstrap -- true
)
56 rm "$tmpdir/manifest.scm"
58 # Honoring the local 'manifest.scm' file.
59 cat > "$tmpdir/manifest.scm" <<EOF
60 (specifications->manifest '("guile-bootstrap"))
62 cat > "$tmpdir/fake-shell.sh" <<EOF
64 # This fake shell allows us to test interactive use.
65 exec echo "\$GUIX_ENVIRONMENT"
67 chmod +x
"$tmpdir/fake-shell.sh"
68 profile1
="$(cd "$tmpdir"; SHELL="$
(realpath fake-shell.sh
)" guix shell --bootstrap)"
69 profile2
="$(guix shell --bootstrap guile-bootstrap -- "$SHELL" -c 'echo $GUIX_ENVIRONMENT')"
71 test "$profile1" = "$profile2"
72 rm "$tmpdir/manifest.scm"
74 # Do not read manifest when passed '-q'.
75 echo "Broken manifest." > "$tmpdir/manifest.scm"
76 (cd "$tmpdir"; SHELL
="$(realpath fake-shell.sh)" guix shell
--bootstrap -q)
77 rm "$tmpdir/manifest.scm"
79 # Make sure '-D' affects only the immediately following '-f', and not packages
80 # that appear later: <https://issues.guix.gnu.org/52093>.
81 cat > "$tmpdir/empty-package.scm" <<EOF
82 (use-modules (guix) (guix tests)
83 (guix build-system trivial))
85 (dummy-package "empty-package"
86 (build-system trivial-build-system)) ;zero inputs
89 guix shell
--bootstrap --pure -D -f "$tmpdir/empty-package.scm" \
90 guile-bootstrap
-- guile
--version
91 rm "$tmpdir/empty-package.scm"
93 if guile
-c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev
/null
95 # Compute the build environment for the initial GNU Make.
96 guix shell
--bootstrap --no-substitutes --search-paths --pure \
97 -D -e '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/a"
99 # Make sure bootstrap binaries are in the profile.
100 profile
=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'`
102 # Make sure the bootstrap binaries are all listed where they belong.
103 grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a"
104 grep -E "^export C_INCLUDE_PATH=\"$profile/include\"" "$tmpdir/a"
105 grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a"
106 for dep
in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0
108 guix gc
--references "$profile" |
grep "$dep"
111 # 'make-boot0' itself must not be listed.
112 ! guix gc
--references "$profile" |
grep make-boot0
114 # Honoring the local 'guix.scm' file.
115 echo '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/guix.scm"
116 (cd "$tmpdir"; guix shell
--bootstrap --search-paths --pure > "b")
117 cmp "$tmpdir/a" "$tmpdir/b"
118 rm "$tmpdir/guix.scm"