site

bvnf.space sources
Log | Files | Refs

commit d55d731007b7adbe18e2742c1f20518bb06165e0
parent 845c063cf6d0370bc53b0182d234e4f7a32c796f
Author: phoebos <ben@bvnf.space>
Date:   Fri, 30 Jun 2023 03:51:06 +0100

blog: new post

Diffstat:
Ablog/009-fulldeps.html | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amedia/bar.png | 0
Amedia/hist.png | 0
3 files changed, 99 insertions(+), 0 deletions(-)

diff --git a/blog/009-fulldeps.html b/blog/009-fulldeps.html @@ -0,0 +1,99 @@ +<!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;} + </style> +</head> +<body> +<h1>bliss-fulldepends</h1> + +<p>I've been writing <a href="//git.bvnf.space/bliss/">an implementation of kiss + in Lua</a>, called bliss, 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]&lt;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, showing 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> diff --git a/media/bar.png b/media/bar.png Binary files differ. diff --git a/media/hist.png b/media/hist.png Binary files differ.