Title: Using awk to pretty-display OpenBSD packages update changes Author: Solène Date: 04 December 2021 Tags: openbsd awk Description: # Introduction You use OpenBSD and when you upgrade your packages you often wonder which one is a rebuild and which one is a real version update? The packages updates are logged in /var/log/messages and using awk it's easy to achieve some kind of report. # Command line The typical update line will display the package name, its version, a "->" and the newer version of the installed package. By verifying if the newer version is different from the original version, we can report updated packages. awk is already installed in OpenBSD, so you can run this command in your terminal without any other requirement. ```shell command line awk -F '-' '/Added/ && /->/ { sub(">","",$0) ; if( $(NF-1) != $NF ) { $NF=" => "$NF ; print }}' /var/log/messages ``` The output should look like this (after a pkg_add -u): ```command line output Dec 4 12:27:45 daru pkg_add: Added quirks 4.86 => 4.87 Dec 4 13:01:01 daru pkg_add: Added cataclysm dda 0.F.2v0 => 0.F.3p0v0 Dec 4 13:01:05 daru pkg_add: Added ccache 4.5 => 4.5.1 Dec 4 13:04:47 daru pkg_add: Added nss 3.72 => 3.73 Dec 4 13:07:43 daru pkg_add: Added libexif 0.6.23p0 => 0.6.24 Dec 4 13:40:41 daru pkg_add: Added kakoune 2021.08.28 => 2021.11.08 Dec 4 13:43:27 daru pkg_add: Added kdeconnect kde 1.4.1 => 21.08.3 Dec 4 13:46:16 daru pkg_add: Added libinotify 20180201 => 20211018 Dec 4 13:51:42 daru pkg_add: Added libreoffice 7.2.2.2p0v0 => 7.2.3.2v0 Dec 4 13:52:37 daru pkg_add: Added mousepad 0.5.7 => 0.5.8 Dec 4 13:52:50 daru pkg_add: Added munin node 2.0.68 => 2.0.69 Dec 4 13:53:01 daru pkg_add: Added munin server 2.0.68 => 2.0.69 Dec 4 13:53:14 daru pkg_add: Added neomutt 20211029p0 gpgme sasl 20211029p0 gpgme => sasl Dec 4 13:53:20 daru pkg_add: Added nethack 3.6.6p0 no_x11 3.6.6p0 => no_x11 Dec 4 13:58:53 daru pkg_add: Added ristretto 0.12.0 => 0.12.1 Dec 4 14:01:07 daru pkg_add: Added rust 1.56.1 => 1.57.0 Dec 4 14:02:33 daru pkg_add: Added sysclean 2.9 => 3.0 Dec 4 14:03:57 daru pkg_add: Added uget 2.0.11p4 => 2.2.2p0 Dec 4 14:04:35 daru pkg_add: Added w3m 0.5.3pl20210102p0 image 0.5.3pl20210102p0 => image Dec 4 14:05:49 daru pkg_add: Added yt dlp 2021.11.10.1 => 2021.12.01 ``` # Limitations The command seems to mangle the separators when displaying the result and doesn't work well with flavors packages that will always be shown as updated. At least it's a good start, it requires a bit more polishing but that's already useful enough for me. |