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
89
90
91
92
93
94
95
96
97
98
99
100
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>bliss-fulldepends</title>
<link rel="icon" href="data:image/gif;base64,R0lGODlhEAAQAPH/AAAAAP//AAD/AP8AACH/C0NSTkcAAAAAMS4wSAAAAAIwPwAAAAJATwAAAAJQXwAAAAJgbwAAAAJwfwAAAAKAjwAAAAKQnwAAAAKgrwAAAAKwvwAAAALAzwAAAALQ3wAAAALg7wAh+QQF//8EACwAAAAAEAAQAAACOJQFqTp9j5p00IApq8X0rTtBSQCQYIeUZGBmh7qyp8fGpGvV8PyqPt9bJUKiBUYT4SBPRMuH0SgAADs="/>
<style type="text/css">
body {font-family: sans-serif; padding: 2ch; margin: auto; max-width: 50em; color:black; background: #fff;}
pre { margin: 0; padding: 1ch;}
h1 { font-size: 1.4em;}
img { max-width: 100%; height: auto;}
</style>
</head>
<body>
<h1>bliss-fulldepends</h1>
<p>I've been writing an implementation of <a href="//web.archive.org/web/20231225090525/https://kisslinux.org/wiki/package-manager">kiss</a>
in Lua, called <a href="//git.bvnf.space/bliss/">bliss</a>, and I just finished a <code>pkg.order</code>
function, which performs a topological sort to order packages so that
dependencies are built first. This function can also be used to get the full,
recursive dependency list of a package, which I think is sort of interesting, so
I wrote <a href="http://git.bvnf.space/bliss/file/contrib/bliss-fulldepends.html">a quick script</a>.</p>
<details>
<summary>View the code</summary>
<pre><code>#!/usr/bin/env lua
-- Display all dependencies of packages (recursively)
local bliss = require "bliss"
local dirent = require "posix.dirent"
local function lists(env, arg)
if #arg == 0 then
for file in dirent.files(env.sys_db) do
if string.sub(file, 1, 1) ~= "." then
table.insert(arg, {file, #bliss.order(env, {file})})
end
end
table.sort(arg, function (a,b) return a[2]<b[2] end)
for _,v in ipairs(arg) do print(v[1],v[2]) end
else
local deps = bliss.order(env, {arg[1]})
for _,v in ipairs(deps) do print(v) end
end
end
if arg[1] == "-h" then
print("usage: "..arg[0].." [pkg]")
print(" With no args, list installed packages by total number of dependencies")
print(" With an arg, list full dependencies of pkg")
os.exit()
end
local env, atexit = bliss.setup()
table.insert(env.PATH, 1, env.sys_db)
lists(env, arg)</pre></code></details>
<p>Here's what you can do with it.</p>
<ul>
<li>List all your installed packages by number of total dependencies:
<pre><code>$ bliss-fulldepends
scheme-manpages 1
libogg 1
...
zathura-pdf-poppler 91
firefox 102</pre></code>
</li>
<li>List the total dependencies for a package (topologically sorted):
<pre><code>$ bliss-fulldepends kiss
certs
zlib
openssl
curl
git
b3sum
kiss</pre></code>
i.e. kiss depends on b3sum and git; git depends on curl, and so on.
</li>
</ul>
<p>And no, it's not horribly slow: for my system, the former takes <code>150ms</code> and the latter <code>6ms</code>.
The listing of all packages could be sped up by caching the dependency lists rather than walking through them all again for each package installed,
but it's fast enough for me.</p>
<p>Here's a bar chart of number of total dependencies on my system:
<figure><img src="/media/bar.png" alt="bar chart" height="480px"/></figure>
And here is a histogram of the same information, emphasizing how many just have 1 "dependency" (themselves).
<figure><img src="/media/hist.png" alt="histogram of the same data" height="480px"/></figure>
</p>
<hr />
<p>written 2023-06-30</p>
<p><a href="../">Home</a></p>
<p><a href="./">Blog home</a></p>
</body>
</html>
|