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 | ||
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 | |
87 | ||
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" | |
92 | ||
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" | |
9241172c LC |
98 | |
99 | # Make a "hole" in the list of generations, and make sure we can | |
100 | # roll back "over" it. | |
101 | rm "$profile-4-link" | |
102 | guix-package --bootstrap -p "$profile" --roll-back | |
103 | test "`readlink_base "$profile"`" = "$profile-3-link" | |
ad1ebab3 | 104 | fi |
0afdc485 | 105 | |
9518856b | 106 | # Make sure the `:' syntax works. |
2a5ab9dc | 107 | guix-package --bootstrap -i "binutils:lib" -p "$profile" -n |
9518856b | 108 | |
64fc89b6 LC |
109 | # Check whether `--list-available' returns something sensible. |
110 | guix-package -A 'gui.*e' | grep guile | |
111 | ||
0ec1af59 LC |
112 | # Try with the default profile. |
113 | ||
114 | XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" | |
115 | export XDG_CACHE_HOME | |
116 | HOME="t-home-$$" | |
117 | export HOME | |
118 | ||
119 | mkdir -p "$HOME" | |
120 | ||
121 | guix-package --bootstrap -i "$boot_guile" | |
122 | test -L "$HOME/.guix-profile" | |
123 | test -f "$HOME/.guix-profile/bin/guile" | |
24e262f0 LC |
124 | |
125 | # Failed attempt to roll back. | |
126 | if guix-package --bootstrap --roll-back; | |
127 | then false; else true; fi |