Portmaster
This article is about Portmaster, my ports management tool of choice.
Portmaster config file
Portmaster works like a charm with the default configuration. These config file options are mostly nice-to-have, not strictly neccesary. The portmaster config file is called /usr/local/etc/portmaster.rc
Automatically delete old distfiles
One of the things that annoyed me after a while is the fact that Portmaster doesn't delete old distfiles without asking first - so I would start a large upgrade, answer all the make config screens that Portmaster is clever enough to show me all at once, and then go do something else. Only to come back and see Portmaster waiting for my OK to delete libsomething-1.2.3.tar.bz2 (which has already been replaced by a new installed version). I can see why this may be nice for some people, but I want it to delete old distfiles without asking me, so I put the following line in /usr/local/etc/portmaster.rc
:
ALWAYS_SCRUB_DISTFILES=dopt
That's it.
Automatically delete build depencencies after install
When installing stuff I often end up with a bunch of build dependencies that I don't need after the port has been built. Portmaster can remove these automatically, and will do so if given the command line option --delete-build-only
or if the following line is present in /usr/local/etc/portmaster.rc
:
PM_DEL_BUILD_ONLY=pm_dbo
This makes Portmaster clean up the build-only dependencies automatically.
Keeping ports up-to-date is generally problem-free, until some shared library gets a version bump. The problem is easiest illustrated with an example:
Sometime during the summer of 2010 the port devel/gettext
was updated, and the update meant that the shared library /usr/local/lib/libintl.so.8
was replaced with /usr/local/lib/libintl.so.9
. The shell I use depends on this library, among others:
/usr/local/bin/bash: libncurses.so.8 => /lib/libncurses.so.8 (0x8006e7000) libintl.so.9 => /usr/local/lib/libintl.so.9 (0x800834000) libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x80093d000) libc.so.7 => /lib/libc.so.7 (0x800b37000)
The problem is that because I upgraded devel/gettext
without reading /usr/ports/UPDATING
I didn't rebuild shells/bash
, so it still depended on the old library /usr/local/lib/libintl.so.8
which was deleted when I updated devel/gettext
. This meant that bash stopped working and I could no longer log onto the server. What I should have done is run portmaster -r devel/gettext
which would have upgraded devel/gettext
and then every port that depends on it. I forgot, and I could certaintly forget again, so I add the following option to portmasters config, which makes it save old libraries when upgrading:
SAVE_SHARED=wopt
The old shared libraries are saved in /usr/local/lib/compat/pkg
Portmaster log file
Sometimes it is nice to have a record of when I upgraded which ports. Maybe something stopped working roughly a week ago and I can go back to see which upgrade might have caused it. I add the following to the config:
PM_LOG=/var/log/portmaster.log
Ignore failed backup package
Portmaster automatically builds a backup package of the installed port when uninstalling before installing a new version. Sometimes if I manually deleted some files from a port, the package creation process will fail. While the feature is nice, I would like it to just continue when this happens, so I add the following to the config:
PM_IGNORE_FAILED_BACKUP_PACKAGE=pm_ignore_failed_backup_package
Complete portmaster config
For copy-pasting purposes, here is the complete config:
ALWAYS_SCRUB_DISTFILES=dopt PM_DEL_BUILD_ONLY=pm_dbo SAVE_SHARED=wopt PM_LOG=/var/log/portmaster.log PM_IGNORE_FAILED_BACKUP_PACKAGE=pm_ignore_failed_backup_package
Reinstall all ports
To reinstall (recompile and install) all installed ports, and at the same time upgrade the outdated ports I run the following command:
# portmaster -af
This should be done after upgrading the OS, that is, after going from one major version to another (like from 7.x to 8.x). Portmaster will give you a nice list with the actions it has performed after it finishes.
There is a lot of [other options] to portmaster of course, but like I said, the defaults are fine for me. Eventually I will update this page with more Portmaster commands and tricks.