diff options
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 |