diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-29 16:04:41 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-30 10:05:00 -0700 |
commit | 83315fc895efe7a5253974a0ad38d360c208c511 (patch) | |
tree | bb2d1b8a9908766ba0dc938fd2a50c89fcc8f392 /src/combinator.lisp | |
parent | cdbde348be913d3f08b73c7f585077b0e180e849 (diff) | |
download | consfigurator-83315fc895efe7a5253974a0ad38d360c208c511.tar.gz |
add WITH-FLAGFILE
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/combinator.lisp')
-rw-r--r-- | src/combinator.lisp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/combinator.lisp b/src/combinator.lisp index 2101132..892d9c8 100644 --- a/src/combinator.lisp +++ b/src/combinator.lisp @@ -219,3 +219,29 @@ affect /root and not /home." (if (and (stringp user) (string= user "root")) `(eseqprops ,@properties) `(reconnects. `((:as :to ,,user)) ,@properties))) + +(defmacro with-flagfile (flagfile &body propapps) + "Apply PROPAPPS unless FLAGFILE exists on the remote; after applying, create +FLAGFILE. +Useful to ensure that something is done just once. Has the semantics that if +FLAGFILE exists, PROPAPPS are assumed to all be already applied." + `(with-flagfile* + ,flagfile + ,(if (cdr propapps) `(eseqprops ,@propapps) (car propapps)))) + +(define-function-property-combinator with-flagfile* (flagfile propapp) + (:retprop :type (propapptype propapp) + :desc (get (car propapp) 'desc) + :hostattrs (get (car propapp) 'hostattrs) + :check (lambda (&rest ignore) + (declare (ignore ignore)) + (remote-exists-p flagfile)) + :apply (lambda (&rest ignore) + (declare (ignore ignore)) + (prog1 (propappapply propapp) + (mrun "touch" flagfile))) + :unapply (lambda (&rest ignore) + (declare (ignore ignore)) + (prog1 (propappunapply propapp) + (mrun "rm" flagfile))) + :args (cdr propapp))) |