aboutsummaryrefslogtreecommitdiff
path: root/src/property/file.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-04-08 15:34:43 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-04-08 15:34:43 -0700
commit51365fc3eabfe76499f2daa3412d407ea7025fe9 (patch)
treee8524ac34b7e0f51d5de0a09d0e65d9fadab5044 /src/property/file.lisp
parent5827de0b4a7057d5ce816c37391134b2428159f2 (diff)
downloadconsfigurator-51365fc3eabfe76499f2daa3412d407ea7025fe9.tar.gz
add FILE:IS-COPY-OF
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/file.lisp')
-rw-r--r--src/property/file.lisp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/property/file.lisp b/src/property/file.lisp
index e42df20..71372d8 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -155,6 +155,19 @@ error if FROM is another kind of file, except when unapplying."
(mrun "rm" from)
:no-change)))
+(defprop is-copy-of :posix (dest source)
+ "Ensure that DEST is a copy of SOURCE. SOURCE may be a regular file or a
+symbolic link, in which case the target of the link will be copied."
+ (:desc #?"${dest} is copy of ${source}")
+ (:check
+ (and (test "-f" dest)
+ (zerop (mrun :for-exit "cmp" "-s" dest source))))
+ (:apply
+ (with-remote-temporary-file
+ (temp :directory (pathname-directory-pathname dest))
+ (mrun "cp" "-L" "--preserve=all" source temp)
+ (mrun "mv" temp dest))))
+
;;;; Config files