From dc396f800b11fc9aa4bae07df268ad51a2740d8b Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 29 May 2021 14:59:42 -0700 Subject: hostattrs accessors: call PREPROCESS-HOST in some situations Signed-off-by: Sean Whitton --- src/property.lisp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/property.lisp') diff --git a/src/property.lisp b/src/property.lisp index 2abb5e9..c3a6a5d 100644 --- a/src/property.lisp +++ b/src/property.lisp @@ -457,7 +457,19 @@ install an apt package but the host is FreeBSD.") "Retrieve the list of static informational attributes of type KEY. Called by property :HOSTATTRS, :APPLY and :UNAPPLY subroutines." - (getf (slot-value host 'hostattrs) k)) + ;; Ensure the host is preprocessed so the desired hostattrs are actually + ;; there, assuming we're not already preprocessing it. Avoid calling + ;; PREPROCESS-HOST on PREPROCESSED-HOST values to avoid pointless copying. + ;; + ;; This is just to improve readability for some property definitions and + ;; avoid confusing situations where hostattrs appear to be missing (for + ;; example, if the hostname is not set until HOSTNAME:IS); properties which + ;; will look up multiple hostattrs by supplying a value for HOST should call + ;; PREPROCESS-HOST on that value themselves. + (let ((host (if (and (subtypep (class-of host) 'unpreprocessed-host) + (not (eql host *preprocessing-host*))) + (preprocess-host host) host))) + (getf (slot-value host 'hostattrs) k))) (defun get-hostattrs-car (k &optional (host *host*)) (car (get-hostattrs k host))) -- cgit v1.2.3