Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use sb-md5 if on sbcl, otherwise improve error if missing md5sum #10

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ql-https.asd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:bug-tracker "https://github.com/rudolfochrist/ql-https/issues"
:source-control (:git "https://github.com/rudolfochrist/ql-https.git")
:version (:read-file-line "version")
:depends-on ((:require "uiop"))
:depends-on ((:require "uiop") (:feature :sbcl :sb-md5))
:components ((:file "ql-https"))
:description "Enable HTTPS in Quicklisp"
:long-description
Expand Down
13 changes: 10 additions & 3 deletions ql-https.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@
(end (position #\/ url :start start)))
(subseq url start end))))

#+sbcl
(defun md5 (file)
"Returns md5sum of FILE"
(uiop:run-program (format nil "md5sum \"~A\" | cut -d' ' -f 1" file)
:output '(:string :stripped t)))
(format nil "~{~2,'0x~}" (coerce (sb-md5:md5sum-file file) 'list)))

#-sbcl
(defun md5 (file)
"Returns md5sum of FILE"
(let* ((output (uiop:run-program (list "md5sum" (namestring file)) :output :string))
(space-pos (position #\Space output)))
(subseq output 0 space-pos)))

(defun file-size (file)
"Returns the size of FILE in bytes"
Expand All @@ -62,7 +69,7 @@
"Checks that the md5 and size of FILE are as expected from the quicklisp
dist."
(let ((release (ql-dist:find-release name)))
(unless (string= (ql-dist:archive-md5 release) (md5 file))
(unless (string-equal (ql-dist:archive-md5 release) (md5 file))
(error "md5 mismatch for ~A" name))
(unless (= (ql-dist:archive-size release) (file-size file))
(error "file size mismatch for ~A" name))))
Expand Down