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 | |
5d4b411f | 60 | boot_make="(@@ (gnu packages base) 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 | |
acc08466 | 82 | # Search. |
278b6428 LC |
83 | LC_MESSAGES=C |
84 | export LC_MESSAGES | |
6c1cd80d NK |
85 | test "`guix package -s "An example GNU package" | grep ^name:`" = \ |
86 | "name: hello" | |
aad5af9f | 87 | test -z "`guix package -s "n0t4r341p4ck4g3"`" |
acc08466 | 88 | |
2cd09108 NK |
89 | # List generations. |
90 | test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \ | |
91 | = " guile-bootstrap" | |
92 | ||
0ab212b9 NK |
93 | # Exit with 1 when a generation does not exist. |
94 | if guix package -p "$profile" --list-generations=42; | |
95 | then false; else true; fi | |
96 | ||
ad1ebab3 | 97 | # Remove a package. |
e49951eb | 98 | guix package --bootstrap -p "$profile" -r "guile-bootstrap" |
ad1ebab3 LC |
99 | test -L "$profile-3-link" |
100 | test -f "$profile/bin/make" && ! test -f "$profile/bin/guile" | |
24e262f0 LC |
101 | |
102 | # Roll back. | |
e49951eb | 103 | guix package --roll-back -p "$profile" |
24e262f0 LC |
104 | test "`readlink_base "$profile"`" = "$profile-2-link" |
105 | test -x "$profile/bin/guile" && test -x "$profile/bin/make" | |
e49951eb | 106 | guix package --roll-back -p "$profile" |
24e262f0 LC |
107 | test "`readlink_base "$profile"`" = "$profile-1-link" |
108 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
109 | ||
d9307267 LC |
110 | # Move to the empty profile. |
111 | for i in `seq 1 3` | |
112 | do | |
6c1cd80d NK |
113 | guix package --bootstrap --roll-back -p "$profile" |
114 | ! test -f "$profile/bin" | |
115 | ! test -f "$profile/lib" | |
116 | test "`readlink_base "$profile"`" = "$profile-0-link" | |
d9307267 | 117 | done |
24e262f0 | 118 | |
4b2bc804 NK |
119 | # Test that '--list-generations' does not output the zeroth generation. |
120 | test -z "`guix package -p "$profile" -l 0`" | |
121 | ||
82fe08ed | 122 | # Reinstall after roll-back to the empty profile. |
5d4b411f | 123 | guix package --bootstrap -p "$profile" -e "$boot_make" |
82fe08ed LC |
124 | test "`readlink_base "$profile"`" = "$profile-1-link" |
125 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
24e262f0 | 126 | |
9ac9360d NK |
127 | # Check that the first generation is the current one. |
128 | test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)" | |
129 | ||
82fe08ed | 130 | # Roll-back to generation 0, and install---all at once. |
e49951eb | 131 | guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap |
82fe08ed LC |
132 | test "`readlink_base "$profile"`" = "$profile-1-link" |
133 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
134 | ||
135 | # Install Make. | |
5d4b411f | 136 | guix package --bootstrap -p "$profile" -e "$boot_make" |
82fe08ed | 137 | test "`readlink_base "$profile"`" = "$profile-2-link" |
24e262f0 | 138 | test -x "$profile/bin/guile" && test -x "$profile/bin/make" |
741c70c6 | 139 | grep "`guix build -e "$boot_make"`" "$profile/manifest" |
9241172c LC |
140 | |
141 | # Make a "hole" in the list of generations, and make sure we can | |
142 | # roll back "over" it. | |
82fe08ed | 143 | rm "$profile-1-link" |
e49951eb | 144 | guix package --bootstrap -p "$profile" --roll-back |
82fe08ed | 145 | test "`readlink_base "$profile"`" = "$profile-0-link" |
5924080d LC |
146 | |
147 | # Make sure LIBRARY_PATH gets listed by `--search-paths'. | |
148 | guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap | |
149 | guix package --search-paths -p "$profile" | grep LIBRARY_PATH | |
b7884ca3 NK |
150 | |
151 | # Delete the third generation and check that it was actually deleted. | |
152 | guix package -p "$profile" --delete-generations=3 | |
153 | test -z "`guix package -p "$profile" -l 3`" | |
154 | ||
155 | # Exit with 1 when a generation does not exist. | |
156 | if guix package -p "$profile" --delete-generations=42; | |
157 | then false; else true; fi | |
158 | ||
159 | # Exit with 0 when trying to delete the zeroth generation. | |
160 | guix package -p "$profile" --delete-generations=0 | |
ad1ebab3 | 161 | fi |
0afdc485 | 162 | |
6447738c MW |
163 | # Make sure multiple arguments to -i works. |
164 | guix package --bootstrap -i guile gcc -p "$profile" -n | |
165 | ||
9518856b | 166 | # Make sure the `:' syntax works. |
ecb1b610 | 167 | guix package --bootstrap -i "glibc:debug" -p "$profile" -n |
9518856b | 168 | |
aa92cf98 | 169 | # Make sure nonexistent outputs are reported. |
e49951eb MW |
170 | guix package --bootstrap -i "guile-bootstrap:out" -p "$profile" -n |
171 | if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile" -n; | |
aa92cf98 | 172 | then false; else true; fi |
e49951eb | 173 | if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile"; |
aa92cf98 LC |
174 | then false; else true; fi |
175 | ||
64fc89b6 | 176 | # Check whether `--list-available' returns something sensible. |
03f4ef28 | 177 | guix package -p "$profile" -A 'gui.*e' | grep guile |
64fc89b6 | 178 | |
2aa6efb0 CR |
179 | # Check whether `--show' returns something sensible. |
180 | guix package --show=guile | grep "^Package: guile" | |
181 | ||
d7ddb257 LC |
182 | # There's no generation older than 12 months, so the following command should |
183 | # have no effect. | |
184 | generation="`readlink_base "$profile"`" | |
185 | if guix package -p "$profile" --delete-generations=12m; | |
186 | then false; else true; fi | |
187 | test "`readlink_base "$profile"`" = "$generation" | |
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 | |
67668155 LC |
207 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null |
208 | then | |
5d4b411f | 209 | guix package --bootstrap -e "$boot_make" |
67668155 LC |
210 | test -f "$HOME/.guix-profile/bin/make" |
211 | first_environment="`cd $HOME/.guix-profile ; pwd`" | |
212 | ||
e49951eb | 213 | guix package --bootstrap --roll-back |
67668155 LC |
214 | test -f "$HOME/.guix-profile/bin/guile" |
215 | ! test -f "$HOME/.guix-profile/bin/make" | |
216 | test "`cd $HOME/.guix-profile ; pwd`" = "$first_environment" | |
217 | fi | |
218 | ||
d9307267 LC |
219 | # Move to the empty profile. |
220 | default_profile="`readlink "$HOME/.guix-profile"`" | |
221 | for i in `seq 1 3` | |
222 | do | |
d2952326 LC |
223 | # Make sure the current generation is a GC root. |
224 | profile_link="`readlink "$default_profile"`" | |
225 | guix gc --list-live | grep "`readlink "$profile_link"`" | |
226 | ||
e49951eb | 227 | guix package --bootstrap --roll-back |
d9307267 LC |
228 | ! test -f "$HOME/.guix-profile/bin" |
229 | ! test -f "$HOME/.guix-profile/lib" | |
230 | test "`readlink "$default_profile"`" = "$default_profile-0-link" | |
231 | done | |
3b9c0020 | 232 | |
88371f0d LC |
233 | # Check whether '-p ~/.guix-profile' makes any difference. |
234 | # See <http://bugs.gnu.org/17939>. | |
235 | if test -e "$HOME/.guix-profile-0-link"; then false; fi | |
236 | if test -e "$HOME/.guix-profile-1-link"; then false; fi | |
237 | guix package --bootstrap -p "$HOME/.guix-profile" -i guile-bootstrap | |
238 | if test -e "$HOME/.guix-profile-1-link"; then false; fi | |
239 | guix package --bootstrap --roll-back -p "$HOME/.guix-profile" | |
240 | if test -e "$HOME/.guix-profile-0-link"; then false; fi | |
241 | ||
3b9c0020 | 242 | # Extraneous argument. |
e49951eb | 243 | if guix package install foo-bar; |
aa92cf98 | 244 | then false; else true; fi |
1a43e4dc LC |
245 | |
246 | # Make sure the "broken pipe" doesn't yield an error. | |
247 | # Note: 'pipefail' is a Bash-specific option. | |
248 | set -o pipefail || true | |
249 | guix package -A g | head -1 2> "$HOME/err1" | |
250 | guix package -I | head -1 2> "$HOME/err2" | |
251 | test "`cat "$HOME/err1" "$HOME/err2"`" = "" |