gtk and wayland update
[jackhill/guix/guix.git] / tests / guix-refresh.sh
1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
3 #
4 # This file is part of GNU Guix.
5 #
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.
10 #
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.
15 #
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/>.
18
19 #
20 # Test the 'guix refresh' command-line utility.
21 #
22
23 guix refresh --version
24
25 manifest="t-guix-refresh-manifest-$$.scm"
26 module_dir="t-guix-refresh-modules-$$"
27 trap 'rm -f "$manifest"; rm -rf "$module_dir"' EXIT
28
29 # Tell the 'test' updater what to simulate.
30 export GUIX_TEST_UPDATER_TARGETS
31 idutils_version="$(guix package -A ^idutils$ | cut -f2)"
32 GUIX_TEST_UPDATER_TARGETS='
33 (("guile" "3" (("12.5" "file:///dev/null")
34 ("1.6.4" "file:///dev/null")))
35 ("libreoffice" "" (("1.0" "file:///dev/null")))
36 ("idutils" "" (("'$idutils_version'" "file:///dev/null")))
37 ("the-test-package" "" (("5.5" "file://'$PWD/$module_dir'/source"))))'
38
39 # No newer version available.
40 ! guix refresh -t test idutils
41 case "$(guix refresh -t test idutils 2>&1)" in
42 *"$idutils_version"*"already the latest version"*) true;;
43 *) false;;
44 esac
45 ! guix refresh -t test libreoffice
46 case "$(guix refresh -t test libreoffice 2>&1)" in
47 *"greater than the latest known version"*"1.0"*) true;;
48 *) false;;
49 esac
50
51 # Various ways to specify packages.
52 cat > "$manifest" <<EOF
53 (specifications->manifest (list "guile@3.0"))
54 EOF
55 default_IFS="$IFS"
56 IFS=_
57 for spec in "guile" \
58 "guile@3.0" \
59 "-e_(@ (gnu packages guile) guile-3.0)" \
60 "-m_$manifest" \
61 "-r_guile" \
62 "-s_core"
63 do
64 guix refresh -t test $spec
65 case "$(guix refresh -t test $spec 2>&1)" in
66 *"would be upgraded"*"12.5"*)
67 true;;
68 *)
69 false;;
70 esac
71 done
72 IFS="$default_IFS"
73
74 # Actually updating.
75 mkdir "$module_dir"
76 echo hello > "$module_dir/source"
77 cat > "$module_dir/sample.scm"<<EOF
78 (define-module (sample)
79 #:use-module (guix packages)
80 #:use-module (guix download)
81 #:use-module (gnu packages base))
82
83 (define-public my-thing
84 (package
85 (inherit hello)
86 (name "the-test-package")
87 (version "4.3")
88 (source (origin
89 (method url-fetch)
90 (uri (string-append "mirror://gnu/hello/hello-" version
91 ".tar.gz"))
92 (sha256
93 (base32
94 "086vqwk2wl8zfs47sq2xpjc9k066ilmb8z6dn0q6ymwjzlm196cd"))))))
95 EOF
96 guix refresh -t test -L "$module_dir" the-test-package
97 guix refresh -t test -L "$module_dir" the-test-package -u \
98 --keyring="$module_dir/keyring.kbx" # so we don't create $HOME/.config
99 grep 'version "5.5"' "$module_dir/sample.scm"
100 grep "$(guix hash -H sha256 -f nix-base32 "$module_dir/source")" "$module_dir/sample.scm"
101
102 # Specifying a target version.
103 ! guix refresh -t test guile=2.0.0
104 case "$(guix refresh -t test guile=2.0.0 2>&1)" in
105 *"failed to find"*"2.0.0"*) true;;
106 *) false;;
107 esac
108 for spec in "guile=1.6.4" "guile@3=1.6.4"
109 do
110 guix refresh -t test "$spec"
111 case "$(guix refresh -t test "$spec" 2>&1)" in
112 *"would be downgraded"*"1.6.4"*) true;;
113 *) false;;
114 esac
115 done
116
117 # Listing updaters. This should work whether or not networking is available.
118 guix refresh --list-updaters