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