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
29 basename `readlink "$1"`
32 # Return true if a typical shebang in the store would exceed Linux's default
36 test `echo $NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash | wc -c` \
40 profile
="t-profile-$$"
43 trap 'rm -f "$profile" "$profile-"[0-9]* ; rm -rf t-home-'"$$" EXIT
46 guix package
--bootstrap -p "$profile" -i guile-bootstrap
47 test -L "$profile" && test -L "$profile-1-link"
48 ! test -f "$profile-2-link"
49 test -f "$profile/bin/guile"
51 boot_make
="(@@ (gnu packages commencement) gnu-make-boot0)"
52 boot_make_drv
="`guix build -e "$boot_make" | grep -v -e -debug`"
53 guix package
--bootstrap -p "$profile" -i "$boot_make_drv"
54 test -L "$profile-2-link"
55 test -f "$profile/bin/make" && test -f "$profile/bin/guile"
57 # Check whether `--list-installed' works.
58 # XXX: Change the tests when `--install' properly extracts the package
59 # name and version string.
60 installed
="`guix package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
62 "guile-bootstrap make-boot0")
64 "make-boot0 guile-bootstrap")
70 test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
73 test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
76 # Exit with 1 when a generation does not exist.
77 if guix package
-p "$profile" --list-generations=42;
78 then false
; else true
; fi
79 if guix package
-p "$profile" --switch-generation=99;
80 then false
; else true
; fi
83 guix package
--bootstrap -p "$profile" -r "guile-bootstrap"
84 test -L "$profile-3-link"
85 test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
88 guix package
--roll-back -p "$profile"
89 test "`readlink_base "$profile"`" = "$profile-2-link"
90 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
91 guix package
--roll-back -p "$profile"
92 test "`readlink_base "$profile"`" = "$profile-1-link"
93 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
95 # Switch to the rolled generation and switch back.
96 guix package
-p "$profile" --switch-generation=2
97 test "`readlink_base "$profile"`" = "$profile-2-link"
98 guix package
-p "$profile" --switch-generation=-1
99 test "`readlink_base "$profile"`" = "$profile-1-link"
101 # Move to the empty profile.
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"
110 # Test that '--list-generations' does not output the zeroth generation.
111 test -z "`guix package -p "$profile" -l 0`"
113 # Reinstall after roll-back to the empty profile.
114 guix package
--bootstrap -p "$profile" -e "$boot_make"
115 test "`readlink_base "$profile"`" = "$profile-1-link"
116 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
118 # Check that the first generation is the current one.
119 test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)"
121 # Roll-back to generation 0, and install---all at once.
122 guix package
--bootstrap -p "$profile" --roll-back -i guile-bootstrap
123 test "`readlink_base "$profile"`" = "$profile-1-link"
124 test -x "$profile/bin/guile" && ! test -x "$profile/bin/make"
127 guix package
--bootstrap -p "$profile" -e "$boot_make"
128 test "`readlink_base "$profile"`" = "$profile-2-link"
129 test -x "$profile/bin/guile" && test -x "$profile/bin/make"
130 grep "`guix build -e "$boot_make"`" "$profile/manifest"
132 # Make a "hole" in the list of generations, and make sure we can
133 # roll back and switch "over" it.
135 guix package
--bootstrap -p "$profile" --roll-back
136 test "`readlink_base "$profile"`" = "$profile-0-link"
137 guix package
-p "$profile" --switch-generation=+1
138 test "`readlink_base "$profile"`" = "$profile-2-link"
140 # Make sure LIBRARY_PATH gets listed by `--search-paths'.
141 guix package
--bootstrap -p "$profile" -i guile-bootstrap
-i gcc-bootstrap
142 guix package
--search-paths -p "$profile" |
grep LIBRARY_PATH
144 # Roll back so we can delete #3 below.
145 guix package
-p "$profile" --switch-generation=2
147 # Delete the third generation and check that it was actually deleted.
148 guix package
-p "$profile" --delete-generations=3
149 test -z "`guix package -p "$profile" -l 3`"
153 # Try with the default profile.
156 XDG_CACHE_HOME
="${XDG_CACHE_HOME:-$HOME/.cache}"
157 export XDG_CACHE_HOME
158 HOME
="$PWD/t-home-$$"
163 # Get the canonical directory name so that 'guix package' recognizes it.
164 HOME
="`cd $HOME; pwd -P`"
166 guix package
--bootstrap -e "$boot_make"
167 test -f "$HOME/.guix-profile/bin/make"
169 guix package
--bootstrap --roll-back
170 ! test -f "$HOME/.guix-profile/bin/make"