Skip to content

Commit a028be0

Browse files
Merge pull request rudolfochrist#12 from rudolfochrist/cross-platform
Cross platform adjustments esp. md5/sha256 checksums
2 parents 7b7c318 + e7928dc commit a028be0

3 files changed

Lines changed: 30 additions & 17 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ ql-https — HTTPS support for Quicklisp via curl
1616

1717
- [Quicklisp](https://www.quicklisp.org/beta/)
1818
- curl
19-
- md5sum (unless you're using SBCL)
2019

2120

2221
## AUTOMATIC INSTALLATION

install.sh

100644100755
Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,43 @@ set -euo pipefail
44

55
LISP=${LISP=sbcl}
66

7+
# For testers
8+
QL_TOPDIR="${QL_TOPDIR-$HOME/quicklisp}"
9+
CLDIR="${CLDIR-$HOME/common-lisp}"
10+
SKIP_USERINIT="${SKIP_USERINIT-no}"
11+
12+
if test -d "$QL_TOPDIR"; then
13+
echo "Cannot install Quicklisp because it seems it is already installed!"
14+
echo "Please check $QL_TOPDIR"
15+
exit 1
16+
fi
17+
718
echo "Downloading quicklisp metadata..."
8-
mkdir -p ~/quicklisp
19+
mkdir -p "$QL_TOPDIR"
920
meta=$( curl -s https://beta.quicklisp.org/client/quicklisp.sexp | \
10-
awk '/:client-tar/,/)/' | tr '\n' ' ' | sed -e's/\s\+/ /g' )
21+
awk '/:client-tar/,/)/' | tr '\n' ' ' | tr -s ' ' )
1122

12-
url=$( grep -oP '(?<=:url ")[^"]*' <<< "$meta" )
13-
sha256=$( grep -oP '(?<=:sha256 ")[^"]*' <<< "$meta" )
23+
url=$( perl -nle 'print $& if m{(?<=:url ")[^"]*}g' <<< "$meta" )
24+
sha256=$( perl -nle 'print $& if m{(?<=:sha256 ")[^"]*}g' <<< "$meta" )
1425

1526
echo "Downloading quicklisp client..."
16-
curl -s "$url" -o ~/quicklisp/quicklisp.tar
27+
curl -s "$url" -o "$QL_TOPDIR"/quicklisp.tar
1728

18-
if [ "$sha256" != "$(sha256sum ~/quicklisp/quicklisp.tar | cut -d' ' -f 1)" ]
29+
if [ "$sha256" != "$(openssl dgst -sha256 "$QL_TOPDIR"/quicklisp.tar | cut -d' ' -f 2)" ]
1930
then
20-
echo "sha mismatch" >&2
21-
exit 1
31+
echo "sha mismatch" >&2
32+
exit 1
2233
fi
2334

24-
tar xf ~/quicklisp/quicklisp.tar -C ~/quicklisp
25-
rm ~/quicklisp/quicklisp.tar
35+
tar xf "$QL_TOPDIR"/quicklisp.tar -C "$QL_TOPDIR"
36+
rm "$QL_TOPDIR"/quicklisp.tar
2637

2738
echo "Cloning ql-https..."
28-
git clone https://github.com/rudolfochrist/ql-https ~/common-lisp/ql-https
39+
git clone https://github.com/rudolfochrist/ql-https "$CLDIR"/ql-https
2940

30-
echo "Running setup code..."
31-
$LISP <<EOF
41+
if test "$SKIP_USERINIT" = no; then
42+
echo "Running setup code..."
43+
$LISP <<EOF
3244
(require 'asdf)
3345
(load "~/common-lisp/ql-https/ql-setup.lisp")
3446
(asdf:load-system "ql-https")
@@ -39,7 +51,7 @@ $LISP <<EOF
3951
(ql:add-to-init-file))
4052
EOF
4153

42-
cat > ~/quicklisp/setup.lisp <<EOF
54+
cat > "$QL_TOPDIR"/setup.lisp <<EOF
4355
(require 'asdf)
4456
(let ((quicklisp-init #p"~/common-lisp/ql-https/ql-setup.lisp"))
4557
(when (probe-file quicklisp-init)
@@ -51,5 +63,6 @@ cat > ~/quicklisp/setup.lisp <<EOF
5163
#+ql-https
5264
(setf ql-https:*quietly-use-https* t)
5365
EOF
66+
fi
5467

5568
echo "All done!"

ql-https.lisp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@
5656
#-sbcl
5757
(defun md5 (file)
5858
"Returns md5sum of FILE"
59-
(let* ((output (uiop:run-program (list "md5sum" (namestring file)) :output :string))
59+
(let* ((output (uiop:run-program (list "openssl" "dgst" "-md5" (namestring file))
60+
:output '(:string :stripped t)))
6061
(space-pos (position #\Space output)))
61-
(subseq output 0 space-pos)))
62+
(subseq output (1+ space-pos)))) ; exclude space itself
6263

6364
(defun file-size (file)
6465
"Returns the size of FILE in bytes"

0 commit comments

Comments
 (0)