-
Notifications
You must be signed in to change notification settings - Fork 1
/
quicklisp-systems.lisp
88 lines (72 loc) · 3.41 KB
/
quicklisp-systems.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
;; Copyright (C) 2021 Mariano Montone
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(require :dexador)
(require :asdf)
(require :quicklisp)
(require :chipz)
(defpackage #:quicklisp-systems
(:use #:cl))
(in-package #:quicklisp-systems)
(defvar *systems-file* (merge-pathnames "quicklisp-systems-list" (uiop/pathname:pathname-directory-pathname *load-pathname*)))
(defparameter *systems-file-url* "https://github.com/mmontone/quicklisp-systems/releases/latest/download/quicklisp-systems-list.gz"
"The URL from where to download the file with Quicklisp systems descriptions.")
(defmacro do-systems ((system &optional (path *systems-file*)) &body body)
(let ((f (gensym)))
`(when (probe-file ,path)
(with-open-file (,f ,path :direction :input :external-format :utf-8)
(loop for ,system := (read ,f nil nil)
while ,system
do ,@body)))))
(defun check-systems-list ()
(and (probe-file *systems-file*) t))
(defun list-all-systems ()
(let (systems)
(do-systems (system)
(push system systems))
(sort systems 'string< :key (lambda (x) (getf x :name)))))
(defun find-system-info (name)
(do-systems (system)
(when (equalp (getf system :name) name)
(return-from find-system-info system))))
(defun apropos-system (string &optional search-description)
(let (systems)
(do-systems (system)
(when (or (search string (getf system :name) :test 'equalp)
(and search-description
(or (and (getf system :description)
(search string (getf system :description) :test 'equalp))
(and (getf system :long-description)
(search string (getf system :long-description) :test 'equalp)))))
(push system systems)))
systems))
(defun apropos-author (author-name)
(let (systems)
(do-systems (system)
(when (and (getf system :author)
(search author-name (getf system :author) :test 'equalp))
(push system systems)))
systems))
(defun gunzip (gzip-filename output-filename)
(with-open-file (gzstream gzip-filename :direction :input
:element-type '(unsigned-byte 8))
(with-open-file (stream output-filename :direction :output
:element-type '(unsigned-byte 8)
:if-exists :supersede)
(chipz:decompress stream 'chipz:gzip gzstream)
output-filename)))
(defun download-systems-file (&optional (url *systems-file-url*))
(format t "Downloading quicklisp systems file from ~a ~%" url)
(ql-util:with-temporary-file (systems-file-list.gz (pathname-name *systems-file*))
(dex:fetch url systems-file-list.gz)
(gunzip systems-file-list.gz *systems-file*))
(format t "Systems file downloaded to ~a~%" *systems-file*))
(provide :quicklisp-systems)