;; SPDX-License-Identifier: BSD-2-Clause ;; Probes are pieces of code that find things out about the system ;; under configuration, informing what changes we need. ;; for use by probes, to avoid log confusion (defun subprobe-output argv (apply output-of argv)) (defun probe-output argv (with-indent (log-probe "output of %s" (repr argv)) (apply subprobe-output argv))) ;; returns true or false, not an exitcode (defun subprobe-success argv (let ((exitcode (apply system argv))) (eq exitcode 0))) (defun probe-success argv (with-indent (log-probe "exitcode of %s" (repr argv)) (apply subprobe-success argv))) (defun subprobe-sed-crypto-digest (script fp) (let* ((command (append (list "sed" "-e" script fp) (pipe-crypto-digest)))) (apply output-of command))) ;; note: this one roots its file-path! (defun probe-sed-would-change (script file-path) (with-indent (log-probe "would %s be changed by sed %s ?" file-path script) (let ((fp (*rooted* file-path))) (not (equal (crypto-digest fp) (subprobe-sed-crypto-digest script fp)))))) (defun -f (fn) (let* ((rv (subprobe-success "/bin/test" "-f" fn))) (log-probe "is %s a file? %s" fn (if rv "yes" "no")) rv)) (defun -e (fn) (let* ((rv (subprobe-success "/bin/test" "-e" fn))) (log-probe "does %s exist? %s" fn (if rv "yes" "no")) rv)) (defun -d (dn) (let* ((rv (subprobe-success "/bin/test" "-d" dn))) (log-probe "is %s a directory? %s" dn (if rv "yes" "no")) rv))