summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-06-26 22:23:11 +0200
committerLudovic Courtès <ludo@gnu.org>2017-06-26 22:52:06 +0200
commit6d382339de1c9fbe20ec056fb5200d5724a4aa44 (patch)
tree34f20217c6d9c09649bfb4a512d29925968d4699
parent94a400bebae48aebc35fb84aa0b134b25ce46e46 (diff)
downloadpatches-6d382339de1c9fbe20ec056fb5200d5724a4aa44.tar
patches-6d382339de1c9fbe20ec056fb5200d5724a4aa44.tar.gz
profiles: Add 'manifest-transaction-removal-candidate?'.
* guix/profiles.scm (manifest-transaction-removal-candidate?): New procedure. * tests/profiles.scm ("manifest-transaction-removal-candidate?"): New test.
-rw-r--r--guix/profiles.scm7
-rw-r--r--tests/profiles.scm7
2 files changed, 14 insertions, 0 deletions
diff --git a/guix/profiles.scm b/guix/profiles.scm
index dcb5186c7a..056406e303 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -96,6 +96,7 @@
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 @@ remove software."
(($ <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
diff --git a/tests/profiles.scm b/tests/profiles.scm
index f731807e8c..469dde2652 100644
--- a/tests/profiles.scm
+++ b/tests/profiles.scm
@@ -197,6 +197,13 @@
(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))