Skip to content

Commit 43861ad

Browse files
committed
Better installation process
1 parent e20c316 commit 43861ad

7 files changed

Lines changed: 244 additions & 19 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.fasl
2+
/.DS_Store

README.txt

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
2 VERSION
88
=========
99

10+
,----
11+
| 0.4.0
12+
`----
13+
1014

1115
3 SYNOPSIS
1216
==========
@@ -32,13 +36,44 @@
3236
4.2 INSTALLATION
3337
~~~~~~~~~~~~~~~~
3438

35-
Clone the repository somewhere ASDF finds it, like `~/common-lisp' and
36-
add following lines to your lisp init/startup file (e.g. `~/.sbclrc')
39+
1. Clone quicklisp-client from
40+
<https://github.com/quicklisp/quicklisp-client.git> to ~/quicklisp
41+
2. Clone ql-https from
42+
<https://github.com/rudolfochrist/ql-https.git> to to
43+
~/common-lisp/ql-https
44+
3. Disconnect internet.
45+
4. Start a fresh REPL and (require 'asdf)
46+
5. Load ~/common-lisp/ql-https/ql-setup.lisp
47+
6. Eval (asdf:load-system "ql-https")
48+
7. Inspect ql-<http:*fetch-scheme-functions>* and verify everything
49+
was registered properly.
50+
8. Connect internet.
51+
9. Eval (quicklisp:setup) - use the USE-HTTPS restart if you hit the
52+
network.
53+
10. DONE
54+
55+
If you're bothered that (ql:update-client) warns about a missing
56+
client-info.sexp then do:
57+
58+
1. Set ql-<info:*version>* to a year before (or any other year)
59+
e.g. from 2021-02-13 to 2020-02-13
60+
2. Run (ql:update-client) This "installs" the latest client and write
61+
the client-info.sexp
62+
63+
64+
4.3 STARTUP
65+
~~~~~~~~~~~
3766

3867
,----
39-
| (require 'asdf)
40-
| #+quicklisp (asdf:load-system "ql-https")
41-
| #+ql-https (setf ql-https:*quietly-use-https* t) ;; optional
68+
| (let ((quicklisp-init #p"~/common-lisp/ql-https/ql-setup.lisp"))
69+
| (when (probe-file quicklisp-init)
70+
| (load quicklisp-init)
71+
| (asdf:load-system "ql-https")
72+
| (uiop:symbol-call :quicklisp :setup)))
73+
|
74+
| ;; optional
75+
| #+ql-https
76+
| (setf ql-https:*quietly-use-https* t)
4277
`----
4378

4479

asdf.conf

Lines changed: 0 additions & 4 deletions
This file was deleted.

doc/README.org

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,38 @@ cat ../version
2727

2828
** INSTALLATION
2929

30-
Clone the repository somewhere ASDF finds it, like =~/common-lisp= and add following lines to your lisp
31-
init/startup file (e.g. =~/.sbclrc=)
30+
1. Clone quicklisp-client from https://github.com/quicklisp/quicklisp-client.git
31+
to ~/quicklisp
32+
2. Clone ql-https from https://github.com/rudolfochrist/ql-https.git to
33+
to ~/common-lisp/ql-https
34+
3. Disconnect internet.
35+
4. Start a fresh REPL and (require 'asdf)
36+
5. Load ~/common-lisp/ql-https/ql-setup.lisp
37+
6. Eval (asdf:load-system "ql-https")
38+
7. Inspect ql-http:*fetch-scheme-functions* and verify everything was registered properly.
39+
8. Connect internet.
40+
9. Eval (quicklisp:setup) - use the USE-HTTPS restart if you hit the network.
41+
10. DONE
42+
43+
If you're bothered that (ql:update-client) warns about a missing client-info.sexp then do:
44+
45+
1. Set ql-info:*version* to a year before (or any other year) e.g. from 2021-02-13 to 2020-02-13
46+
2. Run (ql:update-client)
47+
This "installs" the latest client and write the client-info.sexp
48+
49+
50+
** STARTUP
3251

3352
#+begin_src lisp
34-
(require 'asdf)
35-
#+quicklisp (asdf:load-system "ql-https")
36-
#+ql-https (setf ql-https:*quietly-use-https* t) ;; optional
53+
(let ((quicklisp-init #p"~/common-lisp/ql-https/ql-setup.lisp"))
54+
(when (probe-file quicklisp-init)
55+
(load quicklisp-init)
56+
(asdf:load-system "ql-https")
57+
(uiop:symbol-call :quicklisp :setup)))
58+
59+
;; optional
60+
,#+ql-https
61+
(setf ql-https:*quietly-use-https* t)
3762
#+end_src
3863

3964
* AUTHOR

ql-https.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#.(uiop:read-file-string
1717
(uiop:subpathname *load-pathname* "README.txt"))
1818
:perform (load-op :after (o c)
19+
(uiop:symbol-call :ql-https :register-fetch-scheme-functions)
1920
(pushnew :ql-https *features*)))
2021

2122

ql-https.lisp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
(:use :cl)
55
(:export
66
#:fetcher
7-
#:*quietly-use-https*))
7+
#:*quietly-use-https*
8+
#:register-fetch-scheme-functions))
89

910
(in-package #:ql-https)
1011

@@ -35,7 +36,8 @@
3536
(setf *quietly-use-https* t)
3637
(apply #'fetcher url file args)))))
3738

38-
;;; register QL
39-
(setf ql-http:*fetch-scheme-functions*
40-
(list (cons "http" 'fetcher)
41-
(cons "https" 'fetcher)))
39+
40+
(defun register-fetch-scheme-functions ()
41+
(setf ql-http:*fetch-scheme-functions*
42+
(list (cons "http" 'fetcher)
43+
(cons "https" 'fetcher))))

ql-setup.lisp

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
;; Copyright (c) 2014 Zachary Beane <zach@quicklisp.org>
2+
3+
;; Permission is hereby granted, free of charge, to any person obtaining a copy
4+
;; of this software and associated documentation files (the "Software"), to deal
5+
;; in the Software without restriction, including without limitation the rights
6+
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
;; copies of the Software, and to permit persons to whom the Software is
8+
;; furnished to do so, subject to the following conditions:
9+
10+
;; The above copyright notice and this permission notice shall be included in
11+
;; all copies or substantial portions of the Software.
12+
13+
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
;; THE SOFTWARE.
20+
21+
;;; Commentary:
22+
;;
23+
;; Copied to get rid the `(qicklisp:setup)' call.
24+
;; Whenever the client is updated the setup.lisp is replaced
25+
;; and contains the call to setup.
26+
27+
(defpackage #:ql-setup
28+
(:use #:cl)
29+
(:export #:*quicklisp-home*
30+
#:qmerge
31+
#:qenough))
32+
33+
(in-package #:ql-setup)
34+
35+
(unless *load-truename*
36+
(error "This file must be LOADed to set up quicklisp."))
37+
38+
(defvar *quicklisp-home*
39+
(make-pathname :name nil :type nil
40+
:defaults (let ((qlhome "~/quicklisp/"))
41+
(if (probe-file qlhome)
42+
qlhome
43+
(error "Quicklisp not installed to
44+
default location. Please set
45+
*quicklisp-home* manually and
46+
retry")))))
47+
48+
(defun qmerge (pathname)
49+
"Return PATHNAME merged with the base Quicklisp directory."
50+
(merge-pathnames pathname *quicklisp-home*))
51+
52+
(defun qenough (pathname)
53+
(enough-namestring pathname *quicklisp-home*))
54+
55+
;;; ASDF is a hard requirement of quicklisp. Make sure it's either
56+
;;; already loaded or load it from quicklisp's bundled version.
57+
58+
(defvar *required-asdf-version* "3.0")
59+
60+
;;; Put ASDF's fasls in a separate directory
61+
62+
(defun implementation-signature ()
63+
"Return a string suitable for discriminating different
64+
implementations, or similar implementations with possibly-incompatible
65+
FASLs."
66+
;; XXX Will this have problems with stuff like threads vs
67+
;; non-threads fasls?
68+
(let ((*print-pretty* nil))
69+
(format nil "lisp-implementation-type: ~A~%~
70+
lisp-implementation-version: ~A~%~
71+
machine-type: ~A~%~
72+
machine-version: ~A~%"
73+
(lisp-implementation-type)
74+
(lisp-implementation-version)
75+
(machine-type)
76+
(machine-version))))
77+
78+
(defun dumb-string-hash (string)
79+
"Produce a six-character hash of STRING."
80+
(let ((hash #xD13CCD13))
81+
(loop for char across string
82+
for value = (char-code char)
83+
do
84+
(setf hash (logand #xFFFFFFFF
85+
(logxor (ash hash 5)
86+
(ash hash -27)
87+
value))))
88+
(subseq (format nil "~(~36,6,'0R~)" (mod hash 88888901))
89+
0 6)))
90+
91+
(defun asdf-fasl-pathname ()
92+
"Return a pathname suitable for storing the ASDF FASL, separated
93+
from ASDF FASLs from incompatible implementations. Also, save a file
94+
in the directory with the implementation signature, if it doesn't
95+
already exist."
96+
(let* ((implementation-signature (implementation-signature))
97+
(original-fasl (compile-file-pathname (qmerge "asdf.lisp")))
98+
(fasl
99+
(qmerge (make-pathname
100+
:defaults original-fasl
101+
:directory
102+
(list :relative
103+
"cache"
104+
"asdf-fasls"
105+
(dumb-string-hash implementation-signature)))))
106+
(signature-file (merge-pathnames "signature.txt" fasl)))
107+
(ensure-directories-exist fasl)
108+
(unless (probe-file signature-file)
109+
(with-open-file (stream signature-file :direction :output)
110+
(write-string implementation-signature stream)))
111+
fasl))
112+
113+
(defun ensure-asdf-loaded ()
114+
"Try several methods to make sure that a sufficiently-new ASDF is
115+
loaded: first try (require \"asdf\"), then loading the ASDF FASL, then
116+
compiling asdf.lisp to a FASL and then loading it."
117+
(let ((source (qmerge "asdf.lisp")))
118+
(labels ((asdf-symbol (name)
119+
(let ((asdf-package (find-package '#:asdf)))
120+
(when asdf-package
121+
(find-symbol (string name) asdf-package))))
122+
(version-satisfies (version)
123+
(let ((vs-fun (asdf-symbol '#:version-satisfies))
124+
(vfun (asdf-symbol '#:asdf-version)))
125+
(when (and vs-fun vfun
126+
(fboundp vs-fun)
127+
(fboundp vfun))
128+
(funcall vs-fun (funcall vfun) version)))))
129+
(block nil
130+
(macrolet ((try (&body asdf-loading-forms)
131+
`(progn
132+
(handler-bind ((warning #'muffle-warning))
133+
(ignore-errors
134+
,@asdf-loading-forms))
135+
(when (version-satisfies *required-asdf-version*)
136+
(return t)))))
137+
(try)
138+
(try (require "asdf"))
139+
(let ((fasl (asdf-fasl-pathname)))
140+
(try (load fasl :verbose nil))
141+
(try (load (compile-file source :verbose nil :output-file fasl))))
142+
(error "Could not load ASDF ~S or newer" *required-asdf-version*))))))
143+
144+
(ensure-asdf-loaded)
145+
146+
;;;
147+
;;; Quicklisp sometimes must upgrade ASDF. Ugrading ASDF will blow
148+
;;; away existing ASDF methods, so e.g. FASL recompilation :around
149+
;;; methods would be lost. This config file will make it possible to
150+
;;; ensure ASDF can be configured before loading Quicklisp itself via
151+
;;; ASDF. Thanks to Nikodemus Siivola for pointing out this issue.
152+
;;;
153+
154+
(let ((asdf-init (probe-file (qmerge "asdf-config/init.lisp"))))
155+
(when asdf-init
156+
(with-simple-restart (skip "Skip loading ~S" asdf-init)
157+
(load asdf-init :verbose nil :print nil))))
158+
159+
(push (qmerge "quicklisp/") asdf:*central-registry*)
160+
161+
(let ((*compile-print* nil)
162+
(*compile-verbose* nil)
163+
(*load-verbose* nil)
164+
(*load-print* nil))
165+
(asdf:oos 'asdf:load-op "quicklisp" :verbose nil))

0 commit comments

Comments
 (0)