2015-06-30 10:35:27 +00:00
|
|
|
# GNU Guix --- Functional package management for GNU
|
2021-01-18 08:26:02 +00:00
|
|
|
# Copyright © 2015, 2016, 2017, 2018, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
|
2015-06-30 10:35:27 +00:00
|
|
|
#
|
|
|
|
# This file is part of GNU Guix.
|
|
|
|
#
|
|
|
|
# GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
# your option) any later version.
|
|
|
|
#
|
|
|
|
# GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#
|
|
|
|
# Test 'guix environment'.
|
|
|
|
#
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
guix environment --version
|
|
|
|
|
|
|
|
tmpdir="t-guix-environment-$$"
|
2016-12-20 18:06:22 +00:00
|
|
|
gcroot="t-guix-environment-gc-root-$$"
|
|
|
|
trap 'rm -r "$tmpdir"; rm -f "$gcroot"' EXIT
|
2015-06-30 10:35:27 +00:00
|
|
|
|
|
|
|
mkdir "$tmpdir"
|
|
|
|
|
2015-11-02 22:42:31 +00:00
|
|
|
# 'guix environment' launches /bin/sh if 'SHELL' is unset, so export 'SHELL'
|
|
|
|
# since we know it's valid (build environments lack /bin/sh.)
|
|
|
|
export SHELL
|
|
|
|
|
2015-06-30 10:35:27 +00:00
|
|
|
# Check the environment variables for the bootstrap Guile.
|
2016-02-12 20:39:26 +00:00
|
|
|
guix environment --bootstrap --ad-hoc guile-bootstrap --pure \
|
|
|
|
--search-paths > "$tmpdir/a"
|
|
|
|
guix environment --bootstrap --ad-hoc guile-bootstrap:out --pure \
|
|
|
|
--search-paths > "$tmpdir/b"
|
2015-06-30 10:35:27 +00:00
|
|
|
|
|
|
|
# $PATH must appear in the search paths, and nothing else.
|
2016-02-12 20:39:26 +00:00
|
|
|
grep -E '^export PATH=.*profile/bin' "$tmpdir/a"
|
2015-06-30 10:35:27 +00:00
|
|
|
test "`wc -l < "$tmpdir/a"`" = 1
|
|
|
|
|
2016-02-12 20:39:26 +00:00
|
|
|
# Guile must be on $PATH.
|
|
|
|
test -x `sed -r 's/^export PATH="(.*)"/\1/' "$tmpdir/a"`/guile
|
|
|
|
|
2015-06-30 21:16:42 +00:00
|
|
|
cmp "$tmpdir/a" "$tmpdir/b"
|
|
|
|
|
2019-03-04 13:19:55 +00:00
|
|
|
# Check '--preserve'.
|
2019-02-15 07:45:57 +00:00
|
|
|
GUIX_TEST_ABC=1
|
|
|
|
GUIX_TEST_DEF=2
|
|
|
|
GUIX_TEST_XYZ=3
|
|
|
|
export GUIX_TEST_ABC GUIX_TEST_DEF GUIX_TEST_XYZ
|
|
|
|
guix environment --bootstrap --ad-hoc guile-bootstrap --pure \
|
2019-03-04 13:19:55 +00:00
|
|
|
--preserve='^GUIX_TEST_A' --preserve='^GUIX_TEST_D' \
|
2019-02-15 07:45:57 +00:00
|
|
|
-- "$SHELL" -c set > "$tmpdir/a"
|
|
|
|
grep '^PATH=' "$tmpdir/a"
|
|
|
|
grep '^GUIX_TEST_ABC=' "$tmpdir/a"
|
|
|
|
grep '^GUIX_TEST_DEF=' "$tmpdir/a"
|
tests: Simplify shell exit status negation;
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-lint.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh: Use the shell '!' keyword to negate command exit status
in place of 'if ...; then false; else true; fi'
2020-09-25 16:00:11 +00:00
|
|
|
! grep '^GUIX_TEST_XYZ=' "$tmpdir/a"
|
2019-02-15 07:45:57 +00:00
|
|
|
|
2015-07-07 20:51:33 +00:00
|
|
|
# Make sure the exit value is preserved.
|
2016-02-12 20:39:26 +00:00
|
|
|
if guix environment --bootstrap --ad-hoc guile-bootstrap --pure \
|
|
|
|
-- guile -c '(exit 42)'
|
2015-10-09 16:11:24 +00:00
|
|
|
then
|
|
|
|
false
|
|
|
|
else
|
|
|
|
test $? = 42
|
|
|
|
fi
|
|
|
|
|
2016-07-26 15:59:25 +00:00
|
|
|
# Make sure 'GUIX_ENVIRONMENT' points to the profile.
|
|
|
|
guix environment --bootstrap --ad-hoc guile-bootstrap --pure \
|
|
|
|
-- "$SHELL" -c 'test -f "$GUIX_ENVIRONMENT/bin/guile"'
|
|
|
|
|
2018-02-16 01:54:28 +00:00
|
|
|
# Make sure 'GUIX_ENVIRONMENT' points to the profile when building from a
|
|
|
|
# manifest.
|
|
|
|
echo "(use-modules (guix profiles) (gnu packages bootstrap))
|
|
|
|
|
|
|
|
(packages->manifest (list %bootstrap-guile))
|
|
|
|
" > $tmpdir/manifest.scm
|
|
|
|
guix environment --bootstrap --manifest=$tmpdir/manifest.scm --pure \
|
|
|
|
-- "$SHELL" -c 'test -f "$GUIX_ENVIRONMENT/bin/guile"'
|
|
|
|
|
2019-11-20 09:02:01 +00:00
|
|
|
# Make sure '--manifest' can be specified multiple times.
|
|
|
|
cat > "$tmpdir/manifest2.scm" <<EOF
|
|
|
|
(use-modules (guix) (guix profiles)
|
|
|
|
(guix build-system trivial)
|
|
|
|
(gnu packages bootstrap))
|
|
|
|
|
|
|
|
(packages->manifest
|
|
|
|
(list (package
|
|
|
|
(inherit %bootstrap-guile)
|
|
|
|
(name "eliug")
|
|
|
|
(build-system trivial-build-system)
|
|
|
|
(arguments
|
|
|
|
(quasiquote
|
|
|
|
(#:guile ,%bootstrap-guile
|
|
|
|
#:builder
|
|
|
|
(begin
|
|
|
|
(mkdir %output)
|
|
|
|
(mkdir (string-append %output "/eliug")))))))))
|
|
|
|
EOF
|
|
|
|
guix environment --bootstrap -m "$tmpdir/manifest.scm" \
|
|
|
|
-m "$tmpdir/manifest2.scm" --pure \
|
|
|
|
-- "$SHELL" -c 'test -f "$GUIX_ENVIRONMENT/bin/guile" && test -d "$GUIX_ENVIRONMENT/eliug"'
|
|
|
|
|
2016-12-20 18:06:22 +00:00
|
|
|
# Make sure '-r' works as expected.
|
|
|
|
rm -f "$gcroot"
|
|
|
|
expected="`guix environment --bootstrap --ad-hoc guile-bootstrap \
|
|
|
|
-- "$SHELL" -c 'echo $GUIX_ENVIRONMENT'`"
|
|
|
|
guix environment --bootstrap -r "$gcroot" --ad-hoc guile-bootstrap \
|
|
|
|
-- guile -c 1
|
|
|
|
test `readlink "$gcroot"` = "$expected"
|
|
|
|
|
|
|
|
# Make sure '-r' is idempotent.
|
|
|
|
guix environment --bootstrap -r "$gcroot" --ad-hoc guile-bootstrap \
|
|
|
|
-- guile -c 1
|
|
|
|
test `readlink "$gcroot"` = "$expected"
|
2021-10-01 16:49:22 +00:00
|
|
|
|
|
|
|
# Make sure '-p' works as expected.
|
|
|
|
test $(guix environment -p "$gcroot" -- "$SHELL" -c 'echo $GUIX_ENVIRONMENT') = "$expected"
|
|
|
|
paths1="$(guix environment -p "$gcroot" --search-paths)"
|
|
|
|
paths2="$(guix environment --bootstrap --ad-hoc guile-bootstrap --search-paths)"
|
|
|
|
test "$paths1" = "$paths2"
|
|
|
|
|
2017-01-18 15:57:56 +00:00
|
|
|
rm "$gcroot"
|
2016-12-20 18:06:22 +00:00
|
|
|
|
2021-01-18 08:26:02 +00:00
|
|
|
# Try '-r' with a relative file name.
|
|
|
|
(cd "$tmpdir"; mkdir "gc-root";
|
|
|
|
guix environment --bootstrap -r "gc-root/r" --ad-hoc guile-bootstrap \
|
|
|
|
-- guile -c 1;
|
|
|
|
rm "gc-root/r"; rmdir "gc-root")
|
|
|
|
|
2017-01-18 15:57:56 +00:00
|
|
|
# Same with an absolute file name.
|
|
|
|
guix environment --bootstrap -r "$PWD/$gcroot" --ad-hoc guile-bootstrap \
|
|
|
|
-- guile -c 1
|
|
|
|
test `readlink "$gcroot"` = "$expected"
|
2016-12-20 18:06:22 +00:00
|
|
|
|
2016-06-04 22:04:05 +00:00
|
|
|
case "`uname -m`" in
|
|
|
|
x86_64)
|
|
|
|
# On x86_64, we should be able to create a 32-bit environment.
|
|
|
|
guix environment --bootstrap --ad-hoc guile-bootstrap --pure \
|
|
|
|
-- guile -c '(exit (string-prefix? "x86_64" %host-type))'
|
|
|
|
guix environment --bootstrap --ad-hoc guile-bootstrap --pure \
|
|
|
|
-s i686-linux \
|
|
|
|
-- guile -c '(exit (string-prefix? "i686" %host-type))'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "nothing to do" >&2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2017-06-21 14:50:59 +00:00
|
|
|
# Make sure we can build the environment of 'guix'. There may be collisions
|
|
|
|
# in its profile (e.g., for 'gzip'), but we have to accept them.
|
|
|
|
guix environment guix --bootstrap -n
|
|
|
|
|
2018-12-17 21:47:44 +00:00
|
|
|
# Try program transformation options.
|
|
|
|
mkdir "$tmpdir/emacs-36.8"
|
|
|
|
drv="`guix environment --ad-hoc emacs -n 2>&1 | grep 'emacs.*\.drv'`"
|
|
|
|
transformed_drv="`guix environment --ad-hoc emacs --with-source="$tmpdir/emacs-36.8" -n 2>&1 | grep 'emacs.*\.drv'`"
|
|
|
|
test -n "$drv"
|
|
|
|
test "$drv" != "$transformed_drv"
|
|
|
|
case "$transformed_drv" in
|
|
|
|
*-emacs-36.8.drv) true;;
|
|
|
|
*) false;;
|
|
|
|
esac
|
|
|
|
rmdir "$tmpdir/emacs-36.8"
|
|
|
|
|
2019-05-07 12:38:06 +00:00
|
|
|
# Transformation options without '--ad-hoc'.
|
|
|
|
drv="`guix environment -n emacs-geiser 2>&1 | grep '\.drv$'`"
|
|
|
|
transformed_drv="`guix environment -n emacs-geiser \
|
|
|
|
--with-input=emacs-minimal=vim 2>&1 | grep '\.drv$'`"
|
|
|
|
test "$drv" != "$transformed_drv"
|
|
|
|
case "$drv" in
|
|
|
|
*-emacs-minimal*.drv*) true;;
|
|
|
|
*) false;;
|
|
|
|
esac
|
|
|
|
case "$transformed_drv" in
|
|
|
|
*-emacs-minimal*.drv*) false;;
|
|
|
|
*) true;;
|
|
|
|
esac
|
|
|
|
case "$transformed_drv" in
|
|
|
|
*-vim*.drv*) true;;
|
|
|
|
*) false;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
2015-06-30 10:35:27 +00:00
|
|
|
if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
|
|
|
|
then
|
|
|
|
# Compute the build environment for the initial GNU Make.
|
2016-02-12 20:39:26 +00:00
|
|
|
guix environment --bootstrap --no-substitutes --search-paths --pure \
|
2019-06-14 19:26:22 +00:00
|
|
|
-e '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/a"
|
2016-02-12 20:39:26 +00:00
|
|
|
|
|
|
|
# Make sure bootstrap binaries are in the profile.
|
|
|
|
profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'`
|
2015-06-30 10:35:27 +00:00
|
|
|
|
|
|
|
# Make sure the bootstrap binaries are all listed where they belong.
|
2016-02-12 20:39:26 +00:00
|
|
|
grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a"
|
2021-07-10 22:44:10 +00:00
|
|
|
grep -E "^export C_INCLUDE_PATH=\"$profile/include\"" "$tmpdir/a"
|
2016-02-12 20:39:26 +00:00
|
|
|
grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a"
|
|
|
|
for dep in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0
|
|
|
|
do
|
|
|
|
guix gc --references "$profile" | grep "$dep"
|
|
|
|
done
|
2015-06-30 10:35:27 +00:00
|
|
|
|
|
|
|
# 'make-boot0' itself must not be listed.
|
tests: Simplify shell exit status negation;
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-lint.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh: Use the shell '!' keyword to negate command exit status
in place of 'if ...; then false; else true; fi'
2020-09-25 16:00:11 +00:00
|
|
|
! guix gc --references "$profile" | grep make-boot0
|
2015-06-30 10:35:27 +00:00
|
|
|
|
|
|
|
# Make sure that the shell spawned with '--exec' sees the same environment
|
|
|
|
# as returned by '--search-paths'.
|
2016-02-12 20:39:26 +00:00
|
|
|
guix environment --bootstrap --no-substitutes --pure \
|
2019-06-14 19:26:22 +00:00
|
|
|
-e '(@ (guix tests) gnu-make-for-tests)' \
|
2021-07-10 22:44:10 +00:00
|
|
|
-- /bin/sh -c 'echo $PATH $C_INCLUDE_PATH $LIBRARY_PATH' > "$tmpdir/b"
|
|
|
|
( . "$tmpdir/a" ; echo $PATH $C_INCLUDE_PATH $LIBRARY_PATH ) > "$tmpdir/c"
|
2015-06-30 10:35:27 +00:00
|
|
|
cmp "$tmpdir/b" "$tmpdir/c"
|
2015-06-30 21:23:06 +00:00
|
|
|
|
|
|
|
rm "$tmpdir"/*
|
|
|
|
|
|
|
|
# The following test assumes 'make-boot0' has a "debug" output.
|
2019-06-14 19:26:22 +00:00
|
|
|
make_boot0_debug="`guix build -e '(@ (guix tests) gnu-make-for-tests)' | grep -e -debug`"
|
2015-06-30 21:23:06 +00:00
|
|
|
test "x$make_boot0_debug" != "x"
|
|
|
|
|
|
|
|
# Make sure the "debug" output is not listed.
|
tests: Simplify shell exit status negation;
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-lint.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh: Use the shell '!' keyword to negate command exit status
in place of 'if ...; then false; else true; fi'
2020-09-25 16:00:11 +00:00
|
|
|
! guix gc --references "$profile" | grep "$make_boot0_debug"
|
2015-10-26 02:33:33 +00:00
|
|
|
|
|
|
|
# Compute the build environment for the initial GNU Make, but add in the
|
|
|
|
# bootstrap Guile as an ad-hoc addition.
|
2016-02-12 20:39:26 +00:00
|
|
|
guix environment --bootstrap --no-substitutes --search-paths --pure \
|
2019-06-14 19:26:22 +00:00
|
|
|
-e '(@ (guix tests) gnu-make-for-tests)' \
|
2016-02-12 20:39:26 +00:00
|
|
|
--ad-hoc guile-bootstrap > "$tmpdir/a"
|
|
|
|
profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'`
|
2015-10-26 02:33:33 +00:00
|
|
|
|
|
|
|
# Make sure the bootstrap binaries are all listed where they belong.
|
2016-02-12 20:39:26 +00:00
|
|
|
grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a"
|
2021-07-10 22:44:10 +00:00
|
|
|
grep -E "^export C_INCLUDE_PATH=\"$profile/include\"" "$tmpdir/a"
|
2016-02-12 20:39:26 +00:00
|
|
|
grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a"
|
|
|
|
for dep in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0 \
|
|
|
|
guile-bootstrap
|
|
|
|
do
|
|
|
|
guix gc --references "$profile" | grep "$dep"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make sure a package list with plain package objects and package+output
|
|
|
|
# tuples can be used with -e.
|
2015-10-31 01:02:51 +00:00
|
|
|
expr_list_test_code="
|
2019-06-14 19:26:22 +00:00
|
|
|
(list (@ (guix tests) gnu-make-for-tests)
|
2016-02-12 20:39:26 +00:00
|
|
|
(list (@ (gnu packages bootstrap) %bootstrap-guile) \"out\"))"
|
2015-10-31 01:02:51 +00:00
|
|
|
|
2016-02-12 20:39:26 +00:00
|
|
|
guix environment --bootstrap --ad-hoc --no-substitutes --search-paths \
|
|
|
|
--pure -e "$expr_list_test_code" > "$tmpdir/a"
|
|
|
|
profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'`
|
2015-10-31 01:02:51 +00:00
|
|
|
|
2019-06-14 19:26:22 +00:00
|
|
|
for dep in make-test-boot0 guile-bootstrap
|
2016-02-12 20:39:26 +00:00
|
|
|
do
|
|
|
|
guix gc --references "$profile" | grep "$dep"
|
|
|
|
done
|
2015-06-30 10:35:27 +00:00
|
|
|
fi
|