1 ;;; scripts/check.lisp --- check host features 3 ;; This script runs some basic checks to ensure the host is ready for 8 (mapc (lambda (x) (unless (find-package x) (ql:quickload x))) 9 '(:cli :std :sb-alien :cli :log)) 11 (defpackage :infra/scripts/check 13 (:use :cl :std :sb-alien :cli :log) 18 (in-package :infra/scripts/check) 20 (defvar *results* (make-hash-table :size 32 :test 'equal)) 22 (defparameter *library-path* (ld-library-path-list)) 23 (defparameter *exec-path* (exec-path-list)) 25 (defun get-result (k) (gethash k *results*)) 27 (defun push-result (k &optional v) 28 (setf (gethash k *results*) v)) 30 (defmacro check-err (is-warn ctrl name) 35 :format-arguments (list ,name)) 37 (error 'simple-program-error 39 :format-arguments (list ,name)))) 41 (defun check-for-shared-lib (name &optional warn) 42 "Check for a shared library by loading it in the current session with dlopen. 44 When WARN is non-nil, signal a warning instead of an error." 45 (if-let ((lib (ignore-errors (load-shared-object (format nil "lib~a.so" name))))) 47 (push-result name lib) 48 (unload-shared-object lib)) 49 (check-err warn "shared library missing: ~x" name))) 51 (defun check-for-bin (name &optional warn) 52 (if-let ((exe (find-exe name))) 53 (push-result name exe) 54 (check-err warn "executable program missing: ~x" name))) 56 (defun check-for-src (name) 59 (defun check-hostname () (push-result "hostname" (machine-instance))) 61 (defun check-user () (push-result "user" (cons (sb-posix:getenv "USER") (user-homedir-pathname)))) 63 (defun check-system () 64 (destructuring-bind (lisp version features) 65 (my-lisp-implementation) 66 (push-result "lisp" (list lisp version features) 67 #-sbcl (push-result "lisp" "unsupported") 68 #-sb-core-compression (println "WARNING: feature sb-core-compression disabled") 69 #-mark-region-gc (println "WARNING: feature mark-region-gc disabled") 73 (push-result "shell" (sb-posix:getenv "SHELL"))) 75 (defun check-display () 76 (push-result "display" (sb-posix:getenv "DISPLAY"))) 82 (push-result "cpu" (machine-version))) 84 (defmethod print-object ((object hash-table) stream) 85 (format stream "#HOST-FEATURES{~{~{~%(~a . ~a)~}~^ ~}}" 86 (loop for k being the hash-keys of *results* 91 (defun check (&optional warn) 92 "Check the host for required features." 94 (setq *library-path* (ld-library-path-list) 95 *exec-path* (exec-path-list)) 97 (debug! (format nil "LD_LIBRARY_PATH: ~A~%" *library-path*)) 98 (debug! (format nil "PATH: ~A~%" *exec-path*)) 106 (check-for-bin "sbcl" warn) 107 (check-for-bin "rustc" warn) 108 (check-for-bin "clang" warn) 109 (check-for-bin "gcc" warn) 110 (check-for-bin "emacs" warn) 112 (check-for-bin "hg" warn) 113 (check-for-bin "git" warn) 115 (check-for-bin "podman" warn) 117 (check-for-src "core") 119 (check-for-shared-lib "rocksdb" warn) 120 (check-for-shared-lib "uring" warn) 121 (check-for-shared-lib "btrfs" warn) 122 (check-for-shared-lib "btrfsutil" warn) 123 (check-for-shared-lib "tree-sitter" warn) 125 (check-for-shared-lib "gtk-4" warn) 126 (check-for-shared-lib "blake3" warn) 127 (check-for-shared-lib "k" warn) 128 (check-for-shared-lib "cbqn" warn) 131 (defmain () (println (check)))