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>
5 # This file is part of GNU Guix.
7 # GNU Guix is free software; you can redistribute it and/or modify it
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.
12 # GNU Guix is distributed in the hope that it will be useful, but
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.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 # Test the `guix package' command-line utility. This test requires network
22 # access and is skipped when that is lacking.
25 guix package
--version
29 basename `readlink "$1"`
32 # Return true if a typical shebang in the store would exceed Linux's default
36 test `echo $NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash | wc -c` \
40 if ! guile
-c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev
/null \
48 profile
="t-profile-$$"
49 profile_alt
="t-profile-alt-$$"
52 trap 'rm -f "$profile" "$profile_alt" "$profile-"[0-9]* "$profile_alt-"[0-9]* ; rm -rf t-home-'"$$" EXIT
55 guix package
--bootstrap -p "$profile" -i guile-bootstrap
56 test -L "$profile" && test -L "$profile-1-link"
57 ! test -f "$profile-2-link"
58 test -f "$profile/bin/guile"
60 boot_make
="(@@ (gnu packages commencement) gnu-make-boot0)"
61 boot_make_drv
="`guix build -e "$boot_make" | grep -v -e -debug`"
62 guix package
--bootstrap -p "$profile" -i "$boot_make_drv"
63 test -L "$profile-2-link"
64 test -f "$profile/bin/make" && test -f "$profile/bin/guile"
66 # Check whether `--list-installed' works.
67 # XXX: Change the tests when `--install' properly extracts the package
68 # name and version string.
69 installed
="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
71 "guile-bootstrap make-boot0")
73 "make-boot0 guile-bootstrap")
79 test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
82 test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
85 # Exit with 1 when a generation does not exist.
86 if guix package
-p "$profile" --list-generations=42;
87 then false
; else true
; fi
88 if guix package
-p "$profile" --switch-generation=99;
89 then false
; else true
; fi
92 guix package
--bootstrap -p "$profile" -r "guile-bootstrap"
93 test -L "$profile-3-link"
94 test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
97 guix package
--roll-back -p "$profile"
98 test "`readlink_base "$profile"`" = "$profile-2-link"
99 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
100 guix package
--roll-back -p "$profile"
101 test "`readlink_base "$profile"`" = "$profile-1-link"
102 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
104 # Switch to the rolled generation and switch back.
105 guix package
-p "$profile" --switch-generation=2
106 test "`readlink_base "$profile"`" = "$profile-2-link"
107 guix package
-p "$profile" --switch-generation=-1
108 test "`readlink_base "$profile"`" = "$profile-1-link"
110 # Move to the empty profile.
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"
119 # Test that '--list-generations' does not output the zeroth generation.
120 test -z "`guix package -p "$profile" -l 0`"
122 # Reinstall after roll-back to the empty profile.
123 guix package
--bootstrap -p "$profile" -e "$boot_make"
124 test "`readlink_base "$profile"`" = "$profile-1-link"
125 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
127 # Check that the first generation is the current one.
128 test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)"
130 # Roll-back to generation 0, and install---all at once.
131 guix package
--bootstrap -p "$profile" --roll-back -i guile-bootstrap
132 test "`readlink_base "$profile"`" = "$profile-1-link"
133 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
136 guix package
--bootstrap -p "$profile" -e "$boot_make"
137 test "`readlink_base "$profile"`" = "$profile-2-link"
138 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
139 grep "`guix build -e "$boot_make"`" "$profile/manifest"
141 # Make a "hole" in the list of generations, and make sure we can
142 # roll back and switch "over" it.
144 guix package
--bootstrap -p "$profile" --roll-back
145 test "`readlink_base "$profile"`" = "$profile-0-link"
146 guix package
-p "$profile" --switch-generation=+1
147 test "`readlink_base "$profile"`" = "$profile-2-link"
149 # Make sure LIBRARY_PATH gets listed by `--search-paths'.
150 guix package
--bootstrap -p "$profile" -i guile-bootstrap
-i gcc-bootstrap
151 guix package
-p "$profile" --search-paths |
grep LIBRARY_PATH
153 # Roll back so we can delete #3 below.
154 guix package
-p "$profile" --switch-generation=2
156 # Delete the third generation and check that it was actually deleted.
157 guix package
-p "$profile" --delete-generations=3
158 test -z "`guix package -p "$profile" -l 3`"
160 # Search path of combined profiles. 'LIBRARY_PATH' should show up only in the
161 # combination, not in the individual profiles.
163 guix package
--bootstrap -p "$profile" -i guile-bootstrap
164 guix package
--bootstrap -p "$profile_alt" -i gcc-bootstrap
165 if guix package
-p "$profile" --search-paths |
grep LIBRARY_PATH
167 guix package
-p "$profile" -p "$profile_alt" --search-paths \
168 |
grep "LIBRARY_PATH.*$profile/lib.$profile_alt/lib"
170 # Simulate an upgrade and make sure the package order is preserved.
171 module_dir
="t-guix-package-net-$$"
172 trap 'rm -rf "$module_dir"' EXIT
175 cat > "$module_dir/new.scm" <<EOF
178 #:use-module (gnu packages bootstrap))
180 (define-public new-guile
181 (package (inherit %bootstrap-guile)
182 (version (string-append "42." (getenv "V_MINOR")))))
183 (define-public new-gcc
184 (package (inherit %bootstrap-gcc)
185 (version (string-append "77." (getenv "V_MINOR")))))
188 guix package
--bootstrap -p "$profile" -i gcc-bootstrap
189 installed
="`guix package -p "$profile" -I | cut -f1`"
196 guix package
-p "$profile" --bootstrap -L "$module_dir" -u .
197 post_upgrade
="`guix package -p "$profile" -I | cut -f1`"
198 test "$post_upgrade" = "$installed"
202 # Try with the default profile.
205 XDG_CACHE_HOME
="${XDG_CACHE_HOME:-$HOME/.cache}"
206 export XDG_CACHE_HOME
207 HOME
="$PWD/t-home-$$"
212 # Get the canonical directory name so that 'guix package' recognizes it.
213 HOME
="`cd $HOME; pwd -P`"
215 guix package
--bootstrap -e "$boot_make"
216 test -f "$HOME/.guix-profile/bin/make"
218 guix package
--bootstrap --roll-back
219 ! test -f "$HOME/.guix-profile/bin/make"