aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-04-08 13:27:23 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-04-08 13:28:53 -0700
commit16911629aa955fc69405de5c3fc2b818897f3e03 (patch)
treef5ac3d3a5952b79b39d634b8a80a5b7f697609ee /src
parenteb8298b38d24d9dd73ffc073d064b879d2159dfc (diff)
downloadconsfigurator-16911629aa955fc69405de5c3fc2b818897f3e03.tar.gz
FILE:HAS-CONTENT: don't return :NO-CHANGE if file mode was changed
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src')
-rw-r--r--src/package.lisp1
-rw-r--r--src/property.lisp12
-rw-r--r--src/property/file.lisp2
3 files changed, 14 insertions, 1 deletions
diff --git a/src/package.lisp b/src/package.lisp
index 345f928..4c8e442 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -136,6 +136,7 @@
#:call-with-os
#:with-change-if-changes-file
#:with-change-if-changes-file-content
+ #:with-change-if-changes-file-content-or-mode
;; propspec.lisp
#:in-consfig
diff --git a/src/property.lisp b/src/property.lisp
index a223ff8..8246af5 100644
--- a/src/property.lisp
+++ b/src/property.lisp
@@ -527,3 +527,15 @@ changes in properties which will change the file but not the output of `ls
(result (progn ,@forms)))
(if (and ,before (eql ,before (cksum ,file)))
:no-change result))))
+
+(defmacro with-change-if-changes-file-content-or-mode ((file) &body forms)
+ "Execute FORMS and yield :NO-CHANGE if FILE has the same content and mode
+afterwards."
+ (with-gensyms (before)
+ `(let* ((,before (ls-cksum ,file))
+ (result (progn ,@forms)))
+ (let ((after (ls-cksum ,file)))
+ (if (and ,before
+ (string= (car ,before) (car after) :start1 1 :start2 1)
+ (eql (cadr ,before) (cadr after)))
+ :no-change result)))))
diff --git a/src/property/file.lisp b/src/property/file.lisp
index aaa3944..e42df20 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -35,7 +35,7 @@ CONTENT can be a list of lines or a single string."
(declare (indent 1))
(:desc (declare (ignore content mode mode-supplied-p))
#?"${path} has defined content")
- (:apply (with-change-if-changes-file-content (path)
+ (:apply (with-change-if-changes-file-content-or-mode (path)
(let ((args (list path
(etypecase content
(cons (unlines content))