From 51365fc3eabfe76499f2daa3412d407ea7025fe9 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 8 Apr 2021 15:34:43 -0700 Subject: add FILE:IS-COPY-OF Signed-off-by: Sean Whitton --- src/property/file.lisp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/property/file.lisp') 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 -- cgit v1.2.3