Skip to content

Commit b9ab619

Browse files
Merge pull request rudolfochrist#10 from bo-tato/improved-md5
use sb-md5 if on sbcl, otherwise improve error if missing md5sum
2 parents b714637 + 7ddf606 commit b9ab619

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

ql-https.asd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:bug-tracker "https://github.com/rudolfochrist/ql-https/issues"
1010
:source-control (:git "https://github.com/rudolfochrist/ql-https.git")
1111
:version (:read-file-line "version")
12-
:depends-on ((:require "uiop"))
12+
:depends-on ((:require "uiop") (:feature :sbcl :sb-md5))
1313
:components ((:file "ql-https"))
1414
:description "Enable HTTPS in Quicklisp"
1515
:long-description

ql-https.lisp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,17 @@
4848
(end (position #\/ url :start start)))
4949
(subseq url start end))))
5050

51+
#+sbcl
5152
(defun md5 (file)
5253
"Returns md5sum of FILE"
53-
(uiop:run-program (format nil "md5sum \"~A\" | cut -d' ' -f 1" file)
54-
:output '(:string :stripped t)))
54+
(format nil "~{~2,'0x~}" (coerce (sb-md5:md5sum-file file) 'list)))
55+
56+
#-sbcl
57+
(defun md5 (file)
58+
"Returns md5sum of FILE"
59+
(let* ((output (uiop:run-program (list "md5sum" (namestring file)) :output :string))
60+
(space-pos (position #\Space output)))
61+
(subseq output 0 space-pos)))
5562

5663
(defun file-size (file)
5764
"Returns the size of FILE in bytes"
@@ -62,7 +69,7 @@
6269
"Checks that the md5 and size of FILE are as expected from the quicklisp
6370
dist."
6471
(let ((release (ql-dist:find-release name)))
65-
(unless (string= (ql-dist:archive-md5 release) (md5 file))
72+
(unless (string-equal (ql-dist:archive-md5 release) (md5 file))
6673
(error "md5 mismatch for ~A" name))
6774
(unless (= (ql-dist:archive-size release) (file-size file))
6875
(error "file size mismatch for ~A" name))))

0 commit comments

Comments
 (0)