# HG changeset patch # User ellis # Date 1701142393 18000 # Node ID 17a70918610c1a75652abea232585e0a490a3068 # Parent b1363d688ae1a9f926ca3592e465ee262b82c51d scripts diff -r b1363d688ae1 -r 17a70918610c makefile --- a/makefile Mon Nov 27 18:26:13 2023 -0500 +++ b/makefile Mon Nov 27 22:33:13 2023 -0500 @@ -91,7 +91,7 @@ ### Web ### Dist -dist/code:scripts/bundle.sh +dist/comp:scripts/bundle-dir.sh $< dist/cdn:cdn @@ -105,6 +105,9 @@ dist/emacs:emacs; -dist:dist/code dist/cdn dist/sbcl dist/linux dist/rocksdb +dist:dist/comp dist/cdn dist/sbcl dist/linux dist/rocksdb dist-clean::;rm -rf dist/* + +### Quickstart +quick:code diff -r b1363d688ae1 -r 17a70918610c readme.org --- a/readme.org Mon Nov 27 18:26:13 2023 -0500 +++ b/readme.org Mon Nov 27 22:33:13 2023 -0500 @@ -7,10 +7,54 @@ This project contains scripts, utils, and applications used to host and maintain The Compiler Company infrastructure. -* Usage +* Quickstart +- Dependencies + - Mercurial + - Make #+begin_src shell -# ( linux emacs rocksdb sbcl rust code virt dist ) -make -make install -# make deploy +sudo pacman -Sy make mercurial +# make quick +# make install +#+end_src +* Scripts +** [[file:scripts/eval.sh][eval.sh]] +Eval a lisp script using SBCL. +** [[file:scripts/check.lisp][check.lisp]] +Check the host for compatibility. +#+begin_src shell :results pp replace :exports both +./scripts/eval.sh ./scripts/check.lisp #+end_src + +#+RESULTS: +#+begin_example + +#HOST-FEATURES{ +(lisp . (SBCL 2.3.8 + (CL-PPCRE NAMED-READTABLES ASDF3.3 ASDF3.2 ASDF3.1 ASDF3 ASDF2 ASDF + OS-UNIX NON-BASE-CHARS-EXIST-P ASDF-UNICODE ARENA-ALLOCATOR X86-64 + GENCGC 64-BIT ANSI-CL COMMON-LISP ELF IEEE-FLOATING-POINT LINUX + LITTLE-ENDIAN PACKAGE-LOCAL-NICKNAMES SB-CORE-COMPRESSION SB-LDB + SB-PACKAGE-LOCKS SB-THREAD SB-UNICODE SBCL UNIX))) +(shell . /home/ellis/dev/comp/infra) +(rocksdb . librocksdb.so) +(uring . liburing.so) +(btrfs . libbtrfs.so) +(btrfsutil . libbtrfsutil.so) +(tree-sitter . libtree-sitter.so) +(gtk-4 . libgtk-4.so) +(blake3 . libblake3.so) +(k . libk.so) +(cbqn . libcbqn.so)} +#+end_example +** [[file:scripts/autogen.lisp][autogen.lisp]] +** get-* +Pull and build dependencies. +** [[file:scripts/git-vendor-pull.sh][git-vendor-pull.sh]] +Pull an upstream vendored repository from Git and push it to our +private mirror. + +#+begin_src shell :noeval t :exports code +scripts/git-vendor-pull.sh git.savannah.gnu.org/git emacs master +#+end_src +** [[file:scripts/bundle-dir.sh][bundle-dir.sh]] +Bundle a local directory of source-code repos. diff -r b1363d688ae1 -r 17a70918610c scripts/autogen.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/autogen.lisp Mon Nov 27 22:33:13 2023 -0500 @@ -0,0 +1,9 @@ +;;; scripts/autogen.lisp --- prepare the local environment + +;;; Code: +(in-package :cl-user) +(use-package :std) + +(defmain () + "Prepare the local environment for bootstrapping a complete system." + (format t "Starting scripts/autogen.lisp...~%")) diff -r b1363d688ae1 -r 17a70918610c scripts/bundle-dir.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/bundle-dir.sh Mon Nov 27 22:33:13 2023 -0500 @@ -0,0 +1,34 @@ +#!/bin/bash +# bundle a tar.zst archive of Mercurial repositories. +#WD=/mnt/y/data/packy +WD=$(realpath dist) +OUT=$WD/bundle/src +SRC_PATH=$HOME/dev/comp +BUNDLE_NAME="${1:-comp}" +echo "Bundling $BUNDLE_NAME in $OUT..." + +rm -rf $OUT/* +rm -rf $WD/$BUNDLE_NAME.* +mkdir -pv $WD/vc/{zst,stream} + +pushd $SRC_PATH +# Find all mercurial repositories, create bundles and dump them to $OUT dir +for i in $(find . -name ".hg" | cut -c 3-); do + echo ""; + echo $i; + + cd "$i"; + cd ..; + hg bundle -a -t zstd-v2 $WD/vc/zst/$(basename $(hg root)).hg.zst; + hg bundle -a -t none-v2 $WD/vc/$(basename $(hg root)).hg; + hg debugcreatestreamclonebundle $WD/vc/$(basename $(hg root)).hg.stream; + echo "... Done."; + cd $SRC_PATH +done +popd +pushd $WD +tar -I 'zstd' -cf $OUT/$BUNDLE_NAME.tar.zst vc/zst/*.hg.zst +# tar -cf $OUT/$BUNDLE_NAME.tar.stream vc/stream/*.hg.stream +# tar -cf $OUT/$BUNDLE_NAME.tar vc/*.hg +echo "Done." +popd diff -r b1363d688ae1 -r 17a70918610c scripts/bundle.sh --- a/scripts/bundle.sh Mon Nov 27 18:26:13 2023 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -#!/bin/bash -# bundle a tar.zst archive of Mercurial repositories. -#WD=/mnt/y/data/packy -WD=$(realpath dist) -OUT=$WD/code -SRC_PATH=$HOME/dev/comp -BUNDLE_NAME=code -echo "Bundling $BUNDLE_NAME in $OUT..." - -rm -rf $OUT/* -rm -rf $WD/$BUNDLE_NAME.* -mkdir -pv $OUT/{zst,stream} - -pushd $SRC_PATH - -# Find all mercurial repositories, create bundles and dump them to $OUT dir -for i in $(find . -name ".hg" | cut -c 3-); do - echo ""; - echo $i; - - cd "$i"; - cd ..; - hg bundle -a -t zstd-v2 $OUT/zst/$(basename $(hg root)).hg.zst; - hg bundle -a -t none-v2 $OUT/$(basename $(hg root)).hg; - hg debugcreatestreamclonebundle $OUT/stream/$(basename $(hg root)).hg.stream; - echo "... Done."; - cd $SRC_PATH -done -popd -pushd $WD -tar -I 'zstd --ultra -22' -cf $BUNDLE_NAME.tar.zst code/zst/*.hg.zst -tar -cf $BUNDLE_NAME.tar.stream code/stream/*.hg.stream -tar -cf $BUNDLE_NAME.tar code/*.hg -echo "Done." -popd diff -r b1363d688ae1 -r 17a70918610c scripts/check.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/check.lisp Mon Nov 27 22:33:13 2023 -0500 @@ -0,0 +1,105 @@ +;;; scripts/check.lisp --- check host features + +;; This script runs some basic checks to ensure the host is ready for +;; bootstrapping. + +;;; Code: +(require 'asdf) +(require 'sb-posix) +(asdf:load-asd #P"~/dev/comp/core/lisp/std/std.asd") +(asdf:load-system :std) + +(defpackage :infra/scripts/check + (:use :cl :std :sb-alien) + (:export :main + :*results*)) + +(in-package :infra/scripts/check) + +(defvar *results* (make-hash-table :size 32 :test 'equal)) + +(defparameter *library-path* (ld-library-path-list)) +(defparameter *exec-path* (exec-path-list)) + +(defun get-result (k) (gethash k *results*)) + +(defun push-result (k &optional v) + (setf (gethash k *results*) v)) + +(defun check-for-shared-lib (name) + (if-let ((lib (ignore-errors (load-shared-object (format nil "lib~a.so" name))))) + (prog1 + (push-result name lib) + (unload-shared-object lib)) + (push-result name))) + +(defun check-for-bin (name) + (push-result name)) + +(defun check-for-src (name) + (push-result name)) + +(defun check-system () + (destructuring-bind (lisp version features) + (my-lisp-implementation) + (push-result "lisp" (list lisp version features) + #-sbcl (push-result "lisp")))) + +(defun check-shell () + (push-result "shell" (sb-posix:getcwd))) + +(defun check-display () + (push-result "display")) + +(defun check-net () + (push-result "net")) + +(defun check-cpu () + (push-result "cpu")) + +(defmethod print-object ((object hash-table) stream) + (format stream "#HOST-FEATURES{~{~{~%(~a . ~a)~}~^ ~}}" + (loop for k being the hash-keys of *results* + using (hash-value v) + unless (null v) + collect (list k v)))) + +(defmain () + "Check the host for required features." + + (setq *library-path* (ld-library-path-list) + *exec-path* (exec-path-list)) + + (debug! (format nil "LD_LIBRARY_PATH: ~A~%" *library-path*)) + (debug! (format nil "PATH: ~A~%" *exec-path*)) + (check-system) + (check-shell) + + (check-for-bin "sbcl") + (check-for-bin "rustc") + (check-for-bin "clang") + (check-for-bin "gcc") + (check-for-bin "emacs") + ;; vcs + (check-for-bin "hg") + (check-for-bin "git") + ;; virt + (check-for-bin "podman") + + (check-for-src "core") + ;; core dependencies + (check-for-shared-lib "rocksdb") + (check-for-shared-lib "uring") + (check-for-shared-lib "btrfs") + (check-for-shared-lib "btrfsutil") + (check-for-shared-lib "tree-sitter") + ;; extras + (check-for-shared-lib "sbcl") ;; requires compiling sbcl as shared_lib + (check-for-shared-lib "gtk-4") + (check-for-shared-lib "blake3") + (check-for-shared-lib "k") + (check-for-shared-lib "cbqn") + (print *results*) + *results*) + +(main) diff -r b1363d688ae1 -r 17a70918610c scripts/eval.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/eval.sh Mon Nov 27 22:33:13 2023 -0500 @@ -0,0 +1,10 @@ +#!/bin/sh + +# eval lisp code +LISP="/usr/bin/sbcl" +args="" +FILE="${1}" +[[ -z "$FILE" ]] && : || args="--script $FILE " +FORM=${2} +[[ -z "$FORM" ]] && : || args="--eval $FORM " +$LISP $args --eval "(quit)" diff -r b1363d688ae1 -r 17a70918610c scripts/get-code.sh --- a/scripts/get-code.sh Mon Nov 27 18:26:13 2023 -0500 +++ b/scripts/get-code.sh Mon Nov 27 22:33:13 2023 -0500 @@ -4,7 +4,7 @@ OUT=build/comp-$(date "+%Y%m%d") mkdir -pv $OUT pushd $OUT -wget https://packy.compiler.company/$SRC.tar.zst +wget https://packy.compiler.company/bundle/src/$SRC.tar.zst unzstd $SRC.tar.zst tar -xvf $SRC.tar rm -rf $SRC.tar.zst $SRC.tar diff -r b1363d688ae1 -r 17a70918610c scripts/git-vendor-pull.sh --- a/scripts/git-vendor-pull.sh Mon Nov 27 18:26:13 2023 -0500 +++ b/scripts/git-vendor-pull.sh Mon Nov 27 22:33:13 2023 -0500 @@ -1,10 +1,12 @@ #!/usr/bin/bash # scripts/git-vendor-pull.sh git.savannah.gnu.org/git emacs master -DOMAIN="${1}" -REMOTE="https://$DOMAIN/${2}" -REPO="ssh://git@vc.compiler.company/packy/shed/vendor/${2}" -BRANCH="${3:-master}" -OUT="${4:-build/${2}}" +NAME="${1}" +DOMAIN="${2}" +REMOTE="https://$DOMAIN/$NAME" +BRANCH="${2:-master}" +REPO="ssh://git@vc.compiler.company/packy/shed/vendor/${1}" +OUT="${3:-build/src/${1}}" +mkdir -pv build/src git clone $REPO $OUT pushd $OUT git pull $REMOTE $BRANCH diff -r b1363d688ae1 -r 17a70918610c skelfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skelfile Mon Nov 27 22:33:13 2023 -0500 @@ -0,0 +1,4 @@ +;;; skelfile --- infra skelfile -*- mode: skel; -*- +:name "infra" +:description "The Compiler Company Infrastructure" +:author "Richard Westhaver "