1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2023 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 refresh' command-line utility.
23 guix refresh
--version
25 manifest
="t-guix-refresh-manifest-$$.scm"
26 module_dir
="t-guix-refresh-modules-$$"
27 trap 'rm -f "$manifest"; rm -rf "$module_dir"' EXIT
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"))))'
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
;;
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
;;
51 # Various ways to specify packages.
52 cat > "$manifest" <<EOF
53 (specifications->manifest (list "guile@3.0"))
59 "-e_(@ (gnu packages guile) guile-3.0)" \
64 guix refresh
-t test $spec
65 case "$(guix refresh -t test $spec 2>&1)" in
66 *"would be upgraded"*"12.5"*)
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))
83 (define-public my-thing
86 (name "the-test-package")
90 (uri (string-append "mirror://gnu/hello/hello-" version
94 "086vqwk2wl8zfs47sq2xpjc9k066ilmb8z6dn0q6ymwjzlm196cd"))))))
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"
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
;;
108 for spec
in "guile=1.6.4" "guile@3=1.6.4"
110 guix refresh
-t test "$spec"
111 case "$(guix refresh -t test "$spec" 2>&1)" in
112 *"would be downgraded"*"1.6.4"*) true
;;
117 # Listing updaters. This should work whether or not networking is available.
118 guix refresh
--list-updaters