commit 96fb123832b262a3453fe1b7646758da235a343e Author: Ricardo Wurmus Date: Tue Jan 3 10:14:52 2023 +0100 WIP diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index e0b94ce48d..bbda2df35a 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -183,9 +183,9 @@ (define (show-help) (newline) (show-bug-report-information)) -(define (options->update-specs opts) - "Return the list of packages requested by OPTS, honoring options like -'--recursive'." +(define (options->packages+update-specs opts) + "Return the list of packages and update-specs requested by OPTS, honoring +options like '--recursive'." (define core-package? (let* ((input->package (match-lambda ((name (? package? package) _ ...) package) @@ -220,7 +220,7 @@ (define (keep-newest package lst) (_ (cons package lst))))) - (define args-packages + (define args-packages+update-specs ;; Packages explicitly passed as command-line arguments. (match (filter-map (match-lambda (('argument . spec) @@ -244,17 +244,18 @@ (define args-packages (some ;user-specified packages some))) - (define packages + (define packages+update-specs (match (assoc-ref opts 'manifest) - (#f args-packages) + (#f args-packages+update-specs) ((? string? file) (packages-from-manifest file)))) (if (assoc-ref opts 'recursive?) - (mlet %store-monad ((edges (node-edges %bag-node-type - (all-packages)))) - (return (node-transitive-edges packages edges))) + (let ((packages update-specs (partition package? packages+update-specs))) + (mlet %store-monad ((edges (node-edges %bag-node-type + (all-packages)))) + (return (append (node-transitive-edges packages edges) update-specs)))) (with-monad %store-monad - (return packages)))) + (return packages+update-specs)))) ;;; @@ -561,35 +562,45 @@ (define (options->updaters opts) (with-error-handling (with-store store (run-with-store store - (mlet %store-monad ((update-specs (options->update-specs opts))) - (cond - (list-dependent? - (list-dependents (map update-spec-package update-specs))) - (list-transitive? - (list-transitive (map update-spec-package update-specs))) - (update? - (parameterize ((%openpgp-key-server - (or (assoc-ref opts 'key-server) - (%openpgp-key-server))) - (%gpg-command - (or (assoc-ref opts 'gpg-command) - (%gpg-command))) - (current-keyring - (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-download key-download - #:warn? warn?)) - update-specs) - (return #t))) - (else - (for-each (cut check-for-package-update <> updaters - #:warn? warn?) - (map update-spec-package update-specs)) - (return #t))))))))) + (mlet %store-monad ((packages+update-specs (options->packages+update-specs opts))) + (let ((packages update-specs (partition package? packages+update-specs))) + (cond + (list-dependent? + (list-dependents (append packages (map update-spec-package update-specs)))) + (list-transitive? + (list-transitive (append packages (map update-spec-package update-specs)))) + (update? + (parameterize ((%openpgp-key-server + (or (assoc-ref opts 'key-server) + (%openpgp-key-server))) + (%gpg-command + (or (assoc-ref opts 'gpg-command) + (%gpg-command))) + (current-keyring + (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-download key-download + #:warn? warn?)) + update-specs) + (for-each + (lambda (package) + (update-package store + package + #false + updaters + #:key-download key-download + #:warn? warn?)) + packages) + (return #t))) + (else + (for-each (cut check-for-package-update <> updaters + #:warn? warn?) + (append packages (map update-spec-package update-specs))) + (return #t))))))))))