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 if guix package
-p "$profile" --list-generations=42;
99 then false
; else true
; fi
100 if guix package
-p "$profile" --switch-generation=99;
101 then false
; else true
; fi
104 guix package
--bootstrap -p "$profile" -r "guile-bootstrap"
105 test -L "$profile-3-link"
106 test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
109 guix package
--roll-back -p "$profile"
110 test "`readlink_base "$profile"`" = "$profile-2-link"
111 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
112 guix package
--roll-back -p "$profile"
113 test "`readlink_base "$profile"`" = "$profile-1-link"
114 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
116 # Switch to the rolled generation and switch back.
117 guix package
-p "$profile" --switch-generation=2
118 test "`readlink_base "$profile"`" = "$profile-2-link"
119 guix package
-p "$profile" --switch-generation=-1
120 test "`readlink_base "$profile"`" = "$profile-1-link"
122 # Move to the empty profile.
125 guix package
--bootstrap --roll-back -p "$profile"
126 ! test -f "$profile/bin"
127 ! test -f "$profile/lib"
128 test "`readlink_base "$profile"`" = "$profile-0-link"
131 # Test that '--list-generations' does not output the zeroth generation.
132 test -z "`guix package -p "$profile" -l 0`"
134 # Reinstall after roll-back to the empty profile.
135 guix package
--bootstrap -p "$profile" -e "$boot_make"
136 test "`readlink_base "$profile"`" = "$profile-1-link"
137 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
139 # Check that the first generation is the current one.
140 test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)"
142 # Roll-back to generation 0, and install---all at once.
143 guix package
--bootstrap -p "$profile" --roll-back -i guile-bootstrap
144 test "`readlink_base "$profile"`" = "$profile-1-link"
145 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
148 guix package
--bootstrap -p "$profile" -e "$boot_make"
149 test "`readlink_base "$profile"`" = "$profile-2-link"
150 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
151 grep "`guix build -e "$boot_make"`" "$profile/manifest"
153 # Make a "hole" in the list of generations, and make sure we can
154 # roll back and switch "over" it.
156 guix package
--bootstrap -p "$profile" --roll-back
157 test "`readlink_base "$profile"`" = "$profile-0-link"
158 guix package
-p "$profile" --switch-generation=+1
159 test "`readlink_base "$profile"`" = "$profile-2-link"
161 # Make sure LIBRARY_PATH gets listed by `--search-paths'.
162 guix package
--bootstrap -p "$profile" -i guile-bootstrap
-i gcc-bootstrap
163 guix package
-p "$profile" --search-paths |
grep LIBRARY_PATH
165 # Roll back so we can delete #3 below.
166 guix package
-p "$profile" --switch-generation=2
168 # Delete the third generation and check that it was actually deleted.
169 guix package
-p "$profile" --delete-generations=3
170 test -z "`guix package -p "$profile" -l 3`"
172 # Search path of combined profiles. 'LIBRARY_PATH' should show up only in the
173 # combination, not in the individual profiles.
175 guix package
--bootstrap -p "$profile" -i guile-bootstrap
176 guix package
--bootstrap -p "$profile_alt" -i gcc-bootstrap
177 if guix package
-p "$profile" --search-paths |
grep LIBRARY_PATH
179 guix package
-p "$profile" -p "$profile_alt" --search-paths \
180 |
grep "LIBRARY_PATH.*$profile/lib.$profile_alt/lib"
182 # Simulate an upgrade and make sure the package order is preserved.
183 module_dir
="t-guix-package-net-$$"
184 trap 'rm -rf "$module_dir"' EXIT
187 cat > "$module_dir/new.scm" <<EOF
190 #:use-module (gnu packages bootstrap))
192 (define-public new-guile
193 (package (inherit %bootstrap-guile)
194 (version (string-append "42." (getenv "V_MINOR")))))
195 (define-public new-gcc
196 (package (inherit %bootstrap-gcc)
197 (version (string-append "77." (getenv "V_MINOR")))))
200 guix package
--bootstrap -p "$profile" -i gcc-bootstrap
201 installed
="`guix package -p "$profile" -I | cut -f1`"
208 guix package
-p "$profile" --bootstrap -L "$module_dir" -u .
209 post_upgrade
="`guix package -p "$profile" -I | cut -f1`"
210 test "$post_upgrade" = "$installed"
214 # Try with the default profile.
217 XDG_CACHE_HOME
="${XDG_CACHE_HOME:-$HOME/.cache}"
218 export XDG_CACHE_HOME
219 HOME
="$PWD/t-home-$$"
224 # Get the canonical directory name so that 'guix package' recognizes it.
225 HOME
="`cd $HOME; pwd -P`"
227 guix package
--bootstrap -e "$boot_make"
228 test -f "$HOME/.guix-profile/bin/make"
230 guix package
--bootstrap --roll-back
231 ! test -f "$HOME/.guix-profile/bin/make"