1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
4 # This file is part of GNU Guix.
6 # GNU Guix is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or (at
9 # your option) any later version.
11 # GNU Guix is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 # Test the `guix-package' command-line utility.
23 guix-package
--version
27 basename `readlink "$1"`
30 profile
="t-profile-$$"
33 trap 'rm "$profile" "$profile-"[0-9]* ; rm -rf t-home-'"$$" EXIT
35 boot_guile
="`guix-build -e '(@ (gnu packages bootstrap) %bootstrap-guile)'`"
37 guix-package
--bootstrap -p "$profile" -i "$boot_guile"
38 test -L "$profile" && test -L "$profile-1-link"
39 test -f "$profile/bin/guile"
41 # Installing the same package a second time does nothing.
42 guix-package
--bootstrap -p "$profile" -i "$boot_guile"
43 test -L "$profile" && test -L "$profile-1-link"
44 ! test -f "$profile-2-link"
45 test -f "$profile/bin/guile"
47 # Check whether we have network access.
48 if guile
-c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev
/null
50 boot_make
="`guix-build -e '(@@ (gnu packages base) gnu-make-boot0)'`"
51 guix-package
--bootstrap -p "$profile" -i "$boot_make"
52 test -L "$profile-2-link"
53 test -f "$profile/bin/make" && test -f "$profile/bin/guile"
56 # Check whether `--list-installed' works.
57 # XXX: Change the tests when `--install' properly extracts the package
58 # name and version string.
59 installed
="`guix-package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
61 "guile-bootstrap make-boot0")
63 "make-boot0 guile-bootstrap")
69 test "`guix-package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
72 guix-package
--bootstrap -p "$profile" -r "guile-bootstrap"
73 test -L "$profile-3-link"
74 test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
77 guix-package
--roll-back -p "$profile"
78 test "`readlink_base "$profile"`" = "$profile-2-link"
79 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
80 guix-package
--roll-back -p "$profile"
81 test "`readlink_base "$profile"`" = "$profile-1-link"
82 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
84 # Failed attempt to roll back because there's no previous generation.
85 if guix-package
--roll-back -p "$profile";
86 then false
; else true
; fi
88 # Reinstall after roll-back to generation 1.
89 guix-package
--bootstrap -p "$profile" -i "$boot_make"
90 test "`readlink_base "$profile"`" = "$profile-4-link"
91 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
93 # Roll-back to generation 3[*], and install---all at once.
94 # [*] FIXME: Eventually, this should roll-back to generation 1.
95 guix-package
--bootstrap -p "$profile" --roll-back -i "$boot_guile"
96 test "`readlink_base "$profile"`" = "$profile-5-link"
97 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
99 # Make a "hole" in the list of generations, and make sure we can
100 # roll back "over" it.
102 guix-package
--bootstrap -p "$profile" --roll-back
103 test "`readlink_base "$profile"`" = "$profile-3-link"
106 # Make sure the `:' syntax works.
107 guix-package
--bootstrap -i "binutils:lib" -p "$profile" -n
109 # Check whether `--list-available' returns something sensible.
110 guix-package
-A 'gui.*e' |
grep guile
113 # Try with the default profile.
116 XDG_CACHE_HOME
="${XDG_CACHE_HOME:-$HOME/.cache}"
117 export XDG_CACHE_HOME
123 guix-package
--bootstrap -i "$boot_guile"
124 test -L "$HOME/.guix-profile"
125 test -f "$HOME/.guix-profile/bin/guile"
127 if guile
-c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev
/null
129 guix-package
--bootstrap -i "$boot_make"
130 test -f "$HOME/.guix-profile/bin/make"
131 first_environment
="`cd $HOME/.guix-profile ; pwd`"
133 guix-package
--bootstrap --roll-back
134 test -f "$HOME/.guix-profile/bin/guile"
135 ! test -f "$HOME/.guix-profile/bin/make"
136 test "`cd $HOME/.guix-profile ; pwd`" = "$first_environment"
139 # Failed attempt to roll back.
140 if guix-package
--bootstrap --roll-back;
141 then false
; else true
; fi
143 # Extraneous argument.
144 ! guix-package
install foo-bar