Commit | Line | Data |
---|---|---|
57b86237 | 1 | # GNU Guix --- Functional package management for GNU |
35225dc5 | 2 | # Copyright © 2012, 2013, 2014, 2015, 2017, 2019 Ludovic Courtès <ludo@gnu.org> |
57b86237 | 3 | # Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> |
881eaae1 | 4 | # Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com> |
57b86237 LC |
5 | # |
6 | # This file is part of GNU Guix. | |
7 | # | |
8 | # GNU Guix is free software; you can redistribute it and/or modify it | |
9 | # under the terms of the GNU General Public License as published by | |
10 | # the Free Software Foundation; either version 3 of the License, or (at | |
11 | # your option) any later version. | |
12 | # | |
13 | # GNU Guix is distributed in the hope that it will be useful, but | |
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
20 | ||
21 | # | |
22 | # Test the `guix package' command-line utility. This test requires network | |
23 | # access and is skipped when that is lacking. | |
24 | # | |
25 | ||
26 | guix package --version | |
27 | ||
28 | readlink_base () | |
29 | { | |
30 | basename `readlink "$1"` | |
31 | } | |
32 | ||
33 | # Return true if a typical shebang in the store would exceed Linux's default | |
34 | # static limit. | |
35 | shebang_too_long () | |
36 | { | |
37 | test `echo $NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash | wc -c` \ | |
38 | -ge 128 | |
39 | } | |
40 | ||
0b131612 LC |
41 | if ! guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null \ |
42 | || shebang_too_long | |
43 | then | |
44 | # Skipping. | |
45 | exit 77 | |
46 | fi | |
47 | ||
48 | ||
57b86237 | 49 | profile="t-profile-$$" |
fc2d2339 | 50 | profile_alt="t-profile-alt-$$" |
57b86237 LC |
51 | rm -f "$profile" |
52 | ||
0c152cd6 | 53 | trap 'rm -f "$profile" "$profile_alt" "$profile-"[0-9]* "$profile_alt-"[0-9]* ; rm -rf t-home-'"$$" EXIT |
57b86237 LC |
54 | |
55 | ||
56 | guix package --bootstrap -p "$profile" -i guile-bootstrap | |
57 | test -L "$profile" && test -L "$profile-1-link" | |
58 | ! test -f "$profile-2-link" | |
59 | test -f "$profile/bin/guile" | |
60 | ||
03d76577 | 61 | boot_make="(@ (guix tests) gnu-make-for-tests)" |
57b86237 LC |
62 | boot_make_drv="`guix build -e "$boot_make" | grep -v -e -debug`" |
63 | guix package --bootstrap -p "$profile" -i "$boot_make_drv" | |
64 | test -L "$profile-2-link" | |
65 | test -f "$profile/bin/make" && test -f "$profile/bin/guile" | |
66 | ||
67 | # Check whether `--list-installed' works. | |
68 | # XXX: Change the tests when `--install' properly extracts the package | |
69 | # name and version string. | |
70 | installed="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`" | |
71 | case "x$installed" in | |
72 | "guile-bootstrap make-boot0") | |
73 | true;; | |
74 | "make-boot0 guile-bootstrap") | |
75 | true;; | |
76 | "*") | |
77 | false;; | |
78 | esac | |
79 | ||
80 | test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap" | |
81 | ||
881eaae1 | 82 | guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap |
83 | installed="`guix package -p "$profile" -p "$profile_alt" -I | cut -f1 | xargs echo | sort`" | |
84 | case "x$installed" in | |
85 | "gcc-bootstrap guile-bootstrap make-boot0") | |
86 | true;; | |
87 | "*") | |
88 | false;; | |
89 | esac | |
90 | test "`guix package -p "$profile_alt" -p "$profile" -I | wc -l`" = "3" | |
91 | rm "$profile_alt" | |
92 | ||
57b86237 LC |
93 | # List generations. |
94 | test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \ | |
95 | = " guile-bootstrap" | |
96 | ||
97 | # Exit with 1 when a generation does not exist. | |
d8934360 EB |
98 | ! guix package -p "$profile" --list-generations=42 |
99 | ! guix package -p "$profile" --switch-generation=99 | |
57b86237 LC |
100 | |
101 | # Remove a package. | |
102 | guix package --bootstrap -p "$profile" -r "guile-bootstrap" | |
103 | test -L "$profile-3-link" | |
104 | test -f "$profile/bin/make" && ! test -f "$profile/bin/guile" | |
105 | ||
106 | # Roll back. | |
107 | guix package --roll-back -p "$profile" | |
108 | test "`readlink_base "$profile"`" = "$profile-2-link" | |
109 | test -x "$profile/bin/guile" && test -x "$profile/bin/make" | |
110 | guix package --roll-back -p "$profile" | |
111 | test "`readlink_base "$profile"`" = "$profile-1-link" | |
112 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
113 | ||
114 | # Switch to the rolled generation and switch back. | |
115 | guix package -p "$profile" --switch-generation=2 | |
116 | test "`readlink_base "$profile"`" = "$profile-2-link" | |
117 | guix package -p "$profile" --switch-generation=-1 | |
118 | test "`readlink_base "$profile"`" = "$profile-1-link" | |
119 | ||
120 | # Move to the empty profile. | |
121 | for i in `seq 1 3` | |
122 | do | |
123 | guix package --bootstrap --roll-back -p "$profile" | |
124 | ! test -f "$profile/bin" | |
125 | ! test -f "$profile/lib" | |
126 | test "`readlink_base "$profile"`" = "$profile-0-link" | |
127 | done | |
128 | ||
129 | # Test that '--list-generations' does not output the zeroth generation. | |
130 | test -z "`guix package -p "$profile" -l 0`" | |
131 | ||
132 | # Reinstall after roll-back to the empty profile. | |
133 | guix package --bootstrap -p "$profile" -e "$boot_make" | |
134 | test "`readlink_base "$profile"`" = "$profile-1-link" | |
135 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
136 | ||
137 | # Check that the first generation is the current one. | |
138 | test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)" | |
139 | ||
140 | # Roll-back to generation 0, and install---all at once. | |
141 | guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap | |
142 | test "`readlink_base "$profile"`" = "$profile-1-link" | |
143 | test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" | |
144 | ||
145 | # Install Make. | |
146 | guix package --bootstrap -p "$profile" -e "$boot_make" | |
147 | test "`readlink_base "$profile"`" = "$profile-2-link" | |
148 | test -x "$profile/bin/guile" && test -x "$profile/bin/make" | |
149 | grep "`guix build -e "$boot_make"`" "$profile/manifest" | |
150 | ||
151 | # Make a "hole" in the list of generations, and make sure we can | |
152 | # roll back and switch "over" it. | |
153 | rm "$profile-1-link" | |
154 | guix package --bootstrap -p "$profile" --roll-back | |
155 | test "`readlink_base "$profile"`" = "$profile-0-link" | |
156 | guix package -p "$profile" --switch-generation=+1 | |
157 | test "`readlink_base "$profile"`" = "$profile-2-link" | |
158 | ||
159 | # Make sure LIBRARY_PATH gets listed by `--search-paths'. | |
160 | guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap | |
dbc31ab2 | 161 | guix package -p "$profile" --search-paths | grep LIBRARY_PATH |
57b86237 LC |
162 | |
163 | # Roll back so we can delete #3 below. | |
164 | guix package -p "$profile" --switch-generation=2 | |
165 | ||
166 | # Delete the third generation and check that it was actually deleted. | |
167 | guix package -p "$profile" --delete-generations=3 | |
168 | test -z "`guix package -p "$profile" -l 3`" | |
169 | ||
fc2d2339 LC |
170 | # Search path of combined profiles. 'LIBRARY_PATH' should show up only in the |
171 | # combination, not in the individual profiles. | |
172 | rm "$profile" | |
173 | guix package --bootstrap -p "$profile" -i guile-bootstrap | |
174 | guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap | |
d8934360 | 175 | ! guix package -p "$profile" --search-paths | grep LIBRARY_PATH |
fc2d2339 | 176 | guix package -p "$profile" -p "$profile_alt" --search-paths \ |
c5746f23 | 177 | | grep "LIBRARY_PATH.*$profile/lib.$profile_alt/lib" |
57b86237 | 178 | |
35225dc5 LC |
179 | # Simulate an upgrade and make sure the package order is preserved. |
180 | module_dir="t-guix-package-net-$$" | |
181 | trap 'rm -rf "$module_dir"' EXIT | |
182 | ||
183 | mkdir "$module_dir" | |
184 | cat > "$module_dir/new.scm" <<EOF | |
185 | (define-module (new) | |
186 | #:use-module (guix) | |
187 | #:use-module (gnu packages bootstrap)) | |
188 | ||
189 | (define-public new-guile | |
190 | (package (inherit %bootstrap-guile) | |
191 | (version (string-append "42." (getenv "V_MINOR"))))) | |
192 | (define-public new-gcc | |
193 | (package (inherit %bootstrap-gcc) | |
194 | (version (string-append "77." (getenv "V_MINOR"))))) | |
195 | EOF | |
196 | ||
197 | guix package --bootstrap -p "$profile" -i gcc-bootstrap | |
198 | installed="`guix package -p "$profile" -I | cut -f1`" | |
199 | ||
200 | for i in 1 2 | |
201 | do | |
202 | V_MINOR="$i" | |
203 | export V_MINOR | |
204 | ||
205 | guix package -p "$profile" --bootstrap -L "$module_dir" -u . | |
206 | post_upgrade="`guix package -p "$profile" -I | cut -f1`" | |
207 | test "$post_upgrade" = "$installed" | |
208 | done | |
209 | ||
57b86237 LC |
210 | # |
211 | # Try with the default profile. | |
212 | # | |
213 | ||
214 | XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" | |
215 | export XDG_CACHE_HOME | |
216 | HOME="$PWD/t-home-$$" | |
217 | export HOME | |
218 | ||
219 | mkdir -p "$HOME" | |
220 | ||
221 | # Get the canonical directory name so that 'guix package' recognizes it. | |
222 | HOME="`cd $HOME; pwd -P`" | |
223 | ||
224 | guix package --bootstrap -e "$boot_make" | |
225 | test -f "$HOME/.guix-profile/bin/make" | |
226 | ||
227 | guix package --bootstrap --roll-back | |
228 | ! test -f "$HOME/.guix-profile/bin/make" |