epiphany w/ gtk4 and webkitgtk 2.38
[jackhill/guix/guix.git] / tests / guix-package-net.sh
CommitLineData
57b86237 1# GNU Guix --- Functional package management for GNU
686f2eae 2# Copyright © 2012-2015, 2017, 2019, 2022 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
26guix package --version
27
28readlink_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.
35shebang_too_long ()
36{
37 test `echo $NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash | wc -c` \
38 -ge 128
39}
40
0b131612
LC
41if ! guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null \
42 || shebang_too_long
43then
44 # Skipping.
45 exit 77
46fi
47
48
57b86237 49profile="t-profile-$$"
fc2d2339 50profile_alt="t-profile-alt-$$"
57b86237
LC
51rm -f "$profile"
52
686f2eae
LC
53module_dir="t-guix-package-net-$$"
54mkdir "$module_dir"
55
56trap 'rm -f "$profile" "$profile_alt" "$profile.lock" "$profile_alt.lock" "$profile-"[0-9]* "$profile_alt-"[0-9]* ; rm -r "$module_dir" t-home-'"$$" EXIT
57b86237
LC
57
58
59guix package --bootstrap -p "$profile" -i guile-bootstrap
60test -L "$profile" && test -L "$profile-1-link"
61! test -f "$profile-2-link"
62test -f "$profile/bin/guile"
63
03d76577 64boot_make="(@ (guix tests) gnu-make-for-tests)"
57b86237
LC
65boot_make_drv="`guix build -e "$boot_make" | grep -v -e -debug`"
66guix package --bootstrap -p "$profile" -i "$boot_make_drv"
67test -L "$profile-2-link"
68test -f "$profile/bin/make" && test -f "$profile/bin/guile"
69
70# Check whether `--list-installed' works.
71# XXX: Change the tests when `--install' properly extracts the package
72# name and version string.
73installed="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
74case "x$installed" in
75 "guile-bootstrap make-boot0")
76 true;;
77 "make-boot0 guile-bootstrap")
78 true;;
79 "*")
80 false;;
81esac
82
83test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
84
881eaae1 85guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap
86installed="`guix package -p "$profile" -p "$profile_alt" -I | cut -f1 | xargs echo | sort`"
87case "x$installed" in
88 "gcc-bootstrap guile-bootstrap make-boot0")
89 true;;
90 "*")
91 false;;
92esac
93test "`guix package -p "$profile_alt" -p "$profile" -I | wc -l`" = "3"
94rm "$profile_alt"
95
57b86237
LC
96# List generations.
97test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
98 = " guile-bootstrap"
99
100# Exit with 1 when a generation does not exist.
d8934360
EB
101! guix package -p "$profile" --list-generations=42
102! guix package -p "$profile" --switch-generation=99
57b86237
LC
103
104# Remove a package.
105guix package --bootstrap -p "$profile" -r "guile-bootstrap"
106test -L "$profile-3-link"
107test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
108
109# Roll back.
110guix package --roll-back -p "$profile"
111test "`readlink_base "$profile"`" = "$profile-2-link"
112test -x "$profile/bin/guile" && test -x "$profile/bin/make"
113guix package --roll-back -p "$profile"
114test "`readlink_base "$profile"`" = "$profile-1-link"
115test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
116
117# Switch to the rolled generation and switch back.
118guix package -p "$profile" --switch-generation=2
119test "`readlink_base "$profile"`" = "$profile-2-link"
120guix package -p "$profile" --switch-generation=-1
121test "`readlink_base "$profile"`" = "$profile-1-link"
122
123# Move to the empty profile.
124for i in `seq 1 3`
125do
126 guix package --bootstrap --roll-back -p "$profile"
127 ! test -f "$profile/bin"
128 ! test -f "$profile/lib"
129 test "`readlink_base "$profile"`" = "$profile-0-link"
130done
131
132# Test that '--list-generations' does not output the zeroth generation.
133test -z "`guix package -p "$profile" -l 0`"
134
135# Reinstall after roll-back to the empty profile.
136guix package --bootstrap -p "$profile" -e "$boot_make"
137test "`readlink_base "$profile"`" = "$profile-1-link"
138test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
139
140# Check that the first generation is the current one.
141test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)"
142
143# Roll-back to generation 0, and install---all at once.
144guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap
145test "`readlink_base "$profile"`" = "$profile-1-link"
146test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
147
148# Install Make.
149guix package --bootstrap -p "$profile" -e "$boot_make"
150test "`readlink_base "$profile"`" = "$profile-2-link"
151test -x "$profile/bin/guile" && test -x "$profile/bin/make"
152grep "`guix build -e "$boot_make"`" "$profile/manifest"
153
154# Make a "hole" in the list of generations, and make sure we can
155# roll back and switch "over" it.
156rm "$profile-1-link"
157guix package --bootstrap -p "$profile" --roll-back
158test "`readlink_base "$profile"`" = "$profile-0-link"
159guix package -p "$profile" --switch-generation=+1
160test "`readlink_base "$profile"`" = "$profile-2-link"
161
162# Make sure LIBRARY_PATH gets listed by `--search-paths'.
163guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap
dbc31ab2 164guix package -p "$profile" --search-paths | grep LIBRARY_PATH
57b86237
LC
165
166# Roll back so we can delete #3 below.
167guix package -p "$profile" --switch-generation=2
168
169# Delete the third generation and check that it was actually deleted.
170guix package -p "$profile" --delete-generations=3
171test -z "`guix package -p "$profile" -l 3`"
172
fc2d2339
LC
173# Search path of combined profiles. 'LIBRARY_PATH' should show up only in the
174# combination, not in the individual profiles.
175rm "$profile"
176guix package --bootstrap -p "$profile" -i guile-bootstrap
177guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap
d8934360 178! guix package -p "$profile" --search-paths | grep LIBRARY_PATH
fc2d2339 179guix package -p "$profile" -p "$profile_alt" --search-paths \
c5746f23 180 | grep "LIBRARY_PATH.*$profile/lib.$profile_alt/lib"
57b86237 181
35225dc5 182# Simulate an upgrade and make sure the package order is preserved.
35225dc5
LC
183cat > "$module_dir/new.scm" <<EOF
184(define-module (new)
185 #:use-module (guix)
186 #:use-module (gnu packages bootstrap))
187
188(define-public new-guile
189 (package (inherit %bootstrap-guile)
190 (version (string-append "42." (getenv "V_MINOR")))))
191(define-public new-gcc
192 (package (inherit %bootstrap-gcc)
193 (version (string-append "77." (getenv "V_MINOR")))))
194EOF
195
196guix package --bootstrap -p "$profile" -i gcc-bootstrap
197installed="`guix package -p "$profile" -I | cut -f1`"
198
ccda88a0
LC
199# Dry-run upgrade. Make sure no new generation is created when things are
200# already in store and '-n' is used: <https://issues.guix.gnu.org/53267>.
201V_MINOR=0
202export V_MINOR
203profile_before="$(readlink "$profile")"
204guix package -p "$profile" --bootstrap -L "$module_dir" -u # build the profile
205guix package -p "$profile" --roll-back
206guix package -p "$profile" --bootstrap -L "$module_dir" -u . -n # check '-n'
207test "$(readlink "$profile")" = "$profile_before"
208
35225dc5
LC
209for i in 1 2
210do
211 V_MINOR="$i"
212 export V_MINOR
213
214 guix package -p "$profile" --bootstrap -L "$module_dir" -u .
215 post_upgrade="`guix package -p "$profile" -I | cut -f1`"
216 test "$post_upgrade" = "$installed"
217done
218
57b86237
LC
219#
220# Try with the default profile.
221#
222
223XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
224export XDG_CACHE_HOME
225HOME="$PWD/t-home-$$"
226export HOME
227
228mkdir -p "$HOME"
229
230# Get the canonical directory name so that 'guix package' recognizes it.
231HOME="`cd $HOME; pwd -P`"
232
233guix package --bootstrap -e "$boot_make"
234test -f "$HOME/.guix-profile/bin/make"
235
236guix package --bootstrap --roll-back
237! test -f "$HOME/.guix-profile/bin/make"