Are all installed packages available for reinstall?

When you install a package, you want to know it’s still around to reinstall. You’ve probably never given this much thought. Neither had I, until I read this post on Reddit.

In my case, I run my own poudriere server which allows me to run my own package server.

Why run your own package server?

  1. build ports with non-default configuration settings: Want databases/mantis build for PostgreSQL, not MySQL? (and who wouldn’t?) – You can set that with this in a poudriere configuration file:
    databases_mantis_UNSET+=MYSQL
    databases_mantis_SET+=PGSQL
  2. Was your favourite ports updated? Want to install it tomorrow? poudriere will build it overnight.
  3. Was something just patched for a security releated issue? Want to install it right now and now wait for the FreeBSD build servers? poudriere.

Why bother with orphans?

It is because I am runing my own package server that I want to know if a package is unavailable for reinstall. If that situation arises, it means I’ve done something wrong. Or as the case may be, and i’ll show it later, not done something right.

If you are not running a packge server, you will still want to now if you can’t reinstall a package. If you’re using it now, you’ll probably want to use it in the future.

The script

Directly from the reddit post, I decided to create a monitoring check based on this idea. Here is that script (also available from my git repo):

[dan@zuul:~] $ cat /usr/local/libexec/nagios-custom/check-pkg-availability
#!/bin/sh

# Verify all packages are available in the repo
# re https://www.reddit.com/r/freebsd/comments/nujgxe/understanding_orphaned_packages/

orphans=$(pkg version -vRL= | grep orphaned)
if [ -z "$orphans" ]
then
  echo "All packages are in the upstream repo"
  exit 0
else
  echo "$orphans"
  exit 2
fi

This was designed to be used by Nagios, I’m sure you can use it with any other monitoring system.

How did this help?

Here are some example of how this script has helped me.

I found three servers which had nagios-check_smartmon-py37 installed. They should have had nagios-check_smartmon-py38 installed.

I discovered that I installed sysutils/ansible-sshjail on my ansible server but never added it to the list of packages to build. I had build it manually to install it, but never set myself up to build it in the future.

Similary for benchmarks/iperf.

A host with php72 installed long after I had moved to php74.

I found 16 such packages on one host. I did not recognize the packages. I suspect they were installed for some reason lost to me. I deleted one. That removed 6 packages. I ran pkg autoremove which removed the remaining 10 packages.

This script is helping me discover issues now before they cause grief later.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top