Skip to content

Commit bb47de4

Browse files
Use an ASDF system-search-function hook instead of catching ASDF errors.
1 parent 690b3a0 commit bb47de4

File tree

4 files changed

+52
-47
lines changed

4 files changed

+52
-47
lines changed

quicklisp/client.lisp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
(setf systems (list systems)))
3535
(dolist (thing systems systems)
3636
(flet ((ql ()
37-
(autoload-system-and-dependencies thing :prompt prompt)))
37+
(let ((ql::*attempt-installing* t)
38+
(*quickload-prompt* prompt))
39+
(asdf:load-system thing))))
3840
(if verbose
3941
(ql)
4042
(call-with-quiet-compilation #'ql)))))))

quicklisp/dist.lisp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,15 +1022,6 @@ the given NAME."
10221022
(when system
10231023
(installed-asdf-system-file system))))
10241024

1025-
(defun system-definition-searcher (name)
1026-
"Like FIND-ASDF-SYSTEM-FILE, but this function can be used in
1027-
ASDF:*SYSTEM-DEFINITION-SEARCH-FUNCTIONS*; it will only return system
1028-
file names if they match NAME."
1029-
(let ((system-file (find-asdf-system-file name)))
1030-
(when (and system-file
1031-
(string= (pathname-name system-file) name))
1032-
system-file)))
1033-
10341025
(defun call-with-consistent-dists (fun)
10351026
"Take a snapshot of the available dists and return the same list
10361027
consistently each time ALL-DISTS is called in the dynamic scope of

quicklisp/package.lisp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@
240240
(:export #:standard-dist-enumeration-function
241241
#:*dist-enumeration-functions*
242242
#:find-asdf-system-file
243-
#:system-definition-searcher
244243
#:system-apropos
245244
#:system-apropos-list
246245
#:dependency-tree

quicklisp/setup.lisp

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,55 @@
6161
system given to load is not available via ASDF or a Quicklisp
6262
dist."))
6363

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+
64113
(defun compute-load-strategy (name)
65114
(setf name (string-downcase name))
66115
(let ((asdf-systems '())
@@ -160,42 +209,6 @@
160209
(format t "~&; Loading ~S~%" (name strategy))
161210
(asdf:oos 'asdf:load-op (name strategy) :verbose nil))))
162211

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-
199212
(defvar *initial-dist-url*
200213
"http://beta.quicklisp.org/dist/quicklisp.txt")
201214

0 commit comments

Comments
 (0)