1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2012, 2013, 2014, 2015, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
3 # Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
4 # Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
6 # This file is part of GNU Guix.
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.
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.
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/>.
22 # Test the `guix package' command-line utility. This test requires network
23 # access and is skipped when that is lacking.
26 guix package
--version
30 basename `readlink "$1"`
33 # Return true if a typical shebang in the store would exceed Linux's default
37 test `echo $NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash | wc -c` \
41 if ! guile
-c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev
/null \
49 profile
="t-profile-$$"
50 profile_alt
="t-profile-alt-$$"
53 trap 'rm -f "$profile" "$profile_alt" "$profile-"[0-9]* "$profile_alt-"[0-9]* ; rm -rf t-home-'"$$" EXIT
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"
61 boot_make
="(@ (guix tests) gnu-make-for-tests)"
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"
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`"
72 "guile-bootstrap make-boot0")
74 "make-boot0 guile-bootstrap")
80 test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
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`"
85 "gcc-bootstrap guile-bootstrap make-boot0")
90 test "`guix package -p "$profile_alt" -p "$profile" -I | wc -l`" = "3"
94 test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
97 # Exit with 1 when a generation does not exist.
98 ! guix package
-p "$profile" --list-generations=42
99 ! guix package
-p "$profile" --switch-generation=99
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"
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"
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"
120 # Move to the empty profile.
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"
129 # Test that '--list-generations' does not output the zeroth generation.
130 test -z "`guix package -p "$profile" -l 0`"
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"
137 # Check that the first generation is the current one.
138 test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)"
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"
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"
151 # Make a "hole" in the list of generations, and make sure we can
152 # roll back and switch "over" it.
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"
159 # Make sure LIBRARY_PATH gets listed by `--search-paths'.
160 guix package
--bootstrap -p "$profile" -i guile-bootstrap
-i gcc-bootstrap
161 guix package
-p "$profile" --search-paths |
grep LIBRARY_PATH
163 # Roll back so we can delete #3 below.
164 guix package
-p "$profile" --switch-generation=2
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`"
170 # Search path of combined profiles. 'LIBRARY_PATH' should show up only in the
171 # combination, not in the individual profiles.
173 guix package
--bootstrap -p "$profile" -i guile-bootstrap
174 guix package
--bootstrap -p "$profile_alt" -i gcc-bootstrap
175 ! guix package
-p "$profile" --search-paths |
grep LIBRARY_PATH
176 guix package
-p "$profile" -p "$profile_alt" --search-paths \
177 |
grep "LIBRARY_PATH.*$profile/lib.$profile_alt/lib"
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
184 cat > "$module_dir/new.scm" <<EOF
187 #:use-module (gnu packages bootstrap))
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")))))
197 guix package
--bootstrap -p "$profile" -i gcc-bootstrap
198 installed
="`guix package -p "$profile" -I | cut -f1`"
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"
211 # Try with the default profile.
214 XDG_CACHE_HOME
="${XDG_CACHE_HOME:-$HOME/.cache}"
215 export XDG_CACHE_HOME
216 HOME
="$PWD/t-home-$$"
221 # Get the canonical directory name so that 'guix package' recognizes it.
222 HOME
="`cd $HOME; pwd -P`"
224 guix package
--bootstrap -e "$boot_make"
225 test -f "$HOME/.guix-profile/bin/make"
227 guix package
--bootstrap --roll-back
228 ! test -f "$HOME/.guix-profile/bin/make"