Commit | Line | Data |
---|---|---|
cad25264 | 1 | # GNU Guix --- Functional package management for GNU |
779aa003 | 2 | # Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org> |
cad25264 LC |
3 | # |
4 | # This file is part of GNU Guix. | |
5 | # | |
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. | |
10 | # | |
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. | |
15 | # | |
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/>. | |
18 | ||
19 | # | |
20 | # Test 'guix environment'. | |
21 | # | |
22 | ||
23 | set -e | |
24 | ||
25 | guix environment --version | |
26 | ||
27 | tmpdir="t-guix-environment-$$" | |
28 | trap 'rm -r "$tmpdir"' EXIT | |
29 | ||
30 | mkdir "$tmpdir" | |
31 | ||
b485f756 LC |
32 | # 'guix environment' launches /bin/sh if 'SHELL' is unset, so export 'SHELL' |
33 | # since we know it's valid (build environments lack /bin/sh.) | |
34 | export SHELL | |
35 | ||
cad25264 | 36 | # Check the environment variables for the bootstrap Guile. |
779aa003 DT |
37 | guix environment --bootstrap --ad-hoc guile-bootstrap --pure \ |
38 | --search-paths > "$tmpdir/a" | |
39 | guix environment --bootstrap --ad-hoc guile-bootstrap:out --pure \ | |
40 | --search-paths > "$tmpdir/b" | |
cad25264 LC |
41 | |
42 | # $PATH must appear in the search paths, and nothing else. | |
779aa003 | 43 | grep -E '^export PATH=.*profile/bin' "$tmpdir/a" |
cad25264 LC |
44 | test "`wc -l < "$tmpdir/a"`" = 1 |
45 | ||
779aa003 DT |
46 | # Guile must be on $PATH. |
47 | test -x `sed -r 's/^export PATH="(.*)"/\1/' "$tmpdir/a"`/guile | |
48 | ||
417c39f1 LC |
49 | cmp "$tmpdir/a" "$tmpdir/b" |
50 | ||
4931dfcd | 51 | # Make sure the exit value is preserved. |
779aa003 DT |
52 | if guix environment --bootstrap --ad-hoc guile-bootstrap --pure \ |
53 | -- guile -c '(exit 42)' | |
1de2fe95 DT |
54 | then |
55 | false | |
56 | else | |
57 | test $? = 42 | |
58 | fi | |
59 | ||
60 | # Same as above, but with deprecated -E flag. | |
779aa003 DT |
61 | if guix environment --bootstrap --ad-hoc guile-bootstrap --pure \ |
62 | -E "guile -c '(exit 42)'" | |
4931dfcd LC |
63 | then |
64 | false | |
65 | else | |
66 | test $? = 42 | |
67 | fi | |
68 | ||
cad25264 LC |
69 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null |
70 | then | |
71 | # Compute the build environment for the initial GNU Make. | |
779aa003 DT |
72 | guix environment --bootstrap --no-substitutes --search-paths --pure \ |
73 | -e '(@@ (gnu packages commencement) gnu-make-boot0)' > "$tmpdir/a" | |
74 | ||
75 | # Make sure bootstrap binaries are in the profile. | |
76 | profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'` | |
cad25264 LC |
77 | |
78 | # Make sure the bootstrap binaries are all listed where they belong. | |
779aa003 DT |
79 | grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a" |
80 | grep -E "^export CPATH=\"$profile/include\"" "$tmpdir/a" | |
81 | grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a" | |
82 | for dep in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0 | |
83 | do | |
84 | guix gc --references "$profile" | grep "$dep" | |
85 | done | |
cad25264 LC |
86 | |
87 | # 'make-boot0' itself must not be listed. | |
779aa003 DT |
88 | if guix gc --references "$profile" | grep make-boot0 |
89 | then false; else true; fi | |
cad25264 LC |
90 | |
91 | # Make sure that the shell spawned with '--exec' sees the same environment | |
92 | # as returned by '--search-paths'. | |
779aa003 DT |
93 | guix environment --bootstrap --no-substitutes --pure \ |
94 | -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ | |
1de2fe95 | 95 | -- /bin/sh -c 'echo $PATH $CPATH $LIBRARY_PATH' > "$tmpdir/b" |
cad25264 LC |
96 | ( . "$tmpdir/a" ; echo $PATH $CPATH $LIBRARY_PATH ) > "$tmpdir/c" |
97 | cmp "$tmpdir/b" "$tmpdir/c" | |
6b6298ae LC |
98 | |
99 | rm "$tmpdir"/* | |
100 | ||
101 | # Compute the build environment for the initial GNU Findutils. | |
779aa003 DT |
102 | guix environment --bootstrap --no-substitutes --search-paths --pure \ |
103 | -e '(@@ (gnu packages commencement) findutils-boot0)' > "$tmpdir/a" | |
104 | profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'` | |
6b6298ae LC |
105 | |
106 | # Make sure the bootstrap binaries are all listed where they belong. | |
779aa003 DT |
107 | grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a" |
108 | grep -E "^export CPATH=\"$profile/include\"" "$tmpdir/a" | |
109 | grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a" | |
110 | for dep in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0 \ | |
111 | make-boot0 | |
112 | do | |
113 | guix gc --references "$profile" | grep "$dep" | |
114 | done | |
6b6298ae LC |
115 | |
116 | # The following test assumes 'make-boot0' has a "debug" output. | |
117 | make_boot0_debug="`guix build -e '(@@ (gnu packages commencement) gnu-make-boot0)' | grep -e -debug`" | |
118 | test "x$make_boot0_debug" != "x" | |
119 | ||
120 | # Make sure the "debug" output is not listed. | |
779aa003 DT |
121 | if guix gc --references "$profile" | grep "$make_boot0_debug" |
122 | then false; else true; fi | |
cc90fbbf DT |
123 | |
124 | # Compute the build environment for the initial GNU Make, but add in the | |
125 | # bootstrap Guile as an ad-hoc addition. | |
779aa003 DT |
126 | guix environment --bootstrap --no-substitutes --search-paths --pure \ |
127 | -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ | |
128 | --ad-hoc guile-bootstrap > "$tmpdir/a" | |
129 | profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'` | |
cc90fbbf DT |
130 | |
131 | # Make sure the bootstrap binaries are all listed where they belong. | |
779aa003 DT |
132 | grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a" |
133 | grep -E "^export CPATH=\"$profile/include\"" "$tmpdir/a" | |
134 | grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a" | |
135 | for dep in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0 \ | |
136 | guile-bootstrap | |
137 | do | |
138 | guix gc --references "$profile" | grep "$dep" | |
139 | done | |
140 | ||
141 | # Make sure a package list with plain package objects and package+output | |
142 | # tuples can be used with -e. | |
c9c282ce DT |
143 | expr_list_test_code=" |
144 | (list (@@ (gnu packages commencement) gnu-make-boot0) | |
779aa003 | 145 | (list (@ (gnu packages bootstrap) %bootstrap-guile) \"out\"))" |
c9c282ce | 146 | |
779aa003 DT |
147 | guix environment --bootstrap --ad-hoc --no-substitutes --search-paths \ |
148 | --pure -e "$expr_list_test_code" > "$tmpdir/a" | |
149 | profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'` | |
c9c282ce | 150 | |
779aa003 DT |
151 | for dep in make-boot0 guile-bootstrap |
152 | do | |
153 | guix gc --references "$profile" | grep "$dep" | |
154 | done | |
cad25264 | 155 | fi |