From dee05622a94e2803d232892b376aba70328c21e6 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 9 Oct 2021 12:55:46 -0700 Subject: replace some functions with a new :CONSFIGURATOR-CACHE connattr This simplifies the API. Signed-off-by: Sean Whitton --- src/connection.lisp | 9 +++++---- src/data.lisp | 10 +++++----- src/package.lisp | 2 -- src/property/file.lisp | 3 ++- src/property/installer.lisp | 3 ++- src/property/periodic.lisp | 3 ++- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/connection.lisp b/src/connection.lisp index b7a5cb6..370d146 100644 --- a/src/connection.lisp +++ b/src/connection.lisp @@ -252,6 +252,11 @@ login(1)). Tilde expansion works correctly." (merge-pathnames ".cache/" (connection-connattr connection :remote-home))))) +(defmethod connection-connattr + ((connection connection) (k (eql :consfigurator-cache))) + (merge-pathnames "consfigurator/" + (connection-connattr connection :XDG-CACHE-HOME))) + ;;;; Functions to access the slots of the current connection @@ -603,10 +608,6 @@ specification of POSIX ls(1))." 0)) (failed-change "Could not determine time of remote's last reboot.")))) -(defun remote-consfigurator-cache-pathname (path) - (merge-pathnames - path (merge-pathnames "consfigurator/" (get-connattr :XDG-CACHE-HOME)))) - (defun remote-executable-find (executable) (zerop (mrun :for-exit "command" "-v" executable))) diff --git a/src/data.lisp b/src/data.lisp index d87e648..4962ae0 100644 --- a/src/data.lisp +++ b/src/data.lisp @@ -403,7 +403,8 @@ no risk of clashes between fresly generated files and cached copies of files." (if version pn (ensure-directory-pathname pn))))) (defun remote-data-pathname (&rest args) - (apply #'data-pathname (get-remote-data-cache-dir) args)) + (apply #'data-pathname + (merge-pathnames "data/" (get-connattr :consfigurator-cache)) args)) ;;;; Remote caches @@ -420,13 +421,12 @@ of CONNECTION, where each entry is of the form (mapcar (lambda (line) (mapcar #'filename->string (split-string line :separator "/"))) (multiple-value-bind (out exit) - (mrun :may-fail "find" (get-remote-data-cache-dir) + (mrun :may-fail "find" (merge-pathnames + "data/" + (get-connattr :consfigurator-cache)) "-type" "f" "-printf" "%P\\n") (and (zerop exit) (lines out)))))) -(defun get-remote-data-cache-dir () - (remote-consfigurator-cache-pathname "data/")) - ;;;; Local caches diff --git a/src/package.lisp b/src/package.lisp index 111b25a..7cb7b32 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -163,7 +163,6 @@ #:remote-exists-p #:remote-file-stats #:remote-last-reboot - #:remote-consfigurator-cache-pathname #:remote-executable-find #:mountpointp #:delete-remote-trees @@ -296,7 +295,6 @@ #:get-remote-cached-prerequisite-data #:get-local-cached-prerequisite-data #:get-highest-local-cached-prerequisite-data - #:get-remote-data-cache-dir #:try-register-data-source #:register-data-source diff --git a/src/property/file.lisp b/src/property/file.lisp index 9c4ad7d..0d89d82 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -166,7 +166,8 @@ any of the regular expressions PATTERNS." (defprop data-cache-purged :posix () "Ensure that any prerequisite data cached in the remote home directory is removed." (:desc "Consfigurator data cache cleaned") - (:apply (directory-does-not-exist (get-remote-data-cache-dir)))) + (:apply (directory-does-not-exist + (merge-pathnames "data/" (get-connattr :consfigurator-cache))))) (defprop regex-replaced-lines :posix (file regex replace) "Like s/REGEX/REPLACE/ on the lines of FILE. diff --git a/src/property/installer.lisp b/src/property/installer.lisp index 5e68e4f..fbe574b 100644 --- a/src/property/installer.lisp +++ b/src/property/installer.lisp @@ -273,7 +273,8 @@ using a combinator like ON-CHANGE, or applied manually with DEPLOY-THESE." #P"/root/.cache/consfigurator/")))) (setf (get-connattr :remote-user) "root" (get-connattr :remote-home) "/root" - (get-connattr :XDG-CACHE-HOME) #P"/root/.cache/") + (get-connattr :XDG-CACHE-HOME) #P"/root/.cache/" + (get-connattr :consfigurator-cache) #P"/root/.cache/consfigurator/") (posix-login-environment "root" "/root") ;; Remount (mainly virtual) filesystems that other properties we will diff --git a/src/property/periodic.lisp b/src/property/periodic.lisp index 6c0eab3..437ed41 100644 --- a/src/property/periodic.lisp +++ b/src/property/periodic.lisp @@ -42,7 +42,8 @@ user." (symbol-macrolet ((flagfile (merge-pathnames (string->filename desc) - (remote-consfigurator-cache-pathname "at-most/")))) + (merge-pathnames "at-most/" + (get-connattr :consfigurator-cache))))) (destructuring-bind (psym . args) propapp (:retprop :type (propapptype propapp) :desc (lambda-ignoring-args desc) -- cgit v1.2.3