diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2023-02-20 11:38:40 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2023-02-20 13:16:38 -0700 |
commit | 38c726b324bf13e1d1b9e7cc52d4cea108fe31ce (patch) | |
tree | 35f1e2047b48aa9a99d92c849db588faef1e1503 /src | |
parent | b66eb156bf0f7a4d1595e6fa7b46dda66db69790 (diff) | |
download | consfigurator-38c726b324bf13e1d1b9e7cc52d4cea108fe31ce.tar.gz |
add FILE:EMPTY-DIRECTORY-DOES-NOT-EXIST
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src')
-rw-r--r-- | src/package.lisp | 1 | ||||
-rw-r--r-- | src/property/file.lisp | 20 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/package.lisp b/src/package.lisp index 856d75a..6b72a1b 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -432,6 +432,7 @@ #:has-ownership #:does-not-exist #:directory-does-not-exist + #:empty-directory-does-not-exist #:data-uploaded #:host-data-uploaded #:secret-uploaded diff --git a/src/property/file.lisp b/src/property/file.lisp index 38c3780..251d8b0 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -1,6 +1,6 @@ ;;; Consfigurator -- Lisp declarative configuration management system -;;; Copyright (C) 2020-2022 Sean Whitton <spwhitton@spwhitton.name> +;;; Copyright (C) 2020-2023 Sean Whitton <spwhitton@spwhitton.name> ;;; This file is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by @@ -146,6 +146,24 @@ any of the regular expressions PATTERNS." (:check (not (apply #'remote-exists-p directories))) (:apply (mrun "rm" "-rf" directories))) +(defprop empty-directory-does-not-exist :posix (&rest directories) + "Ensure that none of DIRECTORIES exist as empty directories." + (:desc #?"@{directories} removed if empty") + (:apply + (aif (runlines + :input (unlines directories) + #.(sh-script-to-single-line + "set -e; while read -r dir; do + if [ -d \"$dir\" ]; then + ( cd \"$dir\" + if [ -z \"$(find . ! -name . -print -prune)\" ]; then + echo \"$dir\" + fi ) + fi + done")) + (mrun "rmdir" it) + :no-change))) + (defprop data-uploaded :posix (iden1 iden2 destination) (:desc #?"${destination} installed") (:hostattrs |