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