Mercurial > demo / tools/prepare-image.lisp
changeset 26: |
2015d7277629 |
child: |
aa37feddcfb2 |
author: |
ellis <ellis@rwest.io> |
date: |
Mon, 05 Jun 2023 19:59:26 -0400 |
permissions: |
-rw-r--r-- |
description: |
refactor 01 |
3 ;; For SBCL, if you don't have SBCL_HOME set, then we won't be able to require this later. 5 (require 'sb-introspect) 7 (when (probe-file "scripts/asdf.lisp") 8 (format t "Compiling asdf..~%") 9 (let ((output (compile-file "scripts/asdf.lisp" :verbose nil :print nil))) 19 (push (pathname (format nil "~a/local-projects/poiu/" (namestring (uiop:getcwd)))) 20 asdf:*central-registry*) 22 (defvar *asdf-root-guesser* nil) 24 (defparameter *cwd* (merge-pathnames 25 *default-pathname-defaults* 28 (defun update-output-translations (root) 29 "This function is called dynamically from deliver-utils/common.lisp!" 30 (asdf:initialize-output-translations 31 `(:output-translations 32 :inherit-configuration 34 ,(format nil "~abuild/asdf-cache/~a/" root 35 (uiop:implementation-identifier)))))) 37 (update-output-translations *cwd*) 41 (require :sb-rotate-byte) 43 (asdf:register-preloaded-system :sb-rotate-byte) 44 (asdf:register-preloaded-system :sb-cltl2)) 46 (defun %read-version (file) 47 (let ((key "version: ")) 48 (loop for line in (uiop:read-file-lines file) 49 if (string= key line :end2 (length key)) 50 return (subseq line (length key))))) 52 (defun init-quicklisp () 53 (let ((version (%read-version "quicklisp/dists/quicklisp/distinfo.txt"))) 54 (let ((quicklisp-loc (ensure-directories-exist 56 (format nil "build/quicklisp/~a/" version) 61 (flet ((safe-copy-file (path &optional (dest path)) 62 (let ((src (merge-pathnames 65 (dest (merge-pathnames 68 (format t "Copying: ~a to ~a~%" src dest) 70 (when (equal src dest) 71 (error "Trying to overwrite the same file")) 72 (unless (uiop:file-exists-p dest) 75 (ensure-directories-exist 80 "quicklisp/quicklisp/*.lisp" 84 "quicklisp/quicklisp/*.asd" 86 do (safe-copy-file name 87 (format nil "quicklisp/~a.~a" 89 (pathname-type name)))) 90 (loop for name in (directory 94 do (safe-copy-file name 96 (pathname-name name)))) 97 (safe-copy-file "setup.lisp") 98 (safe-copy-file "quicklisp/version.txt") 99 (safe-copy-file "dists/quicklisp/distinfo.txt") 100 (safe-copy-file "dists/quicklisp/enabled.txt") 101 (safe-copy-file "dists/quicklisp/preference.txt")) 102 (load (merge-pathnames 109 (ql:update-all-dists :prompt nil) 111 (pushnew :demo *features*) 113 (defun update-project-directories (cwd) 114 (flet ((push-src-dir (name) 115 (let ((dir (pathname (format nil "~a~a/" cwd name)))) 116 (when (probe-file dir) 117 (push dir ql:*local-project-directories*))))) 119 (push-src-dir "local-projects") 121 (push-src-dir "third-party") 122 (push-src-dir "lisp"))) 125 (defun update-root (cwd) 126 (update-output-translations cwd) 127 (update-project-directories cwd)) 129 (update-project-directories *cwd*) 131 (defun maybe-asdf-prepare () 132 (when *asdf-root-guesser* 133 (update-root (funcall *asdf-root-guesser*)))) 135 (compile 'maybe-asdf-prepare) 137 (defun unprepare-asdf (root-guesser) 138 "This function is called dynamically from deliver-utils/common.lisp!" 139 (setf *asdf-root-guesser* root-guesser)) 141 (defun maybe-configure-proxy () 142 (let ((proxy (uiop:getenv "HTTP_PROXY"))) 143 (when (and proxy (> (length proxy) 0)) 144 (setf ql:*proxy-url* proxy)))) 146 (maybe-configure-proxy) 149 (ql:quickload "log4cl") 150 (ql:quickload "prove-asdf") 152 (log:info "*local-project-directories: ~S" ql:*local-project-directories*) 154 ;; (ql:quickload :cl-ppcre) 155 ;; make sure we have build asd 157 (push (pathname (format nil "~a/build-utils/" *cwd*)) 158 asdf:*central-registry*) 159 (ql:register-local-projects)