-
Notifications
You must be signed in to change notification settings - Fork 0
/
data-files.lisp
31 lines (28 loc) · 1.23 KB
/
data-files.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
(in-package #:qldeb)
(defun make-data-files (archive system)
(let ((data-files (make-array 0 :adjustable t :fill-pointer 0)))
(multiple-value-prog1 data-files
(loop-entries (entry archive)
(when (archive:entry-regular-file-p entry)
(let ((bytes (make-array (archive::size entry)
:element-type '(unsigned-byte 8))))
(read-sequence bytes (archive:entry-stream entry))
(vector-push-extend
(make-instance
'deb-packager:deb-file
:path (pathname
(format nil "usr/share/common-lisp/source/~A/~A"
(system-name system)
(format-path (archive::%name entry))))
:content bytes
:size (length bytes)
:mode (octal-to-integer (archive::mode entry)))
data-files)))))))
(defun octal-to-integer (octal)
(parse-integer (format nil "~8R" octal)))
(defun format-path (path)
(format nil "~{~A~^/~}" (subseq
(uiop:split-string
(flexi-streams:octets-to-string path)
:separator "/")
1)))