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 @@ otherwise."
"Replace input NAME by REPLACEMENT within INPUTS."
(map (lambda (input)
(match input
(((? string? label) . _)
(((? string? label) _ . outputs)
(if (string=? label name)
(match replacement ;does REPLACEMENT specify an output?
((_ _) (cons label replacement))
(_ (list label replacement)))
(_ (cons* label replacement outputs)))
input))))
inputs))

View File

@ -1982,6 +1982,21 @@
((("coreutils" input "out"))
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")
;;; Local Variables: