aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/package.lisp1
-rw-r--r--src/property/container.lisp13
2 files changed, 8 insertions, 6 deletions
diff --git a/src/package.lisp b/src/package.lisp
index 5cf6c55..048877e 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -469,6 +469,7 @@
(package :consfigurator.property.container
(:export #:contained
+ #:contained-p
#:when-contained))
(package :consfigurator.property.periodic
diff --git a/src/property/container.lisp b/src/property/container.lisp
index a269b91..042dd69 100644
--- a/src/property/container.lisp
+++ b/src/property/container.lisp
@@ -41,6 +41,12 @@ CHROOT:OS-BOOTSTRAPPED, rather than being added to DEFHOST forms."
contained))
(:hostattrs (push-hostattrs 'iscontained contained)))
+(defun contained-p (&rest contained)
+ "Return non-nil if we are outside of any container, or when each of CONTAINED,
+a list of symbols, is contained by this container type."
+ (alet (get-hostattrs 'iscontained)
+ (or (not it) (loop for factor in contained always (member factor it)))))
+
(defmacro when-contained ((&rest contained) &body propapps)
"Macro property combinator. Apply each of PROPAPPS only when outside of any
container, or when each of CONTAINED, a list of symbols, is contained by this
@@ -51,12 +57,7 @@ container type."
(define-function-property-combinator when-contained* (contained propapp)
(macrolet ((check-contained (form)
- `(let ((host-contained (get-hostattrs 'iscontained)))
- (if (or (not host-contained)
- (loop for factor in contained
- always (member factor host-contained)))
- ,form
- :no-change))))
+ `(if (apply #'contained-p contained) ,form :no-change)))
(:retprop :type (propapp-type propapp)
:hostattrs (lambda-ignoring-args
(propapp-attrs propapp))