From 779aa003fbacbbcb6973f289b607d1d285009cec Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 12 Feb 2016 21:39:26 +0100 Subject: scripts: environment: Build environments as profiles. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . * guix/scripts/environment.scm (evaluate-input-search-paths) (build-inputs): Delete. (evaluate-profile-search-paths, strip-input-name) (package-or-package+output?, package-environment-inputs) (build-environment, inputs->profile-derivations): New procedures. (create-environment, show-search-paths, launch-environment) (launch-environment/container): Replace 'inputs' argument with 'profile' argument. (package+propagated-inputs): Strip off names off of input tuples. (options/resolve-packages): Handle input tuples that specify an output in expressions. (guix-environment): Convert inputs into a profile to use in the environment. Remove non-package inputs such as origins from environment inputs. * doc/guix.texi ("invoking guix environment"): Document package+output tuples for --expression option. * tests/guix-environment.sh: Update tests. * tests/guix-environment-container.sh: Likewise. Co-authored-by: Ludovic Courtès --- tests/guix-environment-container.sh | 2 +- tests/guix-environment.sh | 104 ++++++++++++++++++++++-------------- 2 files changed, 66 insertions(+), 40 deletions(-) (limited to 'tests') diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index 703ab31d27..aba34a3bd0 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -73,7 +73,7 @@ guix environment --container --ad-hoc --bootstrap guile-bootstrap \ -- guile -c "$mount_test_code" > $tmpdir/mounts cat "$tmpdir/mounts" -test `wc -l < $tmpdir/mounts` -eq 3 +test `wc -l < $tmpdir/mounts` -eq 4 current_dir="`cd $PWD; pwd -P`" grep -e "$current_dir$" $tmpdir/mounts # current directory diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh index aed27c103c..5ad8dfa82a 100644 --- a/tests/guix-environment.sh +++ b/tests/guix-environment.sh @@ -1,5 +1,5 @@ # GNU Guix --- Functional package management for GNU -# Copyright © 2015 Ludovic Courtès +# Copyright © 2015, 2016 Ludovic Courtès # # This file is part of GNU Guix. # @@ -34,17 +34,23 @@ mkdir "$tmpdir" export SHELL # Check the environment variables for the bootstrap Guile. -guix environment --ad-hoc guile-bootstrap --pure --search-paths > "$tmpdir/a" -guix environment --ad-hoc guile-bootstrap:out --pure --search-paths > "$tmpdir/b" +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" # $PATH must appear in the search paths, and nothing else. -grep -E '^export PATH=.*guile-bootstrap-[0-9.]+/bin' "$tmpdir/a" +grep -E '^export PATH=.*profile/bin' "$tmpdir/a" test "`wc -l < "$tmpdir/a"`" = 1 +# Guile must be on $PATH. +test -x `sed -r 's/^export PATH="(.*)"/\1/' "$tmpdir/a"`/guile + cmp "$tmpdir/a" "$tmpdir/b" # Make sure the exit value is preserved. -if guix environment --ad-hoc guile-bootstrap --pure -- guile -c '(exit 42)' +if guix environment --bootstrap --ad-hoc guile-bootstrap --pure \ + -- guile -c '(exit 42)' then false else @@ -52,7 +58,8 @@ else fi # Same as above, but with deprecated -E flag. -if guix environment --ad-hoc guile-bootstrap --pure -E "guile -c '(exit 42)'" +if guix environment --bootstrap --ad-hoc guile-bootstrap --pure \ + -E "guile -c '(exit 42)'" then false else @@ -62,22 +69,29 @@ fi if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null then # Compute the build environment for the initial GNU Make. - guix environment -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ - --no-substitutes --search-paths --pure > "$tmpdir/a" + guix environment --bootstrap --no-substitutes --search-paths --pure \ + -e '(@@ (gnu packages commencement) gnu-make-boot0)' > "$tmpdir/a" + + # Make sure bootstrap binaries are in the profile. + profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'` # Make sure the bootstrap binaries are all listed where they belong. - grep -E '^export PATH=.*-bootstrap-binaries-0/bin' "$tmpdir/a" - grep -E '^export CPATH=.*-gcc-bootstrap-0/include' "$tmpdir/a" - grep -E '^export CPATH=.*-glibc-bootstrap-0/include' "$tmpdir/a" - grep -E '^export LIBRARY_PATH=.*-glibc-bootstrap-0/lib' "$tmpdir/a" + grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a" + grep -E "^export CPATH=\"$profile/include\"" "$tmpdir/a" + 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 # 'make-boot0' itself must not be listed. - if grep "make-boot0" "$tmpdir/a"; then false; else true; fi + if guix gc --references "$profile" | grep make-boot0 + then false; else true; fi # Make sure that the shell spawned with '--exec' sees the same environment # as returned by '--search-paths'. - guix environment -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ - --no-substitutes --pure \ + guix environment --bootstrap --no-substitutes --pure \ + -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ -- /bin/sh -c 'echo $PATH $CPATH $LIBRARY_PATH' > "$tmpdir/b" ( . "$tmpdir/a" ; echo $PATH $CPATH $LIBRARY_PATH ) > "$tmpdir/c" cmp "$tmpdir/b" "$tmpdir/c" @@ -85,45 +99,57 @@ then rm "$tmpdir"/* # Compute the build environment for the initial GNU Findutils. - guix environment -e '(@@ (gnu packages commencement) findutils-boot0)' \ - --no-substitutes --search-paths --pure > "$tmpdir/a" + guix environment --bootstrap --no-substitutes --search-paths --pure \ + -e '(@@ (gnu packages commencement) findutils-boot0)' > "$tmpdir/a" + profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'` # Make sure the bootstrap binaries are all listed where they belong. - grep -E '^export PATH=.*-bootstrap-binaries-0/bin' "$tmpdir/a" - grep -E '^export PATH=.*-make-boot0-[0-9.]+/bin' "$tmpdir/a" - grep -E '^export CPATH=.*-gcc-bootstrap-0/include' "$tmpdir/a" - grep -E '^export CPATH=.*-glibc-bootstrap-0/include' "$tmpdir/a" - grep -E '^export LIBRARY_PATH=.*-glibc-bootstrap-0/lib' "$tmpdir/a" + grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a" + grep -E "^export CPATH=\"$profile/include\"" "$tmpdir/a" + grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a" + for dep in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0 \ + make-boot0 + do + guix gc --references "$profile" | grep "$dep" + done # The following test assumes 'make-boot0' has a "debug" output. make_boot0_debug="`guix build -e '(@@ (gnu packages commencement) gnu-make-boot0)' | grep -e -debug`" test "x$make_boot0_debug" != "x" # Make sure the "debug" output is not listed. - if grep -E "$make_boot0_debug" "$tmpdir/a"; then false; else true; fi + if guix gc --references "$profile" | grep "$make_boot0_debug" + then false; else true; fi # Compute the build environment for the initial GNU Make, but add in the # bootstrap Guile as an ad-hoc addition. - guix environment -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ - --ad-hoc guile-bootstrap --no-substitutes --search-paths \ - --pure > "$tmpdir/a" + guix environment --bootstrap --no-substitutes --search-paths --pure \ + -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ + --ad-hoc guile-bootstrap > "$tmpdir/a" + profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'` # Make sure the bootstrap binaries are all listed where they belong. - cat $tmpdir/a - grep -E '^export PATH=.*-bootstrap-binaries-0/bin' "$tmpdir/a" - grep -E '^export PATH=.*-guile-bootstrap-2.0/bin' "$tmpdir/a" - grep -E '^export CPATH=.*-gcc-bootstrap-0/include' "$tmpdir/a" - grep -E '^export CPATH=.*-glibc-bootstrap-0/include' "$tmpdir/a" - grep -E '^export LIBRARY_PATH=.*-glibc-bootstrap-0/lib' "$tmpdir/a" - - # Make sure a package list can be used with -e. + grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a" + grep -E "^export CPATH=\"$profile/include\"" "$tmpdir/a" + 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. expr_list_test_code=" (list (@@ (gnu packages commencement) gnu-make-boot0) - (@ (gnu packages bootstrap) %bootstrap-guile))" + (list (@ (gnu packages bootstrap) %bootstrap-guile) \"out\"))" - guix environment --ad-hoc --no-substitutes --search-paths --pure \ - -e "$expr_list_test_code" > "$tmpdir/a" + 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|'` - grep -E '^export PATH=.*-make-boot0-4.1/bin' "$tmpdir/a" - grep -E '^export PATH=.*-guile-bootstrap-2.0/bin' "$tmpdir/a" + for dep in make-boot0 guile-bootstrap + do + guix gc --references "$profile" | grep "$dep" + done fi -- cgit v1.2.3