changeset 371: |
7dcabf3e0edc |
parent: |
71ac00213ae3
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Tue, 24 Sep 2024 15:53:24 -0400 |
permissions: |
-rwxr-xr-x |
description: |
no link in bootstrap.sh |
1 ;;; scripts/check.lisp --- check host features 3 ;; This script runs some basic checks to ensure the host is ready for 7 (defpackage :infra/check 9 (:use :cl :std :sb-alien :cli :log) 14 (in-package :infra/scripts/check) 16 (defvar *results* (make-hash-table :size 32 :test 'equal)) 18 (defparameter *library-path* (ld-library-path-list)) 19 (defparameter *exec-path* (exec-path-list)) 21 (defun get-result (k) (gethash k *results*)) 23 (defun push-result (k &optional v) 24 (setf (gethash k *results*) v)) 26 (defmacro check-err (is-warn ctrl name) 31 :format-arguments (list ,name)) 33 (error 'simple-program-error 35 :format-arguments (list ,name)))) 37 (defun check-for-shared-lib (name &optional warn) 38 "Check for a shared library by loading it in the current session with dlopen. 40 When WARN is non-nil, signal a warning instead of an error." 41 (if-let ((lib (ignore-errors (load-shared-object (format nil "lib~a.so" name))))) 43 (push-result name lib) 44 (unload-shared-object lib)) 45 (check-err warn "shared library missing: ~x" name))) 47 (defun check-for-bin (name &optional warn) 48 (if-let ((exe (find-exe name))) 49 (push-result name exe) 50 (check-err warn "executable program missing: ~x" name))) 52 (defun check-for-src (name) 55 (defun check-hostname () (push-result "hostname" (machine-instance))) 57 (defun check-user () (push-result "user" (cons (sb-posix:getenv "USER") (user-homedir-pathname)))) 59 (defun check-system () 60 (destructuring-bind (lisp version features) 61 (my-lisp-implementation) 62 (push-result "lisp" (list lisp version features) 63 #-sbcl (push-result "lisp" "unsupported") 64 #-sb-core-compression (println "WARNING: feature sb-core-compression disabled") 65 #-mark-region-gc (println "WARNING: feature mark-region-gc disabled") 69 (push-result "shell" (sb-posix:getenv "SHELL"))) 71 (defun check-display () 72 (push-result "display" (sb-posix:getenv "DISPLAY"))) 78 (push-result "cpu" (machine-version))) 80 (defmethod print-object ((object hash-table) stream) 81 (format stream "#HOST-FEATURES{~{~{~%(~a . ~a)~}~^ ~}}" 82 (loop for k being the hash-keys of *results* 87 (defun check (&optional warn) 88 "Check the host for required features." 90 (setq *library-path* (ld-library-path-list) 91 *exec-path* (exec-path-list)) 93 (debug! (format nil "LD_LIBRARY_PATH: ~A~%" *library-path*)) 94 (debug! (format nil "PATH: ~A~%" *exec-path*)) 102 (check-for-bin "sbcl" warn) 103 (check-for-bin "rustc" warn) 104 (check-for-bin "clang" warn) 105 (check-for-bin "gcc" warn) 106 (check-for-bin "emacs" warn) 108 (check-for-bin "hg" warn) 109 (check-for-bin "git" warn) 111 (check-for-bin "podman" warn) 113 (check-for-src "core") 115 (check-for-shared-lib "rocksdb" warn) 116 (check-for-shared-lib "uring" warn) 117 (check-for-shared-lib "btrfs" warn) 118 (check-for-shared-lib "btrfsutil" warn) 119 (check-for-shared-lib "tree-sitter" warn) 121 (check-for-shared-lib "gtk-4" warn) 122 (check-for-shared-lib "blake3" warn) 123 (check-for-shared-lib "k" warn) 124 (check-for-shared-lib "cbqn" warn) 127 (defmain () (println (check)))