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 @@
manifest-transaction-install-entry manifest-transaction-install-entry
manifest-transaction-remove-pattern manifest-transaction-remove-pattern
manifest-transaction-null? manifest-transaction-null?
manifest-transaction-removal-candidate?
manifest-perform-transaction manifest-perform-transaction
manifest-transaction-effects manifest-transaction-effects
@ -564,6 +565,12 @@ remove software."
(($ <manifest-transaction> () ()) #t) (($ <manifest-transaction> () ()) #t)
(($ <manifest-transaction> _ _) #f))) (($ <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) (define (manifest-transaction-effects manifest transaction)
"Compute the effect of applying TRANSACTION to MANIFEST. Return 4 values: "Compute the effect of applying TRANSACTION to MANIFEST. Return 4 values:
the list of packages that would be removed, installed, upgraded, or downgraded the list of packages that would be removed, installed, upgraded, or downgraded

View File

@ -197,6 +197,13 @@
(test-assert "manifest-transaction-null?" (test-assert "manifest-transaction-null?"
(manifest-transaction-null? (manifest-transaction))) (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" (test-assertm "profile-derivation"
(mlet* %store-monad (mlet* %store-monad
((entry -> (package->manifest-entry %bootstrap-guile)) ((entry -> (package->manifest-entry %bootstrap-guile))