diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-24 17:12:38 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-24 17:13:10 -0700 |
commit | c4624df9d40df313f490207c37c7a9f629929936 (patch) | |
tree | 865b30cffee61eda6992447d3daf6257700b8886 /src/property/git.lisp | |
parent | e5221bf896e49f36cf7593cc6c1e0ac8a7319c01 (diff) | |
download | consfigurator-c4624df9d40df313f490207c37c7a9f629929936.tar.gz |
add GIT:SNAPSHOT-EXTRACTED
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/git.lisp')
-rw-r--r-- | src/property/git.lisp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/property/git.lisp b/src/property/git.lisp new file mode 100644 index 0000000..6434575 --- /dev/null +++ b/src/property/git.lisp @@ -0,0 +1,46 @@ +;;; Consfigurator -- Lisp declarative configuration management system + +;;; Copyright (C) 2020-2021 Sean Whitton <spwhitton@spwhitton.name> + +;;; This file is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3, or (at your option) +;;; any later version. + +;;; This file is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. + +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +(in-package :consfigurator.property.git) +(named-readtables:in-readtable :consfigurator) + +(defprop snapshot-extracted :posix + (directory snapshot-name + &key replace + &aux (dest + (merge-pathnames snapshot-name + (ensure-directory-pathname directory)))) + "Extract a tarball as produced by DATA:GIT-SNAPSHOT under DIRECTORY. +If REPLACE, delete and replace the snapshot (or anything else) that already +exists at DIRECTORY/SNAPSHOT-NAME. This is useful to ensure the latest +available version of the snapshot is present on the remote system." + ;; TODO Keyword argument to replace only if a newer version of the + ;; prerequisite data is available. + (:desc (declare (ignore replace dest)) + #?"git snapshot ${snapshot-name} extracted") + (:hostattrs (declare (ignore replace dest)) + (require-data "--git-snapshot" snapshot-name)) + (:check (and (not replace) (remote-exists-p dest))) + (:apply + (declare (ignore replace)) + (delete-remote-tree dest) + (file:directory-exists directory) + (mrun :input (get-data-stream "--git-snapshot" snapshot-name) + #?"cd '${directory}'; tar xfz -")) + (:unapply + (declare (ignore replace)) + (delete-remote-tree dest))) |