|
61 | 61 | system given to load is not available via ASDF or a Quicklisp
|
62 | 62 | dist."))
|
63 | 63 |
|
| 64 | +(defparameter *attempt-installing* nil) |
| 65 | + |
| 66 | +(defun system-definition-searcher (name) |
| 67 | + "Like FIND-ASDF-SYSTEM-FILE, but this function can be used in |
| 68 | +ASDF:*SYSTEM-DEFINITION-SEARCH-FUNCTIONS*; it will only return system |
| 69 | +file names if they match NAME." |
| 70 | + (declare (special *tried-so-far*)) |
| 71 | + (flet |
| 72 | + ((body () |
| 73 | + (if (gethash name *tried-so-far*) |
| 74 | + (error "Dependency looping -- already tried to load ~A" name) |
| 75 | + (progn |
| 76 | + (setf (gethash name *tried-so-far*) t) |
| 77 | + (flet ((try-finding-it () |
| 78 | + (let ((system-file (find-asdf-system-file name))) |
| 79 | + (when (and system-file |
| 80 | + (string= (pathname-name system-file) name)) |
| 81 | + system-file)))) |
| 82 | + (or (try-finding-it) |
| 83 | + (when *attempt-installing* |
| 84 | + (let ((ql-system (find-system name))) |
| 85 | + (when (and ql-system |
| 86 | + ;; TODO FIXME *quickload-prompt* is forward referenced |
| 87 | + (or (not quicklisp-client::*quickload-prompt*) |
| 88 | + (progn |
| 89 | + (format t "About to install ~A.~%" ql-system) |
| 90 | + (press-enter-to-continue)))) |
| 91 | + (ensure-installed ql-system)) |
| 92 | + (try-finding-it)) |
| 93 | + ;; TODO this branch doesn't work because compute-load-strategy |
| 94 | + ;; calls find-system again and triggers the error above. |
| 95 | + #+nil |
| 96 | + (progn |
| 97 | + (let ((strategy (compute-load-strategy name))) |
| 98 | + (show-load-strategy strategy) |
| 99 | + ;; TODO FIXME *quickload-prompt* is forward referenced |
| 100 | + (when (or (not quicklisp-client::*quickload-prompt*) |
| 101 | + (press-enter-to-continue)) |
| 102 | + (apply-load-strategy strategy))) |
| 103 | + (try-finding-it))))))))) |
| 104 | + (if (boundp '*tried-so-far*) |
| 105 | + ;; we are getting nested |
| 106 | + (body) |
| 107 | + ;; only do these once |
| 108 | + (with-simple-restart (abort "Give up on loading ~S" name) |
| 109 | + (let ((*tried-so-far* (make-hash-table :test 'equalp))) |
| 110 | + (declare (special *tried-so-far*)) |
| 111 | + (body)))))) |
| 112 | + |
64 | 113 | (defun compute-load-strategy (name)
|
65 | 114 | (setf name (string-downcase name))
|
66 | 115 | (let ((asdf-systems '())
|
|
160 | 209 | (format t "~&; Loading ~S~%" (name strategy))
|
161 | 210 | (asdf:oos 'asdf:load-op (name strategy) :verbose nil))))
|
162 | 211 |
|
163 |
| -(defun autoload-system-and-dependencies (name &key prompt) |
164 |
| - "Try to load the system named by NAME, automatically loading any |
165 |
| -Quicklisp-provided systems first, and catching ASDF missing |
166 |
| -dependencies too if possible." |
167 |
| - (setf name (string-downcase name)) |
168 |
| - (with-simple-restart (abort "Give up on ~S" name) |
169 |
| - (let ((strategy (compute-load-strategy name)) |
170 |
| - (tried-so-far (make-hash-table :test 'equalp))) |
171 |
| - (show-load-strategy strategy) |
172 |
| - (when (or (not prompt) |
173 |
| - (press-enter-to-continue)) |
174 |
| - (tagbody |
175 |
| - retry |
176 |
| - (handler-case (apply-load-strategy strategy) |
177 |
| - (asdf:missing-dependency-of-version (c) |
178 |
| - ;; Nothing Quicklisp can do to recover from this, so just |
179 |
| - ;; resignal |
180 |
| - (error c)) |
181 |
| - (asdf:missing-dependency (c) |
182 |
| - (let ((parent (asdf::missing-required-by c)) |
183 |
| - (missing (asdf::missing-requires c))) |
184 |
| - (typecase parent |
185 |
| - (asdf:system |
186 |
| - (if (gethash missing tried-so-far) |
187 |
| - (error "Dependency looping -- already tried to load ~ |
188 |
| - ~A" missing) |
189 |
| - (setf (gethash missing tried-so-far) missing)) |
190 |
| - (autoload-system-and-dependencies missing |
191 |
| - :prompt prompt) |
192 |
| - (go retry)) |
193 |
| - (t |
194 |
| - ;; Error isn't from a system dependency, so there's |
195 |
| - ;; nothing to autoload |
196 |
| - (error c))))))))) |
197 |
| - name)) |
198 |
| - |
199 | 212 | (defvar *initial-dist-url*
|
200 | 213 | "http://beta.quicklisp.org/dist/quicklisp.txt")
|
201 | 214 |
|
|
0 commit comments