# HG changeset patch # User František Kučera # Date 1554843220 -7200 # Node ID a390662645097860e62e46acbb50864eb47e0993 # Parent 822ffd23d679611ae9c5b47effb1a537b59f21f1 examples: Reading apt (Debian package system) results diff -r 822ffd23d679 -r a39066264509 relpipe-data/examples-apt.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relpipe-data/examples-apt.xml Tue Apr 09 22:53:40 2019 +0200 @@ -0,0 +1,99 @@ + + + Reading apt (Debian package system) results + using Recutils and/or Relational pipes + 02000 + + + +

+ Debian, Ubuntu and other derived GNU/Linux distributions have their package system based on the .deb packages and tools like apt (or formerly aptitude and apt-get). + This is a command line tool for installing packages and also for searching, showing metadata and other related tasks. + We can show a metadata for a package this way: +

+ + + +

+ This is some kind of ordinary human-readable listing. + But, it seems familiar, like we have met somewhere before… Yes, it is almost the same format as recfile from GNU Recutils! + There are field names, colons and values. Each pair on a separate line. + And there is also a convention for multi-line text – just with a little difference: indentation instead of +. + But we can tune it with just a little sed transformation + and then read it like a recfile: +

+ + + +

And print results in a pretty table:

+ +
+ +

+ We can use also GNU Recutils, but we have to rename some fields like Installed-Size because the - hyphen does not seem to be edible. + This can be fixed this way: +

+ + + +

However, it is still quite dirty, because apt complains about:

+ +
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
+ +

+ So it would be better to introduce some machine-readable output in the apt tool. + But until that: Happy hacking! + For some ad-hoc operations it is usable and we can e.g. convert the results to a CSV or a LibreOffice Calc file (ODS). +

+ + apt-packages.fods]]> + +

The machine-readable format should also carry the sizes in bytes instead of human-friendly units.

+ +

Good news are that the Guix SD package system already prints results in regular recfile format.

+ +
+ +