FreeBSD: when did I last update my ports/packages?

This tip is again FreeBSD only, and won’t work on Linux.

So it’s been a while since you updated your ports and/or packages, and actually you don’t remember exactly when. And now you’re ready to run a new update, but you don’t know from where to start reading /usr/ports/UPDATING before you update.

Luckily, this information can simply be extracted from the SQLite database that contains info on all installed packages. Add the following alias to your ~/.bashrc:

alias pupl='sqlite3 /var/db/pkg/local.sqlite "select datetime(time, \"unixepoch\") from packages order by time desc limit 1"'

Clearly, if you don’t use the Bash shell, you should figure out how to add aliases in your shell. The alias will be active after you re-login; invoke it like any other command.

$ pupl

This alias will display the date and time that the last package or port was updated or installed.

Note: if you last installed a package without updating the already installed packages, this alias will display the date and time for the last installation, and not for the last update!

If you’re going to play around with that database to see what other info you can extract from it, you should probably make a copy of it, to make sure you don’t accidentally write to the original; you don’t want to mess up your package database.

P.s.: the name for the alias comes from ‘Ports UPdated Last’; change it to anything you like.

Related: puptd

REPUBLISHING TERMS

You may republish this article online or in print under our Creative Commons license. You may not edit or shorten the text, you must attribute the article to OhReally.nl and you must include the author’s name in your republication.

If you have any questions, please email rob@ohreally.nl

License

Creative Commons License AttributionCreative Commons Attribution
FreeBSD: when did I last update my ports/packages?