Add (gnu system vm).
[jackhill/guix/guix.git] / tests / guix-package.sh
CommitLineData
233e7676 1# GNU Guix --- Functional package management for GNU
cc57f25d 2# Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
acc08466 3# Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
0afdc485 4#
233e7676 5# This file is part of GNU Guix.
0afdc485 6#
233e7676 7# GNU Guix is free software; you can redistribute it and/or modify it
0afdc485
LC
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#
233e7676 12# GNU Guix is distributed in the hope that it will be useful, but
0afdc485
LC
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
233e7676 18# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
0afdc485
LC
19
20#
21# Test the `guix-package' command-line utility.
22#
23
24guix-package --version
25
24e262f0
LC
26readlink_base ()
27{
28 basename `readlink "$1"`
29}
30
0afdc485
LC
31profile="t-profile-$$"
32rm -f "$profile"
33
0ec1af59 34trap 'rm "$profile" "$profile-"[0-9]* ; rm -rf t-home-'"$$" EXIT
7a6548cb 35
44ce77ff 36guix-package --bootstrap -p "$profile" -i guile-bootstrap
0afdc485
LC
37test -L "$profile" && test -L "$profile-1-link"
38test -f "$profile/bin/guile"
39
1c67d639 40# Installing the same package a second time does nothing.
44ce77ff 41guix-package --bootstrap -p "$profile" -i guile-bootstrap
1c67d639
LC
42test -L "$profile" && test -L "$profile-1-link"
43! test -f "$profile-2-link"
44test -f "$profile/bin/guile"
0afdc485 45
ad1ebab3
LC
46# Check whether we have network access.
47if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
48then
1ffa7090 49 boot_make="`guix-build -e '(@@ (gnu packages base) gnu-make-boot0)'`"
24e262f0 50 guix-package --bootstrap -p "$profile" -i "$boot_make"
ad1ebab3
LC
51 test -L "$profile-2-link"
52 test -f "$profile/bin/make" && test -f "$profile/bin/guile"
0afdc485 53
733b4130 54
ad1ebab3
LC
55 # Check whether `--list-installed' works.
56 # XXX: Change the tests when `--install' properly extracts the package
57 # name and version string.
58 installed="`guix-package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
59 case "x$installed" in
60 "guile-bootstrap make-boot0")
61 true;;
62 "make-boot0 guile-bootstrap")
63 true;;
64 "*")
65 false;;
66 esac
733b4130 67
ad1ebab3 68 test "`guix-package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
733b4130 69
acc08466 70 # Search.
299112d3 71 test "`guix-package -s "GNU Hello" | grep ^name:`" = "name: hello"
acc08466
NK
72 test "`guix-package -s "n0t4r341p4ck4g3"`" = ""
73
ad1ebab3 74 # Remove a package.
cc57f25d 75 guix-package --bootstrap -p "$profile" -r "guile-bootstrap"
ad1ebab3
LC
76 test -L "$profile-3-link"
77 test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
24e262f0
LC
78
79 # Roll back.
80 guix-package --roll-back -p "$profile"
81 test "`readlink_base "$profile"`" = "$profile-2-link"
82 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
83 guix-package --roll-back -p "$profile"
84 test "`readlink_base "$profile"`" = "$profile-1-link"
85 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
86
d9307267
LC
87 # Move to the empty profile.
88 for i in `seq 1 3`
89 do
90 guix-package --bootstrap --roll-back -p "$profile"
91 ! test -f "$profile/bin"
92 ! test -f "$profile/lib"
93 test "`readlink_base "$profile"`" = "$profile-0-link"
94 done
24e262f0 95
82fe08ed 96 # Reinstall after roll-back to the empty profile.
24e262f0 97 guix-package --bootstrap -p "$profile" -i "$boot_make"
82fe08ed
LC
98 test "`readlink_base "$profile"`" = "$profile-1-link"
99 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
24e262f0 100
82fe08ed 101 # Roll-back to generation 0, and install---all at once.
44ce77ff 102 guix-package --bootstrap -p "$profile" --roll-back -i guile-bootstrap
82fe08ed
LC
103 test "`readlink_base "$profile"`" = "$profile-1-link"
104 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
105
106 # Install Make.
107 guix-package --bootstrap -p "$profile" -i "$boot_make"
108 test "`readlink_base "$profile"`" = "$profile-2-link"
24e262f0 109 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
9241172c
LC
110
111 # Make a "hole" in the list of generations, and make sure we can
112 # roll back "over" it.
82fe08ed 113 rm "$profile-1-link"
9241172c 114 guix-package --bootstrap -p "$profile" --roll-back
82fe08ed 115 test "`readlink_base "$profile"`" = "$profile-0-link"
ad1ebab3 116fi
0afdc485 117
9518856b 118# Make sure the `:' syntax works.
2a5ab9dc 119guix-package --bootstrap -i "binutils:lib" -p "$profile" -n
9518856b 120
aa92cf98
LC
121# Make sure nonexistent outputs are reported.
122guix-package --bootstrap -i "guile-bootstrap:out" -p "$profile" -n
123if guix-package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile" -n;
124then false; else true; fi
125if guix-package --bootstrap -i "guile-bootstrap:does-not-exist" -p "$profile";
126then false; else true; fi
127
64fc89b6
LC
128# Check whether `--list-available' returns something sensible.
129guix-package -A 'gui.*e' | grep guile
130
67668155 131#
0ec1af59 132# Try with the default profile.
67668155 133#
0ec1af59
LC
134
135XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
136export XDG_CACHE_HOME
137HOME="t-home-$$"
138export HOME
139
140mkdir -p "$HOME"
141
44ce77ff 142guix-package --bootstrap -i guile-bootstrap
0ec1af59
LC
143test -L "$HOME/.guix-profile"
144test -f "$HOME/.guix-profile/bin/guile"
24e262f0 145
67668155
LC
146if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
147then
148 guix-package --bootstrap -i "$boot_make"
149 test -f "$HOME/.guix-profile/bin/make"
150 first_environment="`cd $HOME/.guix-profile ; pwd`"
151
152 guix-package --bootstrap --roll-back
153 test -f "$HOME/.guix-profile/bin/guile"
154 ! test -f "$HOME/.guix-profile/bin/make"
155 test "`cd $HOME/.guix-profile ; pwd`" = "$first_environment"
156fi
157
d9307267
LC
158# Move to the empty profile.
159default_profile="`readlink "$HOME/.guix-profile"`"
160for i in `seq 1 3`
161do
162 guix-package --bootstrap --roll-back
163 ! test -f "$HOME/.guix-profile/bin"
164 ! test -f "$HOME/.guix-profile/lib"
165 test "`readlink "$default_profile"`" = "$default_profile-0-link"
166done
3b9c0020
LC
167
168# Extraneous argument.
aa92cf98
LC
169if guix-package install foo-bar;
170then false; else true; fi