profiles: Raise an error for unmatched patterns.

Previously, "guix package -r something-not-installed" would silently
complete.  Now an error is raised.

* guix/profiles.scm (&unmatched-pattern-error): New condition type.
(manifest-matching-entries): Rewrite to raise an error when one of
PATTERNS is not matched.
* guix/ui.scm (call-with-error-handling): Handle 'unmatched-pattern-error?'.
* tests/guix-package.sh: Add test.
* tests/profiles.scm ("manifest-matching-entries"): Don't try to remove
unmatched pattern.
("manifest-matching-entries, no match"): New test.
("manifest-transaction-effects"): Remove 'remove' field.
This commit is contained in:
Ludovic Courtès 2019-02-07 14:54:43 +01:00 committed by Ludovic Courtès
parent 89ea6252b6
commit 487cbb0164
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
4 changed files with 49 additions and 17 deletions

View file

@ -643,6 +643,14 @@ or remove one of them from the profile.")
(leave (G_ "generation ~a of profile '~a' does not exist~%")
(missing-generation-error-generation c)
(profile-error-profile c)))
((unmatched-pattern-error? c)
(let ((pattern (unmatched-pattern-error-pattern c)))
(leave (G_ "package '~a~@[@~a~]~@[:~a~]' not found in profile~%")
(manifest-pattern-name pattern)
(manifest-pattern-version pattern)
(match (manifest-pattern-output pattern)
("out" #f)
(output output)))))
((profile-collision-error? c)
(let ((entry (profile-collision-error-entry c))
(conflict (profile-collision-error-conflict c)))