packages: 'modify-inputs' preserves outputs in 'replace' clauses.

Fixes <https://issues.guix.gnu.org/53915>.
Reported by Gordon Quad <gordon@niflheim.info>.

* guix/packages.scm (replace-input): Preserve the outputs of INPUT by
default.
* tests/packages.scm ("modify-inputs, replace, extra output"): New test.
This commit is contained in:
Ludovic Courtès 2022-03-15 15:17:49 +01:00
parent e3801126a9
commit 00dfff84c6
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 17 additions and 2 deletions

View file

@ -1091,11 +1091,11 @@ (define (replace-input name replacement inputs)
"Replace input NAME by REPLACEMENT within INPUTS." "Replace input NAME by REPLACEMENT within INPUTS."
(map (lambda (input) (map (lambda (input)
(match input (match input
(((? string? label) . _) (((? string? label) _ . outputs)
(if (string=? label name) (if (string=? label name)
(match replacement ;does REPLACEMENT specify an output? (match replacement ;does REPLACEMENT specify an output?
((_ _) (cons label replacement)) ((_ _) (cons label replacement))
(_ (list label replacement))) (_ (cons* label replacement outputs)))
input)))) input))))
inputs)) inputs))

View file

@ -1982,6 +1982,21 @@ (define (list->set* lst)
((("coreutils" input "out")) ((("coreutils" input "out"))
input)))) input))))
(test-eq "modify-inputs, replace, extra output"
guile-3.0
;; Replace an input; notice that its output is preserved.
;; See <https://issues.guix.gnu.org/53915>.
(let* ((p1 (dummy-package "p"
(inputs (list `(,coreutils "debug")))))
(p2 (package
(inherit p1)
(version "1")
(inputs (modify-inputs (package-inputs p1)
(replace "coreutils" guile-3.0))))))
(match (package-inputs p2)
((("coreutils" input "debug"))
input))))
(test-end "packages") (test-end "packages")
;;; Local Variables: ;;; Local Variables: