gnu: lxqt-policykit: Update to 0.14.1.
[guix.git] / tests / guix-package-net.sh
blob82c346dd4c3617c7a37c99f55dda8ab4afd07236
1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2012, 2013, 2014, 2015, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
3 # Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
5 # This file is part of GNU Guix.
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.
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.
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/>.
21 # Test the `guix package' command-line utility. This test requires network
22 # access and is skipped when that is lacking.
25 guix package --version
27 readlink_base ()
29 basename `readlink "$1"`
32 # Return true if a typical shebang in the store would exceed Linux's default
33 # static limit.
34 shebang_too_long ()
36 test `echo $NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash | wc -c` \
37 -ge 128
40 if ! guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null \
41 || shebang_too_long
42 then
43 # Skipping.
44 exit 77
48 profile="t-profile-$$"
49 profile_alt="t-profile-alt-$$"
50 rm -f "$profile"
52 trap 'rm -f "$profile" "$profile_alt" "$profile-"[0-9]* "$profile_alt-"[0-9]* ; rm -rf t-home-'"$$" EXIT
55 guix package --bootstrap -p "$profile" -i guile-bootstrap
56 test -L "$profile" && test -L "$profile-1-link"
57 ! test -f "$profile-2-link"
58 test -f "$profile/bin/guile"
60 boot_make="(@@ (gnu packages commencement) gnu-make-boot0)"
61 boot_make_drv="`guix build -e "$boot_make" | grep -v -e -debug`"
62 guix package --bootstrap -p "$profile" -i "$boot_make_drv"
63 test -L "$profile-2-link"
64 test -f "$profile/bin/make" && test -f "$profile/bin/guile"
66 # Check whether `--list-installed' works.
67 # XXX: Change the tests when `--install' properly extracts the package
68 # name and version string.
69 installed="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
70 case "x$installed" in
71 "guile-bootstrap make-boot0")
72 true;;
73 "make-boot0 guile-bootstrap")
74 true;;
75 "*")
76 false;;
77 esac
79 test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
81 # List generations.
82 test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
83 = " guile-bootstrap"
85 # Exit with 1 when a generation does not exist.
86 if guix package -p "$profile" --list-generations=42;
87 then false; else true; fi
88 if guix package -p "$profile" --switch-generation=99;
89 then false; else true; fi
91 # Remove a package.
92 guix package --bootstrap -p "$profile" -r "guile-bootstrap"
93 test -L "$profile-3-link"
94 test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
96 # Roll back.
97 guix package --roll-back -p "$profile"
98 test "`readlink_base "$profile"`" = "$profile-2-link"
99 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
100 guix package --roll-back -p "$profile"
101 test "`readlink_base "$profile"`" = "$profile-1-link"
102 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
104 # Switch to the rolled generation and switch back.
105 guix package -p "$profile" --switch-generation=2
106 test "`readlink_base "$profile"`" = "$profile-2-link"
107 guix package -p "$profile" --switch-generation=-1
108 test "`readlink_base "$profile"`" = "$profile-1-link"
110 # Move to the empty profile.
111 for i in `seq 1 3`
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"
117 done
119 # Test that '--list-generations' does not output the zeroth generation.
120 test -z "`guix package -p "$profile" -l 0`"
122 # Reinstall after roll-back to the empty profile.
123 guix package --bootstrap -p "$profile" -e "$boot_make"
124 test "`readlink_base "$profile"`" = "$profile-1-link"
125 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
127 # Check that the first generation is the current one.
128 test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)"
130 # Roll-back to generation 0, and install---all at once.
131 guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap
132 test "`readlink_base "$profile"`" = "$profile-1-link"
133 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
135 # Install Make.
136 guix package --bootstrap -p "$profile" -e "$boot_make"
137 test "`readlink_base "$profile"`" = "$profile-2-link"
138 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
139 grep "`guix build -e "$boot_make"`" "$profile/manifest"
141 # Make a "hole" in the list of generations, and make sure we can
142 # roll back and switch "over" it.
143 rm "$profile-1-link"
144 guix package --bootstrap -p "$profile" --roll-back
145 test "`readlink_base "$profile"`" = "$profile-0-link"
146 guix package -p "$profile" --switch-generation=+1
147 test "`readlink_base "$profile"`" = "$profile-2-link"
149 # Make sure LIBRARY_PATH gets listed by `--search-paths'.
150 guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap
151 guix package -p "$profile" --search-paths | grep LIBRARY_PATH
153 # Roll back so we can delete #3 below.
154 guix package -p "$profile" --switch-generation=2
156 # Delete the third generation and check that it was actually deleted.
157 guix package -p "$profile" --delete-generations=3
158 test -z "`guix package -p "$profile" -l 3`"
160 # Search path of combined profiles. 'LIBRARY_PATH' should show up only in the
161 # combination, not in the individual profiles.
162 rm "$profile"
163 guix package --bootstrap -p "$profile" -i guile-bootstrap
164 guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap
165 if guix package -p "$profile" --search-paths | grep LIBRARY_PATH
166 then false; fi
167 guix package -p "$profile" -p "$profile_alt" --search-paths \
168 | grep "LIBRARY_PATH.*$profile/lib.$profile_alt/lib"
170 # Simulate an upgrade and make sure the package order is preserved.
171 module_dir="t-guix-package-net-$$"
172 trap 'rm -rf "$module_dir"' EXIT
174 mkdir "$module_dir"
175 cat > "$module_dir/new.scm" <<EOF
176 (define-module (new)
177 #:use-module (guix)
178 #:use-module (gnu packages bootstrap))
180 (define-public new-guile
181 (package (inherit %bootstrap-guile)
182 (version (string-append "42." (getenv "V_MINOR")))))
183 (define-public new-gcc
184 (package (inherit %bootstrap-gcc)
185 (version (string-append "77." (getenv "V_MINOR")))))
188 guix package --bootstrap -p "$profile" -i gcc-bootstrap
189 installed="`guix package -p "$profile" -I | cut -f1`"
191 for i in 1 2
193 V_MINOR="$i"
194 export V_MINOR
196 guix package -p "$profile" --bootstrap -L "$module_dir" -u .
197 post_upgrade="`guix package -p "$profile" -I | cut -f1`"
198 test "$post_upgrade" = "$installed"
199 done
202 # Try with the default profile.
205 XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
206 export XDG_CACHE_HOME
207 HOME="$PWD/t-home-$$"
208 export HOME
210 mkdir -p "$HOME"
212 # Get the canonical directory name so that 'guix package' recognizes it.
213 HOME="`cd $HOME; pwd -P`"
215 guix package --bootstrap -e "$boot_make"
216 test -f "$HOME/.guix-profile/bin/make"
218 guix package --bootstrap --roll-back
219 ! test -f "$HOME/.guix-profile/bin/make"