profiles: Add 'manifest-transaction-removal-candidate?'.

* guix/profiles.scm (manifest-transaction-removal-candidate?): New
procedure.
* tests/profiles.scm ("manifest-transaction-removal-candidate?"): New
test.
This commit is contained in:
Ludovic Courtès 2017-06-26 22:23:11 +02:00
parent 94a400beba
commit 6d382339de
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 14 additions and 0 deletions

View file

@ -96,6 +96,7 @@ (define-module (guix profiles)
manifest-transaction-install-entry
manifest-transaction-remove-pattern
manifest-transaction-null?
manifest-transaction-removal-candidate?
manifest-perform-transaction
manifest-transaction-effects
@ -564,6 +565,12 @@ (define (manifest-transaction-null? transaction)
(($ <manifest-transaction> () ()) #t)
(($ <manifest-transaction> _ _) #f)))
(define (manifest-transaction-removal-candidate? entry transaction)
"Return true if ENTRY is a candidate for removal in TRANSACTION."
(any (lambda (pattern)
((entry-predicate pattern) entry))
(manifest-transaction-remove transaction)))
(define (manifest-transaction-effects manifest transaction)
"Compute the effect of applying TRANSACTION to MANIFEST. Return 4 values:
the list of packages that would be removed, installed, upgraded, or downgraded

View file

@ -197,6 +197,13 @@ (define glibc
(test-assert "manifest-transaction-null?"
(manifest-transaction-null? (manifest-transaction)))
(test-assert "manifest-transaction-removal-candidate?"
(let ((m (manifest (list guile-2.0.9)))
(t (manifest-transaction
(remove (list (manifest-pattern (name "guile")))))))
(and (manifest-transaction-removal-candidate? guile-2.0.9 t)
(not (manifest-transaction-removal-candidate? glibc t)))))
(test-assertm "profile-derivation"
(mlet* %store-monad
((entry -> (package->manifest-entry %bootstrap-guile))