aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/package.lisp3
-rw-r--r--src/property/file.lisp13
2 files changed, 15 insertions, 1 deletions
diff --git a/src/package.lisp b/src/package.lisp
index 4c8e442..3056fe0 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -241,7 +241,8 @@
#:contains-ini-settings
#:regex-replaced-lines
#:directory-exists
- #:symlinked))
+ #:symlinked
+ #:is-copy-of))
(defpackage :consfigurator.property.os
(:use #:cl #:consfigurator)
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