master
pm
1#!/bin/guile
2!#
3
4;; print manifests
5;; a extension for dtr written in guile
6;; usage: dtr pm <pkg>
7
8(use-modules (ice-9 popen)
9 (ice-9 rdelim)
10 (srfi srfi-1))
11
12(define pkg
13 (string-trim-right
14 (last
15 (string-split
16 (cadr (command-line))
17 #\/
18 ))
19 #\newline
20 )
21 )
22
23(define l '())
24
25(call-with-input-file
26 (format #f "/var/lib/spc/installed")
27 (lambda (g)
28
29 (unless (member pkg (string-split (read-string g) #\newline) string=?)
30
31 (format #t "~aERROR:~a package '~a' not found~%"
32 "\x1b[31;1m" "\x1b[m"
33 pkg)
34 (exit 1))
35 ))
36
37(call-with-input-file
38 (format #f "/var/lib/spc/lock/~a.lock" pkg)
39 (lambda (f)
40 (set! l
41 (string-split
42 (read-string f)
43 #\newline)
44 )
45 ))
46
47;; https://codeberg.org/kiss-community/kiss/src/commit/32ed1933ac8ccc5816cfdcc51769fe756232fc68/contrib/kiss-size#L28
48
49(let m
50 (
51 (n 0)
52 )
53
54 (when (< n (length l))
55 (let* (
56 (cl (list-ref l n))
57 (p (car (string-split cl #\|)))
58 )
59 (when (not (or
60 (string-contains
61 cl
62 ": "
63 )
64 (string-contains cl "deps:")
65 (string-contains cl "files:")
66 (string-suffix? "/" p)
67 (string-null? p)
68 )
69 )
70
71 (when (string=? p)
72 (format #t
73 "~a~%"
74 p
75 )))
76 (m (+ n 1))
77 )))