Commit | Line | Data |
---|---|---|
233e7676 | 1 | # GNU Guix --- Functional package management for GNU |
cc57f25d | 2 | # Copyright © 2012, 2013 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 | ||
1c67d639 | 44 | # Installing the same package a second time does nothing. |
e49951eb | 45 | guix package --bootstrap -p "$profile" -i guile-bootstrap |
1c67d639 LC |
46 | test -L "$profile" && test -L "$profile-1-link" |
47 | ! test -f "$profile-2-link" | |
48 | test -f "$profile/bin/guile" | |
0afdc485 | 49 | |
5924080d LC |
50 | # No search path env. var. here. |
51 | guix package --search-paths -p "$profile" | |
52 | test "`guix package --search-paths -p "$profile" | wc -l`" = 0 | |
53 | ||
ad1ebab3 LC |
54 | # Check whether we have network access. |
55 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null | |
56 | then | |
5d4b411f | 57 | boot_make="(@@ (gnu packages base) gnu-make-boot0)" |
81b66f85 | 58 | boot_make_drv="`guix build -e "$boot_make" | grep -v -e -debug`" |
5d4b411f | 59 | guix package --bootstrap -p "$profile" -i "$boot_make_drv" |
ad1ebab3 LC |
60 | test -L "$profile-2-link" |
61 | test -f "$profile/bin/make" && test -f "$profile/bin/guile" | |
0afdc485 | 62 | |
733b4130 | 63 | |
ad1ebab3 LC |
64 | # Check whether `--list-installed' works. |
65 | # XXX: Change the tests when `--install' properly extracts the package | |
66 | # name and version string. | |
e49951eb | 67 | installed="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`" |
ad1ebab3 | 68 | case "x$installed" in |
6c1cd80d NK |
69 | "guile-bootstrap make-boot0") |
70 | true;; | |
71 | "make-boot0 guile-bootstrap") | |
72 | true;; | |
73 | "*") | |
ad1ebab3 LC |
74 | false;; |
75 | esac | |
733b4130 | 76 | |
e49951eb | 77 | test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap" |
733b4130 | 78 | |
acc08466 | 79 | # Search. |
6c1cd80d NK |
80 | test "`guix package -s "An example GNU package" | grep ^name:`" = \ |
81 | "name: hello" | |
e49951eb | 82 | test "`guix package -s "n0t4r341p4ck4g3"`" = "" |
acc08466 | 83 | |
2cd09108 NK |
84 | # List generations. |
85 | test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \ | |
86 | = " guile-bootstrap" | |
87 | ||
ad1ebab3 | 88 | # Remove a package. |
e49951eb | 89 | guix package --bootstrap -p "$profile" -r "guile-bootstrap" |
ad1ebab3 LC |
90 | test -L "$profile-3-link" |
91 | test -f "$profile/bin/make" && ! test -f "$profile/bin/guile" | |
24e262f0 LC |
92 | |
93 | # Roll back. | |
e49951eb | 94 | guix package --roll-back -p "$profile" |
24e262f0 LC |
95 | test "`readlink_base "$profile"`" = "$profile-2-link" |
96 | test -x "$profile/bin/guile" && test -x "$profile/bin/make" | |
e49951eb | 97 | guix package --roll-back -p "$profile" |
24e262f0 LC |
98 | test "`readlink_base "$profile"`" = "$profile-1-link" |
99 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
100 | ||
d9307267 LC |
101 | # Move to the empty profile. |
102 | for i in `seq 1 3` | |
103 | do | |
6c1cd80d NK |
104 | guix package --bootstrap --roll-back -p "$profile" |
105 | ! test -f "$profile/bin" | |
106 | ! test -f "$profile/lib" | |
107 | test "`readlink_base "$profile"`" = "$profile-0-link" | |
d9307267 | 108 | done |
24e262f0 | 109 | |
82fe08ed | 110 | # Reinstall after roll-back to the empty profile. |
5d4b411f | 111 | guix package --bootstrap -p "$profile" -e "$boot_make" |
82fe08ed LC |
112 | test "`readlink_base "$profile"`" = "$profile-1-link" |
113 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
24e262f0 | 114 | |
82fe08ed | 115 | # Roll-back to generation 0, and install---all at once. |
e49951eb | 116 | guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap |
82fe08ed LC |
117 | test "`readlink_base "$profile"`" = "$profile-1-link" |
118 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
119 | ||
120 | # Install Make. | |
5d4b411f | 121 | guix package --bootstrap -p "$profile" -e "$boot_make" |
82fe08ed | 122 | test "`readlink_base "$profile"`" = "$profile-2-link" |
24e262f0 | 123 | test -x "$profile/bin/guile" && test -x "$profile/bin/make" |
741c70c6 | 124 | grep "`guix build -e "$boot_make"`" "$profile/manifest" |
9241172c LC |
125 | |
126 | # Make a "hole" in the list of generations, and make sure we can | |
127 | # roll back "over" it. | |
82fe08ed | 128 | rm "$profile-1-link" |
e49951eb | 129 | guix package --bootstrap -p "$profile" --roll-back |
82fe08ed | 130 | test "`readlink_base "$profile"`" = "$profile-0-link" |
5924080d LC |
131 | |
132 | # Make sure LIBRARY_PATH gets listed by `--search-paths'. | |
133 | guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap | |
134 | guix package --search-paths -p "$profile" | grep LIBRARY_PATH | |
ad1ebab3 | 135 | fi |
0afdc485 | 136 | |
9518856b | 137 | # Make sure the `:' syntax works. |
e49951eb | 138 | guix package --bootstrap -i "binutils:lib" -p "$profile" -n |
9518856b | 139 | |
aa92cf98 | 140 | # Make sure nonexistent outputs are reported. |
e49951eb MW |
141 | guix package --bootstrap -i "guile-bootstrap:out" -p "$profile" -n |
142 | if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile" -n; | |
aa92cf98 | 143 | then false; else true; fi |
e49951eb | 144 | if guix package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile"; |
aa92cf98 LC |
145 | then false; else true; fi |
146 | ||
64fc89b6 | 147 | # Check whether `--list-available' returns something sensible. |
e49951eb | 148 | guix package -A 'gui.*e' | grep guile |
64fc89b6 | 149 | |
67668155 | 150 | # |
0ec1af59 | 151 | # Try with the default profile. |
67668155 | 152 | # |
0ec1af59 LC |
153 | |
154 | XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" | |
155 | export XDG_CACHE_HOME | |
156 | HOME="t-home-$$" | |
157 | export HOME | |
158 | ||
159 | mkdir -p "$HOME" | |
160 | ||
e49951eb | 161 | guix package --bootstrap -i guile-bootstrap |
0ec1af59 LC |
162 | test -L "$HOME/.guix-profile" |
163 | test -f "$HOME/.guix-profile/bin/guile" | |
24e262f0 | 164 | |
67668155 LC |
165 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null |
166 | then | |
5d4b411f | 167 | guix package --bootstrap -e "$boot_make" |
67668155 LC |
168 | test -f "$HOME/.guix-profile/bin/make" |
169 | first_environment="`cd $HOME/.guix-profile ; pwd`" | |
170 | ||
e49951eb | 171 | guix package --bootstrap --roll-back |
67668155 LC |
172 | test -f "$HOME/.guix-profile/bin/guile" |
173 | ! test -f "$HOME/.guix-profile/bin/make" | |
174 | test "`cd $HOME/.guix-profile ; pwd`" = "$first_environment" | |
175 | fi | |
176 | ||
d9307267 LC |
177 | # Move to the empty profile. |
178 | default_profile="`readlink "$HOME/.guix-profile"`" | |
179 | for i in `seq 1 3` | |
180 | do | |
e49951eb | 181 | guix package --bootstrap --roll-back |
d9307267 LC |
182 | ! test -f "$HOME/.guix-profile/bin" |
183 | ! test -f "$HOME/.guix-profile/lib" | |
184 | test "`readlink "$default_profile"`" = "$default_profile-0-link" | |
185 | done | |
3b9c0020 LC |
186 | |
187 | # Extraneous argument. | |
e49951eb | 188 | if guix package install foo-bar; |
aa92cf98 | 189 | then false; else true; fi |