package: Honor '--dry-run' when target profile is already in store.
Fixes <https://issues.guix.gnu.org/53267>. Reported by Tirifto <tirifto@posteo.cz>. Regression introduced in65ffb9388c
. In the (unlikely) case where the profile we're targeting with "guix upgrade -n" or similar is already built, a new profile generation would be created and linked to despite the use of '-n'. This is because65ffb9388c
assumed that dry-run behavior would be handled solely by the build handler, which is not the case when there's nothing to build. * guix/scripts/package.scm (build-and-use-profile): Reintroduce #:dry-run? and honor it. (process-actions): Pass #:dry-run? to 'build-and-use-profile'. * tests/guix-package-net.sh: Add test.
parent
09676b7c11
commit
ccda88a070
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
||||||
;;; Copyright © 2013, 2015 Mark H Weaver <mhw@netris.org>
|
;;; Copyright © 2013, 2015 Mark H Weaver <mhw@netris.org>
|
||||||
;;; Copyright © 2014, 2016 Alex Kost <alezost@gmail.com>
|
;;; Copyright © 2014, 2016 Alex Kost <alezost@gmail.com>
|
||||||
|
@ -139,6 +139,7 @@ denote ranges as interpreted by 'matching-generations'."
|
||||||
|
|
||||||
(define* (build-and-use-profile store profile manifest
|
(define* (build-and-use-profile store profile manifest
|
||||||
#:key
|
#:key
|
||||||
|
dry-run?
|
||||||
(hooks %default-profile-hooks)
|
(hooks %default-profile-hooks)
|
||||||
allow-collisions?
|
allow-collisions?
|
||||||
bootstrap?)
|
bootstrap?)
|
||||||
|
@ -154,6 +155,7 @@ hooks\" run when building the profile."
|
||||||
(prof (derivation->output-path prof-drv)))
|
(prof (derivation->output-path prof-drv)))
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
|
(dry-run? #t)
|
||||||
((and (file-exists? profile)
|
((and (file-exists? profile)
|
||||||
(and=> (readlink* profile) (cut string=? prof <>)))
|
(and=> (readlink* profile) (cut string=? prof <>)))
|
||||||
(format (current-error-port) (G_ "nothing to be done~%")))
|
(format (current-error-port) (G_ "nothing to be done~%")))
|
||||||
|
@ -1069,6 +1071,7 @@ processed, #f otherwise."
|
||||||
trans
|
trans
|
||||||
#:dry-run? dry-run?)
|
#:dry-run? dry-run?)
|
||||||
(build-and-use-profile store profile new
|
(build-and-use-profile store profile new
|
||||||
|
#:dry-run? dry-run?
|
||||||
#:allow-collisions? allow-collisions?
|
#:allow-collisions? allow-collisions?
|
||||||
#:bootstrap? bootstrap?)))))
|
#:bootstrap? bootstrap?)))))
|
||||||
|
|
||||||
|
|
|
@ -196,6 +196,16 @@ EOF
|
||||||
guix package --bootstrap -p "$profile" -i gcc-bootstrap
|
guix package --bootstrap -p "$profile" -i gcc-bootstrap
|
||||||
installed="`guix package -p "$profile" -I | cut -f1`"
|
installed="`guix package -p "$profile" -I | cut -f1`"
|
||||||
|
|
||||||
|
# Dry-run upgrade. Make sure no new generation is created when things are
|
||||||
|
# already in store and '-n' is used: <https://issues.guix.gnu.org/53267>.
|
||||||
|
V_MINOR=0
|
||||||
|
export V_MINOR
|
||||||
|
profile_before="$(readlink "$profile")"
|
||||||
|
guix package -p "$profile" --bootstrap -L "$module_dir" -u # build the profile
|
||||||
|
guix package -p "$profile" --roll-back
|
||||||
|
guix package -p "$profile" --bootstrap -L "$module_dir" -u . -n # check '-n'
|
||||||
|
test "$(readlink "$profile")" = "$profile_before"
|
||||||
|
|
||||||
for i in 1 2
|
for i in 1 2
|
||||||
do
|
do
|
||||||
V_MINOR="$i"
|
V_MINOR="$i"
|
||||||
|
|
Reference in New Issue