diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-08 15:34:43 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-08 15:34:43 -0700 |
commit | 51365fc3eabfe76499f2daa3412d407ea7025fe9 (patch) | |
tree | e8524ac34b7e0f51d5de0a09d0e65d9fadab5044 /src/property/file.lisp | |
parent | 5827de0b4a7057d5ce816c37391134b2428159f2 (diff) | |
download | consfigurator-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.lisp | 13 |
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 |