Where is the latest snapshot?
I often have the need to upgrade my machine. Snapshots are here for that but I never know from which mirror take them. So here comes, up2date, a web page showing all OpenBSD ftp mirrors, sorted by freshest snapshots.
The idea is simple : a perl script parses ftp.html using WWW::Mechanize, grabs ftp:// urls, then connects to each mirror using Net::FTP and fetches the last modification date of base42.tgz, xbase42.tgz and zoom-1.0.1.tgz (arbitrarily choosen in last packages), and stores each one in a large hash for i386, sparc64 and amd64 (randomly chosen as most used archs).
Then, with some magic from Template module, it generates the web page you see using this template. Nothing more, nothing less. BTW, it's a first shot, code may be ugly, but the main idea is here…
This page is generated nightly by a cron job on my personal machine, and I'll try to keep it up to date and available.
I want to be notified of updates!
As some may have noticed, two D-Bus notification daemons have been recently imported, I wanted to play a little with it and D-Bus, that was the perfect occasion. The result is update-notifier, another little perl hack.
Here, it uses LWP::Simple to fetch this RSS feed showing all changes made to the ports-tree and kindly provided by folks at ports.openbsd.nu. Then, with the help of XML::Simple, each item is parsed from the feed, and if it has not already been seen it's added to another hash. Then, in /var/run/update-notifier it writes the timestamp of the last item seen in the feed to avoid displaying the entire feed each time.
Finally, using the recently committed Net::DBus module, a connection to the local D-Bus session daemon is made, and a notification containing all updates/new/removed ports is sent to the notification daemon which displays it. An image is often better than words, so here is the mandatory screenshot.
If you want to use it, simply install prerequisite perl modules and one of the available notification daemons, be sure that D-Bus daemon is launched with your session, drop update-notifier somewhere on you system and simply run it from a crontab. Who said OpenBSD was not ready for daily desktop use? :) BTW, I know following ports-changes is another way to be noticed when ports are updated, but this code was fun to write and debug…