From b43841c124d15eaecc41b3928f08a26dbd5c653a Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Mon, 10 Jul 2023 20:37:55 +0200 Subject: refresh: Sort update specs by package location. Fixes . * guix/scripts/refresh.scm (guix-refresh): Sort update specs by location from bottom to top before updating packages. --- guix/scripts/refresh.scm | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'guix/scripts/refresh.scm') diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index 9676271542..f5cb18af22 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -6,7 +6,7 @@ ;;; Copyright © 2016 Ben Woodcroft ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2018 Efraim Flashner -;;; Copyright © 2019 Ricardo Wurmus +;;; Copyright © 2019, 2023 Ricardo Wurmus ;;; Copyright © 2020 Simon Tournier ;;; Copyright © 2021 Sarah Morgensen ;;; Copyright © 2022 Hartmut Goebel @@ -589,16 +589,27 @@ (define (options->updaters opts) (or (assoc-ref opts 'keyring) (string-append (config-directory) "/upstream/trustedkeys.kbx")))) - (for-each - (lambda (update) - (update-package store - (update-spec-package update) - (update-spec-version update) - updaters - #:key-server (%openpgp-key-server) - #:key-download key-download - #:warn? warn?)) - update-specs) + (let* ((spec-line + (compose location->string + package-location + update-spec-package)) + ;; Sort the specs so that we update packages from the + ;; bottom of the file to the top. This way we can be + ;; sure that the package locations are always correct + ;; and never shifted due to previous edits. + (sorted-update-specs + (sort update-specs + (lambda (a b) (string> (spec-line a) (spec-line b)))))) + (for-each + (lambda (update) + (update-package store + (update-spec-package update) + (update-spec-version update) + updaters + #:key-server (%openpgp-key-server) + #:key-download key-download + #:warn? warn?)) + sorted-update-specs)) (return #t))) (else (for-each (cut check-for-package-update <> updaters -- cgit v1.2.3