-
Notifications
You must be signed in to change notification settings - Fork 0
/
packager.lisp
78 lines (67 loc) · 2.78 KB
/
packager.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
(in-package #:qldeb)
(defun system-name (system)
(format-system-name (ql-dist:name system)))
(defun format-system-name (name)
(uiop:strcat "cl-" (ppcre:regex-replace-all "/" name "--")))
(defun asd-path (system)
(merge-pathnames (uiop:strcat (ql-dist:system-file-name system) ".asd")
(uiop:strcat (ql-dist:prefix (ql-dist:release system)) "/")))
(defun make-deb-packager (archive system)
(let ((asd-form (system-file-info
(read-entry (archive-entry archive (asd-path system)))
system)))
(make-instance
'deb-packager:deb-package
:name (make-symbol (system-name system))
:changelog (make-changelog-entry system asd-form)
:description (or (getf asd-form :description) *dummy-description*)
:architecture "all"
:build-depends nil
:depends (when (ql-dist:required-systems system)
(format-dependencies
system
(ql-dist:required-systems system)))
:long-description (if (getf asd-form :long-description)
(format-long-description
(getf asd-form :long-description))
"")
:maintainer (author asd-form))))
(defun make-changelog-entry (system asd-form)
(make-array
1
:initial-contents (list (make-instance
'deb-packager:changelog-entry
:version (format nil "~D" (system-version system))
:author (author asd-form)
:message "qldeb changelog"
:date 1434665940))))
(defvar *dummy-author-email* "[email protected]")
(defvar *dummy-author* (format nil "Dummy author <~A>" *dummy-author-email*))
(defvar *dummy-description* "Dummy short description")
(defun author (form)
(if (getf form :author)
(validated-author (getf form :author))
*dummy-author*))
(defun validated-author (author)
(if (ppcre:scan ".+<.+>" author)
author
(format nil "~A <~A>" author *dummy-author-email*)))
(defun format-dependencies (system dependencies)
(mapcar (lambda (dependency)
(format nil "~A (>= ~A), ~A (<< ~A)"
(format-system-name dependency) (system-version system)
(format-system-name dependency) (1+ (system-version system))))
dependencies))
(defun system-version (system)
(parse-integer
(format nil "~{~A~}" (uiop:split-string
(ql-dist:version (ql-dist:dist system))
:separator "-"))))
(defun format-long-description (text)
(let ((scanner (ppcre:create-scanner "^[ ]*$" :multi-line-mode t)))
(ppcre:regex-replace-all
scanner
(format nil "~{ ~A~%~}"
(uiop:split-string text :separator "
"))
" .")))