Commit | Line | Data |
---|---|---|
233e7676 | 1 | # GNU Guix --- Functional package management for GNU |
0fb40579 | 2 | # Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 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 | ||
e25234e3 | 31 | module_dir="t-guix-package-$$" |
0afdc485 | 32 | profile="t-profile-$$" |
db5a9444 LC |
33 | tmpfile="t-guix-package-file-$$" |
34 | rm -f "$profile" "$tmpfile" | |
0afdc485 | 35 | |
db5a9444 | 36 | trap 'rm -f "$profile" "$profile-"[0-9]* "$tmpfile"; rm -rf "$module_dir" t-home-'"$$" EXIT |
7a6548cb | 37 | |
5d4b411f LC |
38 | # Use `-e' with a non-package expression. |
39 | if guix package --bootstrap -e +; | |
40 | then false; else true; fi | |
41 | ||
aa042770 LC |
42 | # Install a store item and make sure the version and output in the manifest |
43 | # are correct. | |
44 | guix package --bootstrap -p "$profile" -i `guix build guile-bootstrap` | |
45 | test "`guix package -A guile-bootstrap | cut -f 1-2`" \ | |
46 | = "`guix package -p "$profile" -I | cut -f 1-2`" | |
47 | test "`guix package -p "$profile" -I | cut -f 3`" = "out" | |
48 | rm "$profile" | |
49 | ||
e49951eb | 50 | guix package --bootstrap -p "$profile" -i guile-bootstrap |
0afdc485 LC |
51 | test -L "$profile" && test -L "$profile-1-link" |
52 | test -f "$profile/bin/guile" | |
53 | ||
d2952326 LC |
54 | # Make sure the profile is a GC root. |
55 | guix gc --list-live | grep "`readlink "$profile-1-link"`" | |
56 | ||
1c67d639 | 57 | # Installing the same package a second time does nothing. |
e49951eb | 58 | guix package --bootstrap -p "$profile" -i guile-bootstrap |
1c67d639 LC |
59 | test -L "$profile" && test -L "$profile-1-link" |
60 | ! test -f "$profile-2-link" | |
61 | test -f "$profile/bin/guile" | |
0afdc485 | 62 | |
fc95dc4c LC |
63 | # Collisions are properly flagged (in this case, 'python-wrapper' propagates |
64 | # python@3, which conflicts with python@2.) | |
65 | if guix package --bootstrap -n -p "$profile" -i python@2 python-wrapper | |
66 | then false; else true; fi | |
67 | ||
68 | guix package --bootstrap -n -p "$profile" -i python@2 python-wrapper \ | |
69 | --allow-collisions | |
70 | ||
5924080d | 71 | # No search path env. var. here. |
dbc31ab2 LC |
72 | guix package -p "$profile" --search-paths |
73 | guix package -p "$profile" --search-paths | grep '^export PATH=' | |
74 | test "`guix package -p "$profile" --search-paths | wc -l`" = 1 # $PATH | |
75 | ( set -e; set -x; \ | |
76 | eval `guix package --search-paths=prefix -p "$PWD/$profile"`; \ | |
77 | test "`type -P guile`" = "$PWD/$profile/bin/guile" ; \ | |
78 | type -P rm ) | |
5924080d | 79 | |
57b86237 LC |
80 | # Exit with 1 when a generation does not exist. |
81 | if guix package -p "$profile" --delete-generations=42; | |
82 | then false; else true; fi | |
83 | ||
84 | # Exit with 0 when trying to delete the zeroth generation. | |
85 | guix package -p "$profile" --delete-generations=0 | |
0afdc485 | 86 | |
6447738c MW |
87 | # Make sure multiple arguments to -i works. |
88 | guix package --bootstrap -i guile gcc -p "$profile" -n | |
89 | ||
9518856b | 90 | # Make sure the `:' syntax works. |
ecb1b610 | 91 | guix package --bootstrap -i "glibc:debug" -p "$profile" -n |
9518856b | 92 | |
aa92cf98 | 93 | # Make sure nonexistent outputs are reported. |
e49951eb MW |
94 | guix package --bootstrap -i "guile-bootstrap:out" -p "$profile" -n |
95 | if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile" -n; | |
aa92cf98 | 96 | then false; else true; fi |
e49951eb | 97 | if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile"; |
aa92cf98 LC |
98 | then false; else true; fi |
99 | ||
64fc89b6 | 100 | # Check whether `--list-available' returns something sensible. |
03f4ef28 | 101 | guix package -p "$profile" -A 'gui.*e' | grep guile |
64fc89b6 | 102 | |
2aa6efb0 | 103 | # Check whether `--show' returns something sensible. |
3ce9aa44 | 104 | guix package --show=guile | grep "^name: guile" |
2aa6efb0 | 105 | |
1b0a86dd | 106 | # Ensure `--show' doesn't fail for packages with non-package inputs. |
5e6feee6 EB |
107 | guix package --show=texlive |
108 | ||
1b0a86dd LC |
109 | # Search. |
110 | LC_MESSAGES=C | |
111 | export LC_MESSAGES | |
112 | test "`guix package -s "An example GNU package" | grep ^name:`" = \ | |
113 | "name: hello" | |
114 | test -z "`guix package -s "n0t4r341p4ck4g3"`" | |
115 | ||
db5a9444 LC |
116 | # Search with one and then two regexps. |
117 | # First we get printed circuit boards *and* board games. | |
118 | guix package -s '\<board\>' > "$tmpfile" | |
119 | grep '^name: pcb' "$tmpfile" | |
120 | grep '^name: gnubg' "$tmpfile" | |
121 | ||
122 | # Second we get only board games. | |
123 | guix package -s '\<board\>' -s game > "$tmpfile" | |
124 | grep -v '^name: pcb' "$tmpfile" > /dev/null | |
125 | grep '^name: gnubg' "$tmpfile" | |
126 | ||
127 | rm -f "$tmpfile" | |
128 | ||
0fb40579 LC |
129 | # Make sure deprecated packages don't show up: <https://bugs.gnu.org/30566>. |
130 | mkdir "$module_dir" | |
131 | cat > "$module_dir/foo.scm"<<EOF | |
132 | (define-module (foo) | |
133 | #:use-module (guix packages) | |
134 | #:use-module (gnu packages base)) | |
135 | ||
136 | (define-public deprecated | |
137 | (deprecated-package "fileutils" coreutils)) | |
138 | EOF | |
139 | ||
140 | guix build -L "$module_dir" -e '(@ (foo) deprecated)' -n | |
141 | test "`guix package -L "$module_dir" -s ^fileutils$ | grep ^name:`" = "" | |
142 | ||
143 | rm -rf "$module_dir" | |
144 | ||
1b0a86dd LC |
145 | # Make sure `--search' can display all the packages. |
146 | guix package --search="" > /dev/null | |
147 | ||
d7ddb257 LC |
148 | # There's no generation older than 12 months, so the following command should |
149 | # have no effect. | |
150 | generation="`readlink_base "$profile"`" | |
151 | if guix package -p "$profile" --delete-generations=12m; | |
152 | then false; else true; fi | |
153 | test "`readlink_base "$profile"`" = "$generation" | |
154 | ||
d26eb84d LC |
155 | # The following command should not delete the current generation, even though |
156 | # it matches the given pattern (see <http://bugs.gnu.org/19978>.) And since | |
157 | # there's nothing else to delete, it should just fail. | |
158 | guix package --list-generations -p "$profile" | |
159 | if guix package --bootstrap -p "$profile" --delete-generations=1.. | |
160 | then false; else true; fi | |
161 | test "`readlink_base "$profile"`" = "$generation" | |
162 | ||
c9323a4c LC |
163 | # Make sure $profile is a GC root at this point. |
164 | real_profile="`readlink -f "$profile"`" | |
165 | if guix gc -d "$real_profile" | |
166 | then false; else true; fi | |
167 | test -d "$real_profile" | |
168 | ||
169 | # Now, let's remove all the symlinks to $real_profile, and make sure | |
170 | # $real_profile is no longer a GC root. | |
171 | rm "$profile" "$profile"-[0-9]-link | |
172 | guix gc -d "$real_profile" | |
173 | [ ! -d "$real_profile" ] | |
174 | ||
494dc2fc LC |
175 | # Package transformations. |
176 | ||
177 | # Make sure we get the right version number when using '--with-source'. | |
178 | mkdir "$module_dir" | |
179 | emacs_tarball="$module_dir/emacs-42.5.9rc7.tar.gz" | |
180 | touch "$emacs_tarball" | |
181 | guix package -p "$profile" -i emacs --with-source="$emacs_tarball" -n \ | |
182 | 2> "$tmpfile" | |
183 | grep -E 'emacs[[:blank:]]+42\.5\.9rc7[[:blank:]]+.*-emacs-42.5.9rc7' \ | |
184 | "$tmpfile" | |
185 | rm "$emacs_tarball" "$tmpfile" | |
186 | rmdir "$module_dir" | |
187 | ||
188 | ||
67668155 | 189 | # |
0ec1af59 | 190 | # Try with the default profile. |
67668155 | 191 | # |
0ec1af59 LC |
192 | |
193 | XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" | |
194 | export XDG_CACHE_HOME | |
88371f0d | 195 | HOME="$PWD/t-home-$$" |
0ec1af59 LC |
196 | export HOME |
197 | ||
198 | mkdir -p "$HOME" | |
199 | ||
59c51be2 LC |
200 | # Get the canonical directory name so that 'guix package' recognizes it. |
201 | HOME="`cd $HOME; pwd -P`" | |
202 | ||
e49951eb | 203 | guix package --bootstrap -i guile-bootstrap |
0ec1af59 LC |
204 | test -L "$HOME/.guix-profile" |
205 | test -f "$HOME/.guix-profile/bin/guile" | |
24e262f0 | 206 | |
d9307267 LC |
207 | # Move to the empty profile. |
208 | default_profile="`readlink "$HOME/.guix-profile"`" | |
209 | for i in `seq 1 3` | |
210 | do | |
d2952326 LC |
211 | # Make sure the current generation is a GC root. |
212 | profile_link="`readlink "$default_profile"`" | |
213 | guix gc --list-live | grep "`readlink "$profile_link"`" | |
214 | ||
e49951eb | 215 | guix package --bootstrap --roll-back |
d9307267 LC |
216 | ! test -f "$HOME/.guix-profile/bin" |
217 | ! test -f "$HOME/.guix-profile/lib" | |
218 | test "`readlink "$default_profile"`" = "$default_profile-0-link" | |
219 | done | |
3b9c0020 | 220 | |
88371f0d LC |
221 | # Check whether '-p ~/.guix-profile' makes any difference. |
222 | # See <http://bugs.gnu.org/17939>. | |
223 | if test -e "$HOME/.guix-profile-0-link"; then false; fi | |
224 | if test -e "$HOME/.guix-profile-1-link"; then false; fi | |
225 | guix package --bootstrap -p "$HOME/.guix-profile" -i guile-bootstrap | |
226 | if test -e "$HOME/.guix-profile-1-link"; then false; fi | |
227 | guix package --bootstrap --roll-back -p "$HOME/.guix-profile" | |
228 | if test -e "$HOME/.guix-profile-0-link"; then false; fi | |
229 | ||
3b9c0020 | 230 | # Extraneous argument. |
e49951eb | 231 | if guix package install foo-bar; |
aa92cf98 | 232 | then false; else true; fi |
1a43e4dc LC |
233 | |
234 | # Make sure the "broken pipe" doesn't yield an error. | |
235 | # Note: 'pipefail' is a Bash-specific option. | |
236 | set -o pipefail || true | |
237 | guix package -A g | head -1 2> "$HOME/err1" | |
238 | guix package -I | head -1 2> "$HOME/err2" | |
239 | test "`cat "$HOME/err1" "$HOME/err2"`" = "" | |
300868ba LC |
240 | |
241 | # Make sure '-L' extends the package module search path. | |
300868ba | 242 | mkdir "$module_dir" |
300868ba LC |
243 | |
244 | cat > "$module_dir/foo.scm"<<EOF | |
245 | (define-module (foo) | |
246 | #:use-module (guix packages) | |
247 | #:use-module (gnu packages emacs)) | |
248 | ||
249 | (define-public x | |
250 | (package (inherit emacs) | |
251 | (name "emacs-foo-bar") | |
252 | (version "42"))) | |
253 | EOF | |
254 | ||
255 | guix package -A emacs-foo-bar -L "$module_dir" | grep 42 | |
1b846da8 | 256 | guix package -i emacs-foo-bar@42 -n -L "$module_dir" |
8689901f LC |
257 | |
258 | # Same thing using the 'GUIX_PACKAGE_PATH' environment variable. | |
259 | GUIX_PACKAGE_PATH="$module_dir" | |
260 | export GUIX_PACKAGE_PATH | |
261 | guix package -A emacs-foo-bar | grep 42 | |
1b846da8 | 262 | guix package -i emacs-foo-bar@42 -n |
ee06af5b LC |
263 | |
264 | # Make sure patches that live under $GUIX_PACKAGE_PATH are found. | |
265 | cat > "$module_dir/emacs.patch"<<EOF | |
266 | This is a fake patch. | |
267 | EOF | |
268 | cat > "$module_dir/foo.scm"<<EOF | |
269 | (define-module (foo) | |
270 | #:use-module (guix packages) | |
271 | #:use-module (gnu packages) | |
272 | #:use-module (gnu packages emacs)) | |
273 | ||
274 | (define-public x | |
275 | (package (inherit emacs) | |
276 | (source (origin (inherit (package-source emacs)) | |
277 | (patches (list (search-patch "emacs.patch"))))) | |
278 | (name "emacs-foo-bar-patched") | |
279 | (version "42"))) | |
5763ad92 LC |
280 | |
281 | (define-public y | |
282 | (package (inherit emacs) | |
283 | (name "super-non-portable-emacs") | |
284 | (supported-systems '("foobar64-hurd")))) | |
ee06af5b LC |
285 | EOF |
286 | guix package -i emacs-foo-bar-patched -n | |
287 | ||
223d7939 LC |
288 | # Same when -L is used. |
289 | ( unset GUIX_PACKAGE_PATH; \ | |
290 | guix package -L "$module_dir" -i emacs-foo-bar-patched -n ) | |
291 | ||
0d279400 DT |
292 | # Make sure installing from a file works. |
293 | cat > "$module_dir/package.scm"<<EOF | |
294 | (use-modules (gnu)) | |
295 | (use-package-modules bootstrap) | |
296 | ||
297 | %bootstrap-guile | |
298 | EOF | |
299 | guix package --bootstrap --install-from-file="$module_dir/package.scm" | |
300 | ||
5763ad92 LC |
301 | # This one should not show up in searches since it's no supported on the |
302 | # current system. | |
303 | test "`guix package -A super-non-portable-emacs`" = "" | |
304 | test "`guix package -s super-non-portable-emacs | grep ^systems:`" = "systems: " | |
305 | ||
fc8fdcf5 LC |
306 | # Don't upgrade packages marked for removal: <http://bugs.gnu.org/27262>. |
307 | guix package --bootstrap -p "$profile" -i guile-bootstrap | |
308 | ||
309 | cat > "$module_dir/foo.scm"<<EOF | |
310 | (define-module (foo) | |
311 | #:use-module (guix) | |
312 | #:use-module (gnu packages bootstrap)) | |
313 | ||
314 | (define-public x | |
315 | (package (inherit %bootstrap-guile) (version "42"))) | |
316 | EOF | |
317 | ||
318 | guix package --bootstrap -p "$profile" -r guile-bootstrap -u guile | |
319 | test ! -f "$profile/bin/guile" | |
320 | guix package --bootstrap -p "$profile" --roll-back | |
321 | test -f "$profile/bin/guile" | |
322 | rm "$profile-2-link" | |
323 | ||
847391fe DP |
324 | unset GUIX_PACKAGE_PATH |
325 | ||
fc8fdcf5 | 326 | |
847391fe | 327 | # Using 'GUIX_BUILD_OPTIONS'. |
847391fe | 328 | available="`guix package -A | sort`" |
442a6ff5 | 329 | GUIX_BUILD_OPTIONS="--dry-run --no-grafts" |
847391fe DP |
330 | export GUIX_BUILD_OPTIONS |
331 | ||
332 | # Make sure $GUIX_BUILD_OPTIONS is not simply appended to the command-line, | |
333 | # which would break 'guix package -A' and similar. | |
334 | available2="`guix package -A | sort`" | |
335 | test "$available2" = "$available" | |
336 | guix package -I | |
1b676447 | 337 | |
442a6ff5 LC |
338 | # Restore '--no-grafts', which makes sure we don't end up building stuff when |
339 | # '--dry-run' is passed. | |
340 | GUIX_BUILD_OPTIONS="--no-grafts" | |
1b676447 | 341 | |
5f1087c4 | 342 | # Applying a manifest file. |
1b676447 DT |
343 | cat > "$module_dir/manifest.scm"<<EOF |
344 | (use-package-modules bootstrap) | |
345 | ||
346 | (packages->manifest (list %bootstrap-guile)) | |
347 | EOF | |
348 | guix package --bootstrap -m "$module_dir/manifest.scm" | |
349 | guix package -I | grep guile | |
350 | test `guix package -I | wc -l` -eq 1 | |
5f1087c4 LC |
351 | |
352 | # Error reporting. | |
353 | cat > "$module_dir/manifest.scm"<<EOF | |
354 | (use-package-modules bootstrap) | |
355 | (packages->manifest | |
356 | (list %bootstrap-guile | |
357 | wonderful-package-that-does-not-exist)) | |
358 | EOF | |
359 | if guix package --bootstrap -n -m "$module_dir/manifest.scm" \ | |
360 | 2> "$module_dir/stderr" | |
361 | then false | |
362 | else | |
363 | cat "$module_dir/stderr" | |
ae0307f7 | 364 | grep "manifest.scm:[1-3]:.*wonderful-package.*: unbound variable" \ |
5f1087c4 LC |
365 | "$module_dir/stderr" |
366 | fi |