system: Populate /etc/shells from ACCOUNT-SERVICE-TYPE.
[jackhill/guix/guix.git] / tests / guix-package-net.sh
CommitLineData
57b86237
LC
1# GNU Guix --- Functional package management for GNU
2# Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
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
LC
48profile="t-profile-$$"
49rm -f "$profile"
50
51trap 'rm -f "$profile" "$profile-"[0-9]* ; rm -rf t-home-'"$$" EXIT
52
53
54guix package --bootstrap -p "$profile" -i guile-bootstrap
55test -L "$profile" && test -L "$profile-1-link"
56! test -f "$profile-2-link"
57test -f "$profile/bin/guile"
58
59boot_make="(@@ (gnu packages commencement) gnu-make-boot0)"
60boot_make_drv="`guix build -e "$boot_make" | grep -v -e -debug`"
61guix package --bootstrap -p "$profile" -i "$boot_make_drv"
62test -L "$profile-2-link"
63test -f "$profile/bin/make" && test -f "$profile/bin/guile"
64
65# Check whether `--list-installed' works.
66# XXX: Change the tests when `--install' properly extracts the package
67# name and version string.
68installed="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
69case "x$installed" in
70 "guile-bootstrap make-boot0")
71 true;;
72 "make-boot0 guile-bootstrap")
73 true;;
74 "*")
75 false;;
76esac
77
78test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
79
80# List generations.
81test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
82 = " guile-bootstrap"
83
84# Exit with 1 when a generation does not exist.
85if guix package -p "$profile" --list-generations=42;
86then false; else true; fi
87if guix package -p "$profile" --switch-generation=99;
88then false; else true; fi
89
90# Remove a package.
91guix package --bootstrap -p "$profile" -r "guile-bootstrap"
92test -L "$profile-3-link"
93test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
94
95# Roll back.
96guix package --roll-back -p "$profile"
97test "`readlink_base "$profile"`" = "$profile-2-link"
98test -x "$profile/bin/guile" && test -x "$profile/bin/make"
99guix package --roll-back -p "$profile"
100test "`readlink_base "$profile"`" = "$profile-1-link"
101test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
102
103# Switch to the rolled generation and switch back.
104guix package -p "$profile" --switch-generation=2
105test "`readlink_base "$profile"`" = "$profile-2-link"
106guix package -p "$profile" --switch-generation=-1
107test "`readlink_base "$profile"`" = "$profile-1-link"
108
109# Move to the empty profile.
110for i in `seq 1 3`
111do
112 guix package --bootstrap --roll-back -p "$profile"
113 ! test -f "$profile/bin"
114 ! test -f "$profile/lib"
115 test "`readlink_base "$profile"`" = "$profile-0-link"
116done
117
118# Test that '--list-generations' does not output the zeroth generation.
119test -z "`guix package -p "$profile" -l 0`"
120
121# Reinstall after roll-back to the empty profile.
122guix package --bootstrap -p "$profile" -e "$boot_make"
123test "`readlink_base "$profile"`" = "$profile-1-link"
124test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
125
126# Check that the first generation is the current one.
127test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)"
128
129# Roll-back to generation 0, and install---all at once.
130guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap
131test "`readlink_base "$profile"`" = "$profile-1-link"
132test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
133
134# Install Make.
135guix package --bootstrap -p "$profile" -e "$boot_make"
136test "`readlink_base "$profile"`" = "$profile-2-link"
137test -x "$profile/bin/guile" && test -x "$profile/bin/make"
138grep "`guix build -e "$boot_make"`" "$profile/manifest"
139
140# Make a "hole" in the list of generations, and make sure we can
141# roll back and switch "over" it.
142rm "$profile-1-link"
143guix package --bootstrap -p "$profile" --roll-back
144test "`readlink_base "$profile"`" = "$profile-0-link"
145guix package -p "$profile" --switch-generation=+1
146test "`readlink_base "$profile"`" = "$profile-2-link"
147
148# Make sure LIBRARY_PATH gets listed by `--search-paths'.
149guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap
dbc31ab2 150guix package -p "$profile" --search-paths | grep LIBRARY_PATH
57b86237
LC
151
152# Roll back so we can delete #3 below.
153guix package -p "$profile" --switch-generation=2
154
155# Delete the third generation and check that it was actually deleted.
156guix package -p "$profile" --delete-generations=3
157test -z "`guix package -p "$profile" -l 3`"
158
159
160#
161# Try with the default profile.
162#
163
164XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
165export XDG_CACHE_HOME
166HOME="$PWD/t-home-$$"
167export HOME
168
169mkdir -p "$HOME"
170
171# Get the canonical directory name so that 'guix package' recognizes it.
172HOME="`cd $HOME; pwd -P`"
173
174guix package --bootstrap -e "$boot_make"
175test -f "$HOME/.guix-profile/bin/make"
176
177guix package --bootstrap --roll-back
178! test -f "$HOME/.guix-profile/bin/make"