WIP: bees service
[jackhill/guix/guix.git] / tests / guix-package-net.sh
CommitLineData
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
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
0c152cd6 53trap 'rm -f "$profile" "$profile_alt" "$profile-"[0-9]* "$profile_alt-"[0-9]* ; rm -rf t-home-'"$$" EXIT
57b86237
LC
54
55
56guix package --bootstrap -p "$profile" -i guile-bootstrap
57test -L "$profile" && test -L "$profile-1-link"
58! test -f "$profile-2-link"
59test -f "$profile/bin/guile"
60
03d76577 61boot_make="(@ (guix tests) gnu-make-for-tests)"
57b86237
LC
62boot_make_drv="`guix build -e "$boot_make" | grep -v -e -debug`"
63guix package --bootstrap -p "$profile" -i "$boot_make_drv"
64test -L "$profile-2-link"
65test -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.
70installed="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
71case "x$installed" in
72 "guile-bootstrap make-boot0")
73 true;;
74 "make-boot0 guile-bootstrap")
75 true;;
76 "*")
77 false;;
78esac
79
80test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
81
881eaae1 82guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap
83installed="`guix package -p "$profile" -p "$profile_alt" -I | cut -f1 | xargs echo | sort`"
84case "x$installed" in
85 "gcc-bootstrap guile-bootstrap make-boot0")
86 true;;
87 "*")
88 false;;
89esac
90test "`guix package -p "$profile_alt" -p "$profile" -I | wc -l`" = "3"
91rm "$profile_alt"
92
57b86237
LC
93# List generations.
94test "`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.
102guix package --bootstrap -p "$profile" -r "guile-bootstrap"
103test -L "$profile-3-link"
104test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
105
106# Roll back.
107guix package --roll-back -p "$profile"
108test "`readlink_base "$profile"`" = "$profile-2-link"
109test -x "$profile/bin/guile" && test -x "$profile/bin/make"
110guix package --roll-back -p "$profile"
111test "`readlink_base "$profile"`" = "$profile-1-link"
112test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
113
114# Switch to the rolled generation and switch back.
115guix package -p "$profile" --switch-generation=2
116test "`readlink_base "$profile"`" = "$profile-2-link"
117guix package -p "$profile" --switch-generation=-1
118test "`readlink_base "$profile"`" = "$profile-1-link"
119
120# Move to the empty profile.
121for i in `seq 1 3`
122do
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"
127done
128
129# Test that '--list-generations' does not output the zeroth generation.
130test -z "`guix package -p "$profile" -l 0`"
131
132# Reinstall after roll-back to the empty profile.
133guix package --bootstrap -p "$profile" -e "$boot_make"
134test "`readlink_base "$profile"`" = "$profile-1-link"
135test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
136
137# Check that the first generation is the current one.
138test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)"
139
140# Roll-back to generation 0, and install---all at once.
141guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap
142test "`readlink_base "$profile"`" = "$profile-1-link"
143test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
144
145# Install Make.
146guix package --bootstrap -p "$profile" -e "$boot_make"
147test "`readlink_base "$profile"`" = "$profile-2-link"
148test -x "$profile/bin/guile" && test -x "$profile/bin/make"
149grep "`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.
153rm "$profile-1-link"
154guix package --bootstrap -p "$profile" --roll-back
155test "`readlink_base "$profile"`" = "$profile-0-link"
156guix package -p "$profile" --switch-generation=+1
157test "`readlink_base "$profile"`" = "$profile-2-link"
158
159# Make sure LIBRARY_PATH gets listed by `--search-paths'.
160guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap
dbc31ab2 161guix package -p "$profile" --search-paths | grep LIBRARY_PATH
57b86237
LC
162
163# Roll back so we can delete #3 below.
164guix package -p "$profile" --switch-generation=2
165
166# Delete the third generation and check that it was actually deleted.
167guix package -p "$profile" --delete-generations=3
168test -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.
172rm "$profile"
173guix package --bootstrap -p "$profile" -i guile-bootstrap
174guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap
d8934360 175! guix package -p "$profile" --search-paths | grep LIBRARY_PATH
fc2d2339 176guix 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.
180module_dir="t-guix-package-net-$$"
181trap 'rm -rf "$module_dir"' EXIT
182
183mkdir "$module_dir"
184cat > "$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")))))
195EOF
196
197guix package --bootstrap -p "$profile" -i gcc-bootstrap
198installed="`guix package -p "$profile" -I | cut -f1`"
199
200for i in 1 2
201do
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"
208done
209
57b86237
LC
210#
211# Try with the default profile.
212#
213
214XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
215export XDG_CACHE_HOME
216HOME="$PWD/t-home-$$"
217export HOME
218
219mkdir -p "$HOME"
220
221# Get the canonical directory name so that 'guix package' recognizes it.
222HOME="`cd $HOME; pwd -P`"
223
224guix package --bootstrap -e "$boot_make"
225test -f "$HOME/.guix-profile/bin/make"
226
227guix package --bootstrap --roll-back
228! test -f "$HOME/.guix-profile/bin/make"