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