Commit | Line | Data |
---|---|---|
233e7676 | 1 | # GNU Guix --- Functional package management for GNU |
1a43e4dc | 2 | # Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> |
acc08466 | 3 | # Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> |
0afdc485 | 4 | # |
233e7676 | 5 | # This file is part of GNU Guix. |
0afdc485 | 6 | # |
233e7676 | 7 | # GNU Guix is free software; you can redistribute it and/or modify it |
0afdc485 LC |
8 | # under the terms of the GNU General Public License as published by |
9 | # the Free Software Foundation; either version 3 of the License, or (at | |
10 | # your option) any later version. | |
11 | # | |
233e7676 | 12 | # GNU Guix is distributed in the hope that it will be useful, but |
0afdc485 LC |
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
233e7676 | 18 | # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
0afdc485 LC |
19 | |
20 | # | |
e49951eb | 21 | # Test the `guix package' command-line utility. |
0afdc485 LC |
22 | # |
23 | ||
e49951eb | 24 | guix package --version |
0afdc485 | 25 | |
24e262f0 LC |
26 | readlink_base () |
27 | { | |
28 | basename `readlink "$1"` | |
29 | } | |
30 | ||
0afdc485 LC |
31 | profile="t-profile-$$" |
32 | rm -f "$profile" | |
33 | ||
0ec1af59 | 34 | trap 'rm "$profile" "$profile-"[0-9]* ; rm -rf t-home-'"$$" EXIT |
7a6548cb | 35 | |
5d4b411f LC |
36 | # Use `-e' with a non-package expression. |
37 | if guix package --bootstrap -e +; | |
38 | then false; else true; fi | |
39 | ||
e49951eb | 40 | guix package --bootstrap -p "$profile" -i guile-bootstrap |
0afdc485 LC |
41 | test -L "$profile" && test -L "$profile-1-link" |
42 | test -f "$profile/bin/guile" | |
43 | ||
d2952326 LC |
44 | # Make sure the profile is a GC root. |
45 | guix gc --list-live | grep "`readlink "$profile-1-link"`" | |
46 | ||
1c67d639 | 47 | # Installing the same package a second time does nothing. |
e49951eb | 48 | guix package --bootstrap -p "$profile" -i guile-bootstrap |
1c67d639 LC |
49 | test -L "$profile" && test -L "$profile-1-link" |
50 | ! test -f "$profile-2-link" | |
51 | test -f "$profile/bin/guile" | |
0afdc485 | 52 | |
5924080d LC |
53 | # No search path env. var. here. |
54 | guix package --search-paths -p "$profile" | |
55 | test "`guix package --search-paths -p "$profile" | wc -l`" = 0 | |
56 | ||
ad1ebab3 LC |
57 | # Check whether we have network access. |
58 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null | |
59 | then | |
bdb36958 | 60 | boot_make="(@@ (gnu packages commencement) gnu-make-boot0)" |
81b66f85 | 61 | boot_make_drv="`guix build -e "$boot_make" | grep -v -e -debug`" |
5d4b411f | 62 | guix package --bootstrap -p "$profile" -i "$boot_make_drv" |
ad1ebab3 LC |
63 | test -L "$profile-2-link" |
64 | test -f "$profile/bin/make" && test -f "$profile/bin/guile" | |
0afdc485 | 65 | |
733b4130 | 66 | |
ad1ebab3 LC |
67 | # Check whether `--list-installed' works. |
68 | # XXX: Change the tests when `--install' properly extracts the package | |
69 | # name and version string. | |
e49951eb | 70 | installed="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`" |
ad1ebab3 | 71 | case "x$installed" in |
6c1cd80d NK |
72 | "guile-bootstrap make-boot0") |
73 | true;; | |
74 | "make-boot0 guile-bootstrap") | |
75 | true;; | |
76 | "*") | |
ad1ebab3 LC |
77 | false;; |
78 | esac | |
733b4130 | 79 | |
e49951eb | 80 | test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap" |
733b4130 | 81 | |
2cd09108 NK |
82 | # List generations. |
83 | test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \ | |
84 | = " guile-bootstrap" | |
85 | ||
0ab212b9 NK |
86 | # Exit with 1 when a generation does not exist. |
87 | if guix package -p "$profile" --list-generations=42; | |
88 | then false; else true; fi | |
89 | ||
ad1ebab3 | 90 | # Remove a package. |
e49951eb | 91 | guix package --bootstrap -p "$profile" -r "guile-bootstrap" |
ad1ebab3 LC |
92 | test -L "$profile-3-link" |
93 | test -f "$profile/bin/make" && ! test -f "$profile/bin/guile" | |
24e262f0 LC |
94 | |
95 | # Roll back. | |
e49951eb | 96 | guix package --roll-back -p "$profile" |
24e262f0 LC |
97 | test "`readlink_base "$profile"`" = "$profile-2-link" |
98 | test -x "$profile/bin/guile" && test -x "$profile/bin/make" | |
e49951eb | 99 | guix package --roll-back -p "$profile" |
24e262f0 LC |
100 | test "`readlink_base "$profile"`" = "$profile-1-link" |
101 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
102 | ||
d9307267 LC |
103 | # Move to the empty profile. |
104 | for i in `seq 1 3` | |
105 | do | |
6c1cd80d NK |
106 | guix package --bootstrap --roll-back -p "$profile" |
107 | ! test -f "$profile/bin" | |
108 | ! test -f "$profile/lib" | |
109 | test "`readlink_base "$profile"`" = "$profile-0-link" | |
d9307267 | 110 | done |
24e262f0 | 111 | |
4b2bc804 NK |
112 | # Test that '--list-generations' does not output the zeroth generation. |
113 | test -z "`guix package -p "$profile" -l 0`" | |
114 | ||
82fe08ed | 115 | # Reinstall after roll-back to the empty profile. |
5d4b411f | 116 | guix package --bootstrap -p "$profile" -e "$boot_make" |
82fe08ed LC |
117 | test "`readlink_base "$profile"`" = "$profile-1-link" |
118 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
24e262f0 | 119 | |
9ac9360d NK |
120 | # Check that the first generation is the current one. |
121 | test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)" | |
122 | ||
82fe08ed | 123 | # Roll-back to generation 0, and install---all at once. |
e49951eb | 124 | guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap |
82fe08ed LC |
125 | test "`readlink_base "$profile"`" = "$profile-1-link" |
126 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
127 | ||
128 | # Install Make. | |
5d4b411f | 129 | guix package --bootstrap -p "$profile" -e "$boot_make" |
82fe08ed | 130 | test "`readlink_base "$profile"`" = "$profile-2-link" |
24e262f0 | 131 | test -x "$profile/bin/guile" && test -x "$profile/bin/make" |
741c70c6 | 132 | grep "`guix build -e "$boot_make"`" "$profile/manifest" |
9241172c LC |
133 | |
134 | # Make a "hole" in the list of generations, and make sure we can | |
135 | # roll back "over" it. | |
82fe08ed | 136 | rm "$profile-1-link" |
e49951eb | 137 | guix package --bootstrap -p "$profile" --roll-back |
82fe08ed | 138 | test "`readlink_base "$profile"`" = "$profile-0-link" |
5924080d LC |
139 | |
140 | # Make sure LIBRARY_PATH gets listed by `--search-paths'. | |
141 | guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap | |
142 | guix package --search-paths -p "$profile" | grep LIBRARY_PATH | |
b7884ca3 NK |
143 | |
144 | # Delete the third generation and check that it was actually deleted. | |
145 | guix package -p "$profile" --delete-generations=3 | |
146 | test -z "`guix package -p "$profile" -l 3`" | |
147 | ||
148 | # Exit with 1 when a generation does not exist. | |
149 | if guix package -p "$profile" --delete-generations=42; | |
150 | then false; else true; fi | |
151 | ||
152 | # Exit with 0 when trying to delete the zeroth generation. | |
153 | guix package -p "$profile" --delete-generations=0 | |
ad1ebab3 | 154 | fi |
0afdc485 | 155 | |
6447738c MW |
156 | # Make sure multiple arguments to -i works. |
157 | guix package --bootstrap -i guile gcc -p "$profile" -n | |
158 | ||
9518856b | 159 | # Make sure the `:' syntax works. |
ecb1b610 | 160 | guix package --bootstrap -i "glibc:debug" -p "$profile" -n |
9518856b | 161 | |
aa92cf98 | 162 | # Make sure nonexistent outputs are reported. |
e49951eb MW |
163 | guix package --bootstrap -i "guile-bootstrap:out" -p "$profile" -n |
164 | if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile" -n; | |
aa92cf98 | 165 | then false; else true; fi |
e49951eb | 166 | if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile"; |
aa92cf98 LC |
167 | then false; else true; fi |
168 | ||
64fc89b6 | 169 | # Check whether `--list-available' returns something sensible. |
03f4ef28 | 170 | guix package -p "$profile" -A 'gui.*e' | grep guile |
64fc89b6 | 171 | |
2aa6efb0 | 172 | # Check whether `--show' returns something sensible. |
3ce9aa44 | 173 | guix package --show=guile | grep "^name: guile" |
2aa6efb0 | 174 | |
1b0a86dd | 175 | # Ensure `--show' doesn't fail for packages with non-package inputs. |
5e6feee6 EB |
176 | guix package --show=texlive |
177 | ||
1b0a86dd LC |
178 | # Search. |
179 | LC_MESSAGES=C | |
180 | export LC_MESSAGES | |
181 | test "`guix package -s "An example GNU package" | grep ^name:`" = \ | |
182 | "name: hello" | |
183 | test -z "`guix package -s "n0t4r341p4ck4g3"`" | |
184 | ||
185 | # Make sure `--search' can display all the packages. | |
186 | guix package --search="" > /dev/null | |
187 | ||
d7ddb257 LC |
188 | # There's no generation older than 12 months, so the following command should |
189 | # have no effect. | |
190 | generation="`readlink_base "$profile"`" | |
191 | if guix package -p "$profile" --delete-generations=12m; | |
192 | then false; else true; fi | |
193 | test "`readlink_base "$profile"`" = "$generation" | |
194 | ||
67668155 | 195 | # |
0ec1af59 | 196 | # Try with the default profile. |
67668155 | 197 | # |
0ec1af59 LC |
198 | |
199 | XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" | |
200 | export XDG_CACHE_HOME | |
88371f0d | 201 | HOME="$PWD/t-home-$$" |
0ec1af59 LC |
202 | export HOME |
203 | ||
204 | mkdir -p "$HOME" | |
205 | ||
59c51be2 LC |
206 | # Get the canonical directory name so that 'guix package' recognizes it. |
207 | HOME="`cd $HOME; pwd -P`" | |
208 | ||
e49951eb | 209 | guix package --bootstrap -i guile-bootstrap |
0ec1af59 LC |
210 | test -L "$HOME/.guix-profile" |
211 | test -f "$HOME/.guix-profile/bin/guile" | |
24e262f0 | 212 | |
67668155 LC |
213 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null |
214 | then | |
5d4b411f | 215 | guix package --bootstrap -e "$boot_make" |
67668155 LC |
216 | test -f "$HOME/.guix-profile/bin/make" |
217 | first_environment="`cd $HOME/.guix-profile ; pwd`" | |
218 | ||
e49951eb | 219 | guix package --bootstrap --roll-back |
67668155 LC |
220 | test -f "$HOME/.guix-profile/bin/guile" |
221 | ! test -f "$HOME/.guix-profile/bin/make" | |
222 | test "`cd $HOME/.guix-profile ; pwd`" = "$first_environment" | |
223 | fi | |
224 | ||
d9307267 LC |
225 | # Move to the empty profile. |
226 | default_profile="`readlink "$HOME/.guix-profile"`" | |
227 | for i in `seq 1 3` | |
228 | do | |
d2952326 LC |
229 | # Make sure the current generation is a GC root. |
230 | profile_link="`readlink "$default_profile"`" | |
231 | guix gc --list-live | grep "`readlink "$profile_link"`" | |
232 | ||
e49951eb | 233 | guix package --bootstrap --roll-back |
d9307267 LC |
234 | ! test -f "$HOME/.guix-profile/bin" |
235 | ! test -f "$HOME/.guix-profile/lib" | |
236 | test "`readlink "$default_profile"`" = "$default_profile-0-link" | |
237 | done | |
3b9c0020 | 238 | |
88371f0d LC |
239 | # Check whether '-p ~/.guix-profile' makes any difference. |
240 | # See <http://bugs.gnu.org/17939>. | |
241 | if test -e "$HOME/.guix-profile-0-link"; then false; fi | |
242 | if test -e "$HOME/.guix-profile-1-link"; then false; fi | |
243 | guix package --bootstrap -p "$HOME/.guix-profile" -i guile-bootstrap | |
244 | if test -e "$HOME/.guix-profile-1-link"; then false; fi | |
245 | guix package --bootstrap --roll-back -p "$HOME/.guix-profile" | |
246 | if test -e "$HOME/.guix-profile-0-link"; then false; fi | |
247 | ||
3b9c0020 | 248 | # Extraneous argument. |
e49951eb | 249 | if guix package install foo-bar; |
aa92cf98 | 250 | then false; else true; fi |
1a43e4dc LC |
251 | |
252 | # Make sure the "broken pipe" doesn't yield an error. | |
253 | # Note: 'pipefail' is a Bash-specific option. | |
254 | set -o pipefail || true | |
255 | guix package -A g | head -1 2> "$HOME/err1" | |
256 | guix package -I | head -1 2> "$HOME/err2" | |
257 | test "`cat "$HOME/err1" "$HOME/err2"`" = "" | |
300868ba LC |
258 | |
259 | # Make sure '-L' extends the package module search path. | |
260 | module_dir="t-guix-package-$$" | |
261 | mkdir "$module_dir" | |
262 | trap "rm -rf $module_dir" EXIT | |
263 | ||
264 | cat > "$module_dir/foo.scm"<<EOF | |
265 | (define-module (foo) | |
266 | #:use-module (guix packages) | |
267 | #:use-module (gnu packages emacs)) | |
268 | ||
269 | (define-public x | |
270 | (package (inherit emacs) | |
271 | (name "emacs-foo-bar") | |
272 | (version "42"))) | |
273 | EOF | |
274 | ||
275 | guix package -A emacs-foo-bar -L "$module_dir" | grep 42 | |
276 | guix package -i emacs-foo-bar-42 -n -L "$module_dir" | |
8689901f LC |
277 | |
278 | # Same thing using the 'GUIX_PACKAGE_PATH' environment variable. | |
279 | GUIX_PACKAGE_PATH="$module_dir" | |
280 | export GUIX_PACKAGE_PATH | |
281 | guix package -A emacs-foo-bar | grep 42 | |
282 | guix package -i emacs-foo-bar-42 -n |