1 | (in-package #:asdf-install) |
---|
2 | |
---|
3 | (pushnew :asdf-install *features*) |
---|
4 | |
---|
5 | (defun installer-msg (stream format-control &rest format-arguments) |
---|
6 | (apply #'format stream "~&;;; ASDF-INSTALL: ~@?~%" |
---|
7 | format-control format-arguments)) |
---|
8 | |
---|
9 | (defun verify-gpg-signatures-p (url) |
---|
10 | (labels ((prefixp (prefix string) |
---|
11 | (let ((m (mismatch prefix string))) |
---|
12 | (or (not m) (>= m (length prefix)))))) |
---|
13 | (case *verify-gpg-signatures* |
---|
14 | ((nil) nil) |
---|
15 | ((:unknown-locations) |
---|
16 | (notany |
---|
17 | (lambda (x) (prefixp x url)) |
---|
18 | *safe-url-prefixes*)) |
---|
19 | (t t)))) |
---|
20 | |
---|
21 | (defun same-central-registry-entry-p (a b) |
---|
22 | (flet ((ensure-string (x) |
---|
23 | (typecase x |
---|
24 | (string x) |
---|
25 | (pathname (namestring (translate-logical-pathname x))) |
---|
26 | (t nil)))) |
---|
27 | (and (setf a (ensure-string a)) |
---|
28 | (setf b (ensure-string b)) |
---|
29 | a b (string-equal a b)))) |
---|
30 | |
---|
31 | (defun add-registry-location (location) |
---|
32 | (let ((location-directory (pathname-sans-name+type location))) |
---|
33 | #+asdf |
---|
34 | (pushnew location-directory |
---|
35 | asdf:*central-registry* |
---|
36 | :test #'same-central-registry-entry-p) |
---|
37 | |
---|
38 | #+mk-defsystem |
---|
39 | (mk:add-registry-location location-directory))) |
---|
40 | |
---|
41 | ;;; Fixing the handling of *LOCATIONS* |
---|
42 | |
---|
43 | (defun add-locations (loc-name site system-site) |
---|
44 | (declare (type string loc-name) |
---|
45 | (type pathname site system-site)) |
---|
46 | #+asdf |
---|
47 | (progn |
---|
48 | (pushnew site asdf:*central-registry* :test #'equal) |
---|
49 | (pushnew system-site asdf:*central-registry* :test #'equal)) |
---|
50 | |
---|
51 | #+mk-defsystem |
---|
52 | (progn |
---|
53 | (mk:add-registry-location site) |
---|
54 | (mk:add-registry-location system-site)) |
---|
55 | (setf *locations* |
---|
56 | (append *locations* (list (list site system-site loc-name))))) |
---|
57 | |
---|
58 | ;;;--------------------------------------------------------------------------- |
---|
59 | ;;; URL handling. |
---|
60 | |
---|
61 | (defun url-host (url) |
---|
62 | (assert (string-equal url "http://" :end1 7)) |
---|
63 | (let* ((port-start (position #\: url :start 7)) |
---|
64 | (host-end (min (or (position #\/ url :start 7) (length url)) |
---|
65 | (or port-start (length url))))) |
---|
66 | (subseq url 7 host-end))) |
---|
67 | |
---|
68 | (defun url-port (url) |
---|
69 | (assert (string-equal url "http://" :end1 7)) |
---|
70 | (let ((port-start (position #\: url :start 7))) |
---|
71 | (if port-start |
---|
72 | (parse-integer url :start (1+ port-start) :junk-allowed t) 80))) |
---|
73 | |
---|
74 | ; This is from Juri Pakaste's <juri@iki.fi> base64.lisp |
---|
75 | (defparameter *encode-table* |
---|
76 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=") |
---|
77 | |
---|
78 | (defun base64-encode (string) |
---|
79 | (let ((result (make-array |
---|
80 | (list (* 4 (truncate (/ (+ 2 (length string)) 3)))) |
---|
81 | :element-type 'base-char))) |
---|
82 | (do ((sidx 0 (+ sidx 3)) |
---|
83 | (didx 0 (+ didx 4)) |
---|
84 | (chars 2 2) |
---|
85 | (value nil nil)) |
---|
86 | ((>= sidx (length string)) t) |
---|
87 | (setf value (ash (logand #xFF (char-code (char string sidx))) 8)) |
---|
88 | (dotimes (n 2) |
---|
89 | (when (< (+ sidx n 1) (length string)) |
---|
90 | (setf value |
---|
91 | (logior value |
---|
92 | (logand #xFF (char-code (char string (+ sidx n 1)))))) |
---|
93 | (incf chars)) |
---|
94 | (when (= n 0) |
---|
95 | (setf value (ash value 8)))) |
---|
96 | (setf (elt result (+ didx 3)) |
---|
97 | (elt *encode-table* (if (> chars 3) (logand value #x3F) 64))) |
---|
98 | (setf value (ash value -6)) |
---|
99 | (setf (elt result (+ didx 2)) |
---|
100 | (elt *encode-table* (if (> chars 2) (logand value #x3F) 64))) |
---|
101 | (setf value (ash value -6)) |
---|
102 | (setf (elt result (+ didx 1)) |
---|
103 | (elt *encode-table* (logand value #x3F))) |
---|
104 | (setf value (ash value -6)) |
---|
105 | (setf (elt result didx) |
---|
106 | (elt *encode-table* (logand value #x3F)))) |
---|
107 | result)) |
---|
108 | |
---|
109 | (defun request-uri (url) |
---|
110 | (assert (string-equal url "http://" :end1 7)) |
---|
111 | (if *proxy* |
---|
112 | url |
---|
113 | (let ((path-start (position #\/ url :start 7))) |
---|
114 | (assert (and path-start) nil "url does not specify a file.") |
---|
115 | (subseq url path-start)))) |
---|
116 | |
---|
117 | (defun url-connection (url) |
---|
118 | (let ((stream (make-stream-from-url (or *proxy* url))) |
---|
119 | (host (url-host url))) |
---|
120 | (format stream "GET ~A HTTP/1.0~C~CHost: ~A~C~CCookie: CCLAN-SITE=~A~C~C" |
---|
121 | (request-uri url) #\Return #\Linefeed |
---|
122 | host #\Return #\Linefeed |
---|
123 | *cclan-mirror* #\Return #\Linefeed) |
---|
124 | (when (and *proxy-passwd* *proxy-user*) |
---|
125 | (format stream "Proxy-Authorization: Basic ~A~C~C" |
---|
126 | (base64-encode (format nil "~A:~A" *proxy-user* *proxy-passwd*)) |
---|
127 | #\Return #\Linefeed)) |
---|
128 | (format stream "~C~C" #\Return #\Linefeed) |
---|
129 | (force-output stream) |
---|
130 | (list |
---|
131 | (let* ((l (read-header-line stream)) |
---|
132 | (space (position #\Space l))) |
---|
133 | (parse-integer l :start (1+ space) :junk-allowed t)) |
---|
134 | (loop for line = (read-header-line stream) |
---|
135 | until (or (null line) |
---|
136 | (zerop (length line)) |
---|
137 | (eql (elt line 0) (code-char 13))) |
---|
138 | collect |
---|
139 | (let ((colon (position #\: line))) |
---|
140 | (cons (intern (string-upcase (subseq line 0 colon)) :keyword) |
---|
141 | (string-trim (list #\Space (code-char 13)) |
---|
142 | (subseq line (1+ colon)))))) |
---|
143 | stream))) |
---|
144 | |
---|
145 | (defun download-link-for-package (package-name-or-url) |
---|
146 | (if (= (mismatch package-name-or-url "http://") 7) |
---|
147 | package-name-or-url |
---|
148 | (format nil "http://www.cliki.net/~A?download" |
---|
149 | package-name-or-url))) |
---|
150 | |
---|
151 | (defun download-link-for-signature (url) |
---|
152 | (concatenate 'string url ".asc")) |
---|
153 | |
---|
154 | ;;; XXX unsightful hack |
---|
155 | (defvar *dont-check-signature* nil) |
---|
156 | |
---|
157 | (defun download-files-for-package (package-name-or-url) |
---|
158 | (setf *dont-check-signature* nil) |
---|
159 | (multiple-value-bind (package-url package-file) |
---|
160 | (download-url-to-temporary-file |
---|
161 | (download-link-for-package package-name-or-url)) |
---|
162 | (if (verify-gpg-signatures-p package-name-or-url) |
---|
163 | (restart-case |
---|
164 | (multiple-value-bind (signature-url signature-file) |
---|
165 | (download-url-to-temporary-file |
---|
166 | (download-link-for-signature package-url)) |
---|
167 | (declare (ignore signature-url)) |
---|
168 | (values package-file signature-file)) |
---|
169 | (skip-gpg-check () |
---|
170 | :report "Don't check GPG signature for this package" |
---|
171 | (progn |
---|
172 | (setf *dont-check-signature* t) |
---|
173 | (values package-file nil)))) |
---|
174 | (values package-file nil)))) |
---|
175 | |
---|
176 | (defun verify-gpg-signature (file-name signature-name) |
---|
177 | (block verify |
---|
178 | (when (and (null signature-name) *dont-check-signature*) |
---|
179 | (return-from verify t)) |
---|
180 | (loop |
---|
181 | (restart-case |
---|
182 | (let ((tags (gpg-results file-name signature-name))) |
---|
183 | ;; test that command returned something |
---|
184 | (unless tags |
---|
185 | (error 'gpg-shell-error)) |
---|
186 | ;; test for obvious key/sig problems |
---|
187 | (let ((errsig (header-value :errsig tags))) |
---|
188 | (and errsig (error 'key-not-found :key-id errsig))) |
---|
189 | (let ((badsig (header-value :badsig tags))) |
---|
190 | (and badsig (error 'key-not-found :key-id badsig))) |
---|
191 | (let* ((good (header-value :goodsig tags)) |
---|
192 | (id (first good)) |
---|
193 | (name (format nil "~{~A~^ ~}" (rest good)))) |
---|
194 | ;; good signature, but perhaps not trusted |
---|
195 | (restart-case |
---|
196 | (let ((trusted? (or (header-pair :trust_ultimate tags) |
---|
197 | (header-pair :trust_fully tags))) |
---|
198 | (in-list? (assoc id *trusted-uids* :test #'equal))) |
---|
199 | (cond ((or trusted? in-list?) |
---|
200 | ;; ok |
---|
201 | ) |
---|
202 | ((not trusted?) |
---|
203 | (error 'key-not-trusted |
---|
204 | :key-user-name name :key-id id)) |
---|
205 | ((not in-list?) |
---|
206 | (error 'author-not-trusted |
---|
207 | :key-user-name name :key-id id)))) |
---|
208 | (add-key (&rest rest) |
---|
209 | :report "Add to package supplier list" |
---|
210 | (declare (ignore rest)) |
---|
211 | (pushnew (list id name) *trusted-uids*)))) |
---|
212 | (return-from verify t)) |
---|
213 | (install-anyways |
---|
214 | (&rest rest) |
---|
215 | :report "Don't check GPG signature for this package" |
---|
216 | (declare (ignore rest)) |
---|
217 | (return-from verify t)) |
---|
218 | (retry-gpg-check |
---|
219 | (&rest args) |
---|
220 | :report "Retry GPG check \(e.g., after downloading the key\)" |
---|
221 | (declare (ignore args)) |
---|
222 | nil))))) |
---|
223 | |
---|
224 | (defun header-value (name headers) |
---|
225 | "Searchers headers for name _without_ case sensitivity. Headers should be an alist mapping symbols to values; name a symbol. Returns the value if name is found or nil if it is not." |
---|
226 | (cdr (header-pair name headers))) |
---|
227 | |
---|
228 | (defun header-pair (name headers) |
---|
229 | "Searchers headers for name _without_ case sensitivity. Headers should be an alist mapping symbols to values; name a symbol. Returns the \(name value\) pair if name is found or nil if it is not." |
---|
230 | (assoc name headers |
---|
231 | :test (lambda (a b) |
---|
232 | (string-equal (symbol-name a) (symbol-name b))))) |
---|
233 | |
---|
234 | (defun validate-preferred-location () |
---|
235 | (typecase *preferred-location* |
---|
236 | (null t) |
---|
237 | ((integer 0) |
---|
238 | (assert (<= 1 *preferred-location* (length *locations*)) |
---|
239 | (*preferred-location*) |
---|
240 | 'invalid-preferred-location-number-error |
---|
241 | :preferred-location *preferred-location*)) |
---|
242 | ((or symbol string) |
---|
243 | (assert (find *preferred-location* *locations* |
---|
244 | :test (if (typep *preferred-location* 'symbol) |
---|
245 | #'eq #'string-equal) :key #'third) |
---|
246 | (*preferred-location*) |
---|
247 | 'invalid-preferred-location-name-error |
---|
248 | :preferred-location *preferred-location*)) |
---|
249 | (t |
---|
250 | (assert nil |
---|
251 | (*preferred-location*) |
---|
252 | 'invalid-preferred-location-error |
---|
253 | :preferred-location *preferred-location*))) |
---|
254 | *preferred-location*) |
---|
255 | |
---|
256 | (defun select-location () |
---|
257 | (loop with n-locations = (length *locations*) |
---|
258 | for response = (progn |
---|
259 | (format t "Install where?~%") |
---|
260 | (loop for (source system name) in *locations* |
---|
261 | for i from 1 |
---|
262 | do (format t "~A) ~A: ~% System in ~A~% Files in ~A ~%" |
---|
263 | i name system source)) |
---|
264 | (format t "0) Abort installation.~% --> ") |
---|
265 | (force-output) |
---|
266 | (read)) |
---|
267 | when (and (numberp response) |
---|
268 | (<= 1 response n-locations)) |
---|
269 | return response |
---|
270 | when (and (numberp response) |
---|
271 | (zerop response)) |
---|
272 | do (abort (make-condition 'installation-abort)))) |
---|
273 | |
---|
274 | (defun install-location () |
---|
275 | (validate-preferred-location) |
---|
276 | (let ((location-selection (or *preferred-location* |
---|
277 | (select-location)))) |
---|
278 | (etypecase location-selection |
---|
279 | (integer |
---|
280 | (elt *locations* (1- location-selection))) |
---|
281 | ((or symbol string) |
---|
282 | (find location-selection *locations* :key #'third |
---|
283 | :test (if (typep location-selection 'string) |
---|
284 | #'string-equal #'eq)))))) |
---|
285 | |
---|
286 | |
---|
287 | ;;; install-package -- |
---|
288 | |
---|
289 | (defun find-shell-command (command) |
---|
290 | (loop for directory in *shell-search-paths* do |
---|
291 | (let ((target (make-pathname :name command :type nil |
---|
292 | :directory directory))) |
---|
293 | (when (probe-file target) |
---|
294 | (return-from find-shell-command (namestring target))))) |
---|
295 | (values nil)) |
---|
296 | |
---|
297 | (defun tar-command () |
---|
298 | #-(or :win32 :mswindows) |
---|
299 | (find-shell-command *gnu-tar-program*) |
---|
300 | #+(or :win32 :mswindows) |
---|
301 | *cygwin-bash-program*) |
---|
302 | |
---|
303 | (defun tar-arguments (source packagename) |
---|
304 | #-(or :win32 :mswindows :scl) |
---|
305 | (list "-C" (namestring (truename source)) |
---|
306 | "-xzvf" (namestring (truename packagename))) |
---|
307 | #+(or :win32 :mswindows) |
---|
308 | (list "-l" |
---|
309 | "-c" |
---|
310 | (format nil "\"tar -C \\\"`cygpath '~A'`\\\" -xzvf \\\"`cygpath '~A'`\\\"\"" |
---|
311 | (namestring (truename source)) |
---|
312 | (namestring (truename packagename)))) |
---|
313 | #+scl |
---|
314 | (list "-C" (ext:unix-namestring (truename source)) |
---|
315 | "-xzvf" (ext:unix-namestring (truename packagename)))) |
---|
316 | |
---|
317 | (defun extract-using-tar (to-dir tarball) |
---|
318 | (let ((tar-command (tar-command))) |
---|
319 | (if (and tar-command (probe-file tar-command)) |
---|
320 | (return-output-from-program tar-command |
---|
321 | (tar-arguments to-dir tarball)) |
---|
322 | (warn "Cannot find tar command ~S." tar-command)))) |
---|
323 | |
---|
324 | (defun extract (to-dir tarball) |
---|
325 | (or (some #'(lambda (extractor) (funcall extractor to-dir tarball)) |
---|
326 | *tar-extractors*) |
---|
327 | (error "Unable to extract tarball ~A." tarball))) |
---|
328 | |
---|
329 | (defun install-package (source system packagename) |
---|
330 | "Returns a list of system names (ASDF or MK:DEFSYSTEM) for installed systems." |
---|
331 | (ensure-directories-exist source) |
---|
332 | (ensure-directories-exist system) |
---|
333 | (let* ((tar (extract source packagename)) |
---|
334 | ;; Some tar programs (OSX) list entries with preceeding "x " |
---|
335 | ;; as in "x entry/file.asd" |
---|
336 | (pos-begin (if (= (search "x " tar) 0) |
---|
337 | 2 |
---|
338 | 0)) |
---|
339 | (pos-slash (or (position #\/ tar) |
---|
340 | (position #\Return tar) |
---|
341 | (position #\Linefeed tar))) |
---|
342 | (*default-pathname-defaults* |
---|
343 | (merge-pathnames |
---|
344 | (make-pathname :directory |
---|
345 | `(:relative ,(subseq tar pos-begin pos-slash))) |
---|
346 | source))) |
---|
347 | ;(princ tar) |
---|
348 | (loop for sysfile in (append |
---|
349 | (directory |
---|
350 | (make-pathname :defaults *default-pathname-defaults* |
---|
351 | :name :wild |
---|
352 | :type "asd")) |
---|
353 | (directory |
---|
354 | (make-pathname :defaults *default-pathname-defaults* |
---|
355 | :name :wild |
---|
356 | :type "system"))) |
---|
357 | do (maybe-symlink-sysfile system sysfile) |
---|
358 | do (installer-msg t "Found system definition: ~A" sysfile) |
---|
359 | do (maybe-update-central-registry sysfile) |
---|
360 | collect sysfile))) |
---|
361 | |
---|
362 | (defun maybe-update-central-registry (sysfile) |
---|
363 | ;; make sure that the systems we install are accessible in case |
---|
364 | ;; asdf-install:*locations* and asdf:*central-registry* are out |
---|
365 | ;; of sync |
---|
366 | (add-registry-location sysfile)) |
---|
367 | |
---|
368 | (defun temp-file-name (p) |
---|
369 | (declare (ignore p)) |
---|
370 | (let ((pathname nil)) |
---|
371 | (loop for i = 0 then (1+ i) do |
---|
372 | (setf pathname |
---|
373 | (merge-pathnames |
---|
374 | (make-pathname |
---|
375 | :name (format nil "asdf-install-~d" i) |
---|
376 | :type "asdf-install-tmp") |
---|
377 | *temporary-directory*)) |
---|
378 | (unless (probe-file pathname) |
---|
379 | (return-from temp-file-name pathname))))) |
---|
380 | |
---|
381 | |
---|
382 | ;;; install |
---|
383 | ;;; This is the external entry point. |
---|
384 | |
---|
385 | (defun install (packages &key (propagate nil) (where *preferred-location*)) |
---|
386 | (let* ((*preferred-location* where) |
---|
387 | (*temporary-files* nil) |
---|
388 | (trusted-uid-file |
---|
389 | (merge-pathnames "trusted-uids.lisp" *private-asdf-install-dirs*)) |
---|
390 | (*trusted-uids* |
---|
391 | (when (probe-file trusted-uid-file) |
---|
392 | (with-open-file (f trusted-uid-file) (read f)))) |
---|
393 | (old-uids (copy-list *trusted-uids*)) |
---|
394 | #+asdf |
---|
395 | (*defined-systems* (if propagate |
---|
396 | (make-hash-table :test 'equal) |
---|
397 | *defined-systems*)) |
---|
398 | (packages (if (atom packages) (list packages) packages)) |
---|
399 | (*propagate-installation* propagate) |
---|
400 | (*systems-installed-this-time* nil)) |
---|
401 | (unwind-protect |
---|
402 | (destructuring-bind (source system name) (install-location) |
---|
403 | (declare (ignore name)) |
---|
404 | (labels |
---|
405 | ((one-iter (packages) |
---|
406 | (let ((packages-to-install nil)) |
---|
407 | (loop for p in (mapcar #'string packages) do |
---|
408 | (cond ((local-archive-p p) |
---|
409 | (setf packages-to-install |
---|
410 | (append packages-to-install |
---|
411 | (install-package source system p)))) |
---|
412 | (t |
---|
413 | (multiple-value-bind (package signature) |
---|
414 | (download-files-for-package p) |
---|
415 | (when (verify-gpg-signatures-p p) |
---|
416 | (verify-gpg-signature package signature)) |
---|
417 | (installer-msg t "Installing ~A in ~A, ~A" |
---|
418 | p source system) |
---|
419 | (install-package source system package)) |
---|
420 | (setf packages-to-install |
---|
421 | (append packages-to-install |
---|
422 | (list p)))))) |
---|
423 | (dolist (package packages-to-install) |
---|
424 | (setf package |
---|
425 | (etypecase package |
---|
426 | (symbol package) |
---|
427 | (string (intern package :asdf-install)) |
---|
428 | (pathname (intern |
---|
429 | (namestring (pathname-name package)) |
---|
430 | :asdf-install)))) |
---|
431 | (handler-bind |
---|
432 | ( |
---|
433 | #+asdf |
---|
434 | (asdf:missing-dependency |
---|
435 | (lambda (c) |
---|
436 | (installer-msg |
---|
437 | t |
---|
438 | "Downloading package ~A, required by ~A~%" |
---|
439 | (asdf::missing-requires c) |
---|
440 | (asdf:component-name |
---|
441 | (asdf::missing-required-by c))) |
---|
442 | (one-iter |
---|
443 | (list (asdf::coerce-name |
---|
444 | (asdf::missing-requires c)))) |
---|
445 | (invoke-restart 'retry))) |
---|
446 | #+mk-defsystem |
---|
447 | (make:missing-component |
---|
448 | (lambda (c) |
---|
449 | (installer-msg |
---|
450 | t |
---|
451 | "Downloading package ~A, required by ~A~%" |
---|
452 | (make:missing-component-name c) |
---|
453 | package) |
---|
454 | (one-iter (list (make:missing-component-name c))) |
---|
455 | (invoke-restart 'retry)))) |
---|
456 | (loop (multiple-value-bind (ret restart-p) |
---|
457 | (with-simple-restart |
---|
458 | (retry "Retry installation") |
---|
459 | (push package *systems-installed-this-time*) |
---|
460 | (load-package package)) |
---|
461 | (declare (ignore ret)) |
---|
462 | (unless restart-p (return))))))))) |
---|
463 | (one-iter packages))) |
---|
464 | ;;; cleanup |
---|
465 | (unless (equal old-uids *trusted-uids*) |
---|
466 | (let ((create-file-p nil)) |
---|
467 | (unless (probe-file trusted-uid-file) |
---|
468 | (installer-msg t "Trusted UID file ~A does not exist" |
---|
469 | (namestring trusted-uid-file)) |
---|
470 | (setf create-file-p |
---|
471 | (y-or-n-p "Do you want to create the file?"))) |
---|
472 | (when (or create-file-p (probe-file trusted-uid-file)) |
---|
473 | (ensure-directories-exist trusted-uid-file) |
---|
474 | (with-open-file (out trusted-uid-file |
---|
475 | :direction :output |
---|
476 | :if-exists :supersede) |
---|
477 | (with-standard-io-syntax |
---|
478 | (prin1 *trusted-uids* out)))))) |
---|
479 | (dolist (l *temporary-files* t) |
---|
480 | (when (probe-file l) (delete-file l)))) |
---|
481 | (nreverse *systems-installed-this-time*))) |
---|
482 | |
---|
483 | (defun local-archive-p (package) |
---|
484 | #+(or :sbcl :allegro) (probe-file package) |
---|
485 | #-(or :sbcl :allegro) (and (/= (mismatch package "http://") 7) |
---|
486 | (probe-file package))) |
---|
487 | |
---|
488 | (defun load-package (package) |
---|
489 | #+asdf |
---|
490 | (progn |
---|
491 | (installer-msg t "Loading system ~S via ASDF." package) |
---|
492 | (asdf:operate 'asdf:load-op package)) |
---|
493 | #+mk-defsystem |
---|
494 | (progn |
---|
495 | (installer-msg t "Loading system ~S via MK:DEFSYSTEM." package) |
---|
496 | (mk:load-system package))) |
---|
497 | |
---|
498 | ;;; uninstall -- |
---|
499 | |
---|
500 | (defun uninstall (system &optional (prompt t)) |
---|
501 | #+asdf |
---|
502 | (let* ((asd (asdf:system-definition-pathname system)) |
---|
503 | (system (asdf:find-system system)) |
---|
504 | (dir (pathname-sans-name+type |
---|
505 | (asdf::resolve-symlinks asd)))) |
---|
506 | (when (or (not prompt) |
---|
507 | (y-or-n-p |
---|
508 | "Delete system ~A~%asd file: ~A~%sources: ~A~%Are you sure?" |
---|
509 | system asd dir)) |
---|
510 | #-(or :win32 :mswindows) |
---|
511 | (delete-file asd) |
---|
512 | (let ((dir (#-scl namestring #+scl ext:unix-namestring (truename dir)))) |
---|
513 | (when dir |
---|
514 | (asdf:run-shell-command "rm -r '~A'" dir))))) |
---|
515 | |
---|
516 | #+mk-defsystem |
---|
517 | (multiple-value-bind (sysfile sysfile-exists-p) |
---|
518 | (mk:system-definition-pathname system) |
---|
519 | (when sysfile-exists-p |
---|
520 | (let ((system (ignore-errors (mk:find-system system :error)))) |
---|
521 | (when system |
---|
522 | (when (or (not prompt) |
---|
523 | (y-or-n-p |
---|
524 | "Delete system ~A.~%system file: ~A~%Are you sure?" |
---|
525 | system |
---|
526 | sysfile)) |
---|
527 | (mk:clean-system system) |
---|
528 | (delete-file sysfile) |
---|
529 | (dolist (f (mk:files-in-system system)) |
---|
530 | (delete-file f))) |
---|
531 | )) |
---|
532 | ))) |
---|
533 | |
---|
534 | |
---|
535 | ;;; some day we will also do UPGRADE, but we need to sort out version |
---|
536 | ;;; numbering a bit better first |
---|
537 | |
---|
538 | #+(and :asdf (or :win32 :mswindows)) |
---|
539 | (defun sysdef-source-dir-search (system) |
---|
540 | (let ((name (asdf::coerce-name system))) |
---|
541 | (dolist (location *locations*) |
---|
542 | (let* ((dir (first location)) |
---|
543 | (files (directory (merge-pathnames |
---|
544 | (make-pathname :name name |
---|
545 | :type "asd" |
---|
546 | :version :newest |
---|
547 | :directory '(:relative :wild) |
---|
548 | :host nil |
---|
549 | :device nil) |
---|
550 | dir)))) |
---|
551 | (dolist (file files) |
---|
552 | (when (probe-file file) |
---|
553 | (return-from sysdef-source-dir-search file))))))) |
---|
554 | |
---|
555 | (defmethod asdf:find-component :around |
---|
556 | ((module (eql nil)) name) |
---|
557 | (when (or (not *propagate-installation*) |
---|
558 | (member name *systems-installed-this-time* |
---|
559 | :test (lambda (a b) |
---|
560 | (flet ((ensure-string (x) |
---|
561 | (etypecase x |
---|
562 | (symbol (symbol-name x)) |
---|
563 | (string x)))) |
---|
564 | (string-equal (ensure-string a) (ensure-string b)))))) |
---|
565 | (call-next-method))) |
---|
566 | |
---|
567 | (defun show-version-information () |
---|
568 | (let ((version (asdf-install-version))) |
---|
569 | (if version |
---|
570 | (format *standard-output* "~&;;; ASDF-Install version ~A" |
---|
571 | version) |
---|
572 | (format *standard-output* "~&;;; ASDF-Install version unknown; unable to find ASDF system definition.")) |
---|
573 | (values))) |
---|
574 | |
---|
575 | (defun asdf-install-version () |
---|
576 | "Returns the ASDf-Install version information as a string or nil if it cannot be determined." |
---|
577 | (let ((system (asdf:find-system 'asdf-install))) |
---|
578 | (when system (asdf:component-version system)))) |
---|
579 | |
---|
580 | ;; load customizations if any |
---|
581 | (eval-when (:load-toplevel :execute) |
---|
582 | (let* ((*package* (find-package :asdf-install-customize)) |
---|
583 | (file (probe-file (merge-pathnames |
---|
584 | (make-pathname :name ".asdf-install") |
---|
585 | (truename (user-homedir-pathname)))))) |
---|
586 | (when file (load file)))) |
---|
587 | |
---|
588 | ;;; end of file -- install.lisp -- |
---|