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