diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-12-13 15:58:57 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-12-13 16:17:00 -0700 |
commit | eda14d77dab39e05f69fef5fef2b5fb25482f215 (patch) | |
tree | 3cc600dd718b41d224ac2f0e7905145c53079185 | |
parent | 96363fc7741377ff40133c2656ebd93025a48a81 (diff) | |
download | consfigurator-eda14d77dab39e05f69fef5fef2b5fb25482f215.tar.gz |
rename combinator UNAPPLY->UNAPPLIED and add new UNAPPLY macro
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | doc/introduction.rst | 2 | ||||
-rw-r--r-- | doc/propspecs.rst | 4 | ||||
-rw-r--r-- | src/combinator.lisp | 13 | ||||
-rw-r--r-- | src/deployment.lisp | 2 | ||||
-rw-r--r-- | src/package.lisp | 1 | ||||
-rw-r--r-- | src/property/apache.lisp | 4 | ||||
-rw-r--r-- | src/property/cron.lisp | 4 | ||||
-rw-r--r-- | src/property/libvirt.lisp | 9 | ||||
-rw-r--r-- | src/property/sbuild.lisp | 4 |
9 files changed, 26 insertions, 17 deletions
diff --git a/doc/introduction.rst b/doc/introduction.rst index 45d6472..e1c3a0e 100644 --- a/doc/introduction.rst +++ b/doc/introduction.rst @@ -193,7 +193,7 @@ and/or lacks. For example,:: (eseqprops (apt:installed postfix) (etc-default:set "locale" "LANG" "en_GB.UTF-8") - (unapply (com.example.consfig.services:mail-satellite))) + (unapplied (com.example.consfig.services:mail-satellite))) Property application specifications are applied in order, so properties later in the list usually implicitly depend on properties earlier in the list, diff --git a/doc/propspecs.rst b/doc/propspecs.rst index 8d915b5..bec4e6e 100644 --- a/doc/propspecs.rst +++ b/doc/propspecs.rst @@ -118,8 +118,8 @@ Function. Applies each of the propapps passed as arguments, stopping and signalling a failed change if any of the propapps signal a failed change. Semantically, each propapp implicitly depends upon the preceding propapps. -``UNAPPLY`` -~~~~~~~~~~~ +``UNAPPLIED`` +~~~~~~~~~~~~~ Function. Unapplies a single propapp. diff --git a/src/combinator.lisp b/src/combinator.lisp index 088d3cd..aad9b99 100644 --- a/src/combinator.lisp +++ b/src/combinator.lisp @@ -230,12 +230,19 @@ apply the elements of REQUIREMENTS in reverse order." (post-apply "failed")) (setf (fill-pointer buffer) 0))))) -(define-function-property-combinator unapply (propapp) +(defmacro unapply (form) + "Where FORM is a programmatic application of a property (i.e. an application +of a property directly inside an :APPLY or :UNAPPLY subroutine), unapply the +property instead of applying it." + (destructuring-bind (property . args) form + `(consfigure `(unapplied (,',property ,,@args))))) + +(define-function-property-combinator unapplied (propapp) (destructuring-bind (psym . args) propapp (:retprop :type (proptype psym) :lambda (proplambda psym) :desc (lambda (&rest args) - (strcat "Unapply: " (apply #'propdesc psym args))) + (strcat "Unapplied: " (apply #'propdesc psym args))) :check (when-let ((check (get psym 'check))) (complement check)) :hostattrs (lambda (&rest args) @@ -353,7 +360,7 @@ an :UNAPPLY subroutine for a property which works by calling other properties." (:retprop :type (collapse-propapp-types apply (cdr unapply)) :hostattrs (lambda-ignoring-args (propappattrs apply-propapp) - ;; as in definition of UNAPPLY combinator + ;; as in definition of UNAPPLIED combinator (with-preserve-hostattrs (propappattrs unapply-propapp))) :apply (lambda-ignoring-args (propappapply apply-propapp)) diff --git a/src/deployment.lisp b/src/deployment.lisp index 097bb9b..0691564 100644 --- a/src/deployment.lisp +++ b/src/deployment.lisp @@ -76,7 +76,7 @@ preprocessed." "Immediately preprocess and apply PROPSPEC-EXPRESSION in the context of the current target host and connection. This function is provided for use by specialised property combinators. It should not be used in property -definitions nor in consfigs. +definitions nor in consfigs (except via the UNAPPLY macro). The :HOSTATTRS subroutines of properties applied by PROPSPEC-EXPRESSION will be executed, but any new hostattrs they push will be discarded. Thus either diff --git a/src/package.lisp b/src/package.lisp index c56de79..345d9d6 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -256,6 +256,7 @@ #:with-requirements #:silent-seqprops #:unapply + #:unapplied #:desc #:on-change #:on-apply-change diff --git a/src/property/apache.lisp b/src/property/apache.lisp index bced26c..757135e 100644 --- a/src/property/apache.lisp +++ b/src/property/apache.lisp @@ -145,5 +145,5 @@ restart Apache." ,agree-tos ,htdocs ,domain ,@aliases) (reloaded)) :unapply - (unapply (site-enabled ,domain)) - (unapply (site-available ,domain "")))) + (unapplied (site-enabled ,domain)) + (unapplied (site-available ,domain "")))) diff --git a/src/property/cron.lisp b/src/property/cron.lisp index 2b081dc..3a1343a 100644 --- a/src/property/cron.lisp +++ b/src/property/cron.lisp @@ -94,7 +94,7 @@ inconsistent situations. For example, suppose you and then later - (hostdeploy-these foo.example.org (unapply (additional-property)). + (hostdeploy-these foo.example.org (unapplied (additional-property)). As neither CRON:RUNS-CONFIGURATOR nor IMAGE-DUMPED with no arguments was applied since ADDITIONAL-PROPERTY was unapplied, the executable invoked by the @@ -110,7 +110,7 @@ of IMAGE-DUMPED." (nice-system-job "consfigurator" when "root" "${XDG_CACHE_HOME:-$HOME/.cache}/consfigurator/images/latest") - :unapply (unapply (system-job "consfigurator" when "" "")))) + :unapply (unapplied (system-job "consfigurator" when "" "")))) (defprop user-crontab :posix (env &rest jobs) "Set the contents of the current user's crontab. ENV is like the ENV argument diff --git a/src/property/libvirt.lisp b/src/property/libvirt.lisp index e7e5009..967d76c 100644 --- a/src/property/libvirt.lisp +++ b/src/property/libvirt.lisp @@ -303,10 +303,11 @@ your preferred VM networking setup and corresponding DEPLOYS propapp." ,@(and autostart `((started ,host))) :unapply (destroyed ,host*) - (unapply (defined ,host*)) - (unapply (with-flagfile ,flagfile - (chroot:os-bootstrapped-for - ,chroot-options ,chroot ,host ,additional-properties)))))) + (unapplied (defined ,host*)) + (unapplied + (with-flagfile ,flagfile + (chroot:os-bootstrapped-for + ,chroot-options ,chroot ,host ,additional-properties)))))) (defproplist kvm-boots-chroot :lisp (options properties) "Like LIBVIRT:KVM-BOOTS-CHROOT-FOR but define a new host using PROPERTIES." diff --git a/src/property/sbuild.lisp b/src/property/sbuild.lisp index da3828e..d5b90eb 100644 --- a/src/property/sbuild.lisp +++ b/src/property/sbuild.lisp @@ -77,7 +77,7 @@ Example usage: (sbuild:usable-by \"spwhitton\") (schroot:overlays-in-tmpfs) (periodic:at-most :monthly \"sbuild sid schroot rebuilt\" - (unapply (sbuild:built. nil (os:debian-unstable :amd64)))) + (unapplied (sbuild:built. nil (os:debian-unstable :amd64)))) (sbuild:built. nil (os:debian-unstable :amd64) (sbuild:standard-debian-schroot) @@ -183,7 +183,7 @@ EOF :mode #o755) ;; TODO We should kill any sessions still using the chroot before ;; destroying it (as suggested by sbuild-destroychroot(8)). :unapply - (unapply (chroot:os-bootstrapped-for ,chroot-options ,chroot ,host)) + (unapplied (chroot:os-bootstrapped-for ,chroot-options ,chroot ,host)) (file:does-not-exist ,conf)))) ;; Here we combine Propellor's Sbuild.osDebianStandard and Sbuild.update. |