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