gnu: Add emacs-exec-path-from-shell.
[jackhill/guix/guix.git] / tests / guix-package-net.sh
CommitLineData
57b86237 1# GNU Guix --- Functional package management for GNU
c5746f23 2# Copyright © 2012, 2013, 2014, 2015, 2017 Ludovic Courtès <ludo@gnu.org>
57b86237
LC
3# Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
4#
5# This file is part of GNU Guix.
6#
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.
11#
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.
16#
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/>.
19
20#
21# Test the `guix package' command-line utility. This test requires network
22# access and is skipped when that is lacking.
23#
24
25guix package --version
26
27readlink_base ()
28{
29 basename `readlink "$1"`
30}
31
32# Return true if a typical shebang in the store would exceed Linux's default
33# static limit.
34shebang_too_long ()
35{
36 test `echo $NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash | wc -c` \
37 -ge 128
38}
39
0b131612
LC
40if ! guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null \
41 || shebang_too_long
42then
43 # Skipping.
44 exit 77
45fi
46
47
57b86237 48profile="t-profile-$$"
fc2d2339 49profile_alt="t-profile-alt-$$"
57b86237
LC
50rm -f "$profile"
51
0c152cd6 52trap 'rm -f "$profile" "$profile_alt" "$profile-"[0-9]* "$profile_alt-"[0-9]* ; rm -rf t-home-'"$$" EXIT
57b86237
LC
53
54
55guix package --bootstrap -p "$profile" -i guile-bootstrap
56test -L "$profile" && test -L "$profile-1-link"
57! test -f "$profile-2-link"
58test -f "$profile/bin/guile"
59
60boot_make="(@@ (gnu packages commencement) gnu-make-boot0)"
61boot_make_drv="`guix build -e "$boot_make" | grep -v -e -debug`"
62guix package --bootstrap -p "$profile" -i "$boot_make_drv"
63test -L "$profile-2-link"
64test -f "$profile/bin/make" && test -f "$profile/bin/guile"
65
66# Check whether `--list-installed' works.
67# XXX: Change the tests when `--install' properly extracts the package
68# name and version string.
69installed="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
70case "x$installed" in
71 "guile-bootstrap make-boot0")
72 true;;
73 "make-boot0 guile-bootstrap")
74 true;;
75 "*")
76 false;;
77esac
78
79test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
80
81# List generations.
82test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
83 = " guile-bootstrap"
84
85# Exit with 1 when a generation does not exist.
86if guix package -p "$profile" --list-generations=42;
87then false; else true; fi
88if guix package -p "$profile" --switch-generation=99;
89then false; else true; fi
90
91# Remove a package.
92guix package --bootstrap -p "$profile" -r "guile-bootstrap"
93test -L "$profile-3-link"
94test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
95
96# Roll back.
97guix package --roll-back -p "$profile"
98test "`readlink_base "$profile"`" = "$profile-2-link"
99test -x "$profile/bin/guile" && test -x "$profile/bin/make"
100guix package --roll-back -p "$profile"
101test "`readlink_base "$profile"`" = "$profile-1-link"
102test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
103
104# Switch to the rolled generation and switch back.
105guix package -p "$profile" --switch-generation=2
106test "`readlink_base "$profile"`" = "$profile-2-link"
107guix package -p "$profile" --switch-generation=-1
108test "`readlink_base "$profile"`" = "$profile-1-link"
109
110# Move to the empty profile.
111for i in `seq 1 3`
112do
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"
117done
118
119# Test that '--list-generations' does not output the zeroth generation.
120test -z "`guix package -p "$profile" -l 0`"
121
122# Reinstall after roll-back to the empty profile.
123guix package --bootstrap -p "$profile" -e "$boot_make"
124test "`readlink_base "$profile"`" = "$profile-1-link"
125test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
126
127# Check that the first generation is the current one.
128test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)"
129
130# Roll-back to generation 0, and install---all at once.
131guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap
132test "`readlink_base "$profile"`" = "$profile-1-link"
133test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
134
135# Install Make.
136guix package --bootstrap -p "$profile" -e "$boot_make"
137test "`readlink_base "$profile"`" = "$profile-2-link"
138test -x "$profile/bin/guile" && test -x "$profile/bin/make"
139grep "`guix build -e "$boot_make"`" "$profile/manifest"
140
141# Make a "hole" in the list of generations, and make sure we can
142# roll back and switch "over" it.
143rm "$profile-1-link"
144guix package --bootstrap -p "$profile" --roll-back
145test "`readlink_base "$profile"`" = "$profile-0-link"
146guix package -p "$profile" --switch-generation=+1
147test "`readlink_base "$profile"`" = "$profile-2-link"
148
149# Make sure LIBRARY_PATH gets listed by `--search-paths'.
150guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap
dbc31ab2 151guix package -p "$profile" --search-paths | grep LIBRARY_PATH
57b86237
LC
152
153# Roll back so we can delete #3 below.
154guix package -p "$profile" --switch-generation=2
155
156# Delete the third generation and check that it was actually deleted.
157guix package -p "$profile" --delete-generations=3
158test -z "`guix package -p "$profile" -l 3`"
159
fc2d2339
LC
160# Search path of combined profiles. 'LIBRARY_PATH' should show up only in the
161# combination, not in the individual profiles.
162rm "$profile"
163guix package --bootstrap -p "$profile" -i guile-bootstrap
164guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap
165if guix package -p "$profile" --search-paths | grep LIBRARY_PATH
166then false; fi
167guix package -p "$profile" -p "$profile_alt" --search-paths \
c5746f23 168 | grep "LIBRARY_PATH.*$profile/lib.$profile_alt/lib"
57b86237
LC
169
170#
171# Try with the default profile.
172#
173
174XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
175export XDG_CACHE_HOME
176HOME="$PWD/t-home-$$"
177export HOME
178
179mkdir -p "$HOME"
180
181# Get the canonical directory name so that 'guix package' recognizes it.
182HOME="`cd $HOME; pwd -P`"
183
184guix package --bootstrap -e "$boot_make"
185test -f "$HOME/.guix-profile/bin/make"
186
187guix package --bootstrap --roll-back
188! test -f "$HOME/.guix-profile/bin/make"