Automating package updates on FreeBSD
When updating my ports, I prefer to use packages when I have not changed the options of a port. This describes how I do that.
Compiling large programs like firefox can take a long time. Therefore I like to use packages when updating my ports. But I don’t want to loose any custom options I might have chosen.
This is basically divided into two parts,
- Finding out which ports can be updated by packages.
- Downloading and installing packages.
For the first part, we need to ascertain that the actual options used on
a port (from
pkg query) match the default values (from inspecting the
value of the
OPTIONS_DEFAULT “make” variable in the port). This is
accomplished by the find-pkg-upgrades Python script. I will not cover it
workings in more detail. Suffice it to say that it produces a list of port
names that can be updated by a package.
For the second part, one could just run
pkg upgrade. This however has some
annoying side effects. For example it often tries to install Python
3.6, while I use 3.7. This is fair enough since 3.6 is the default, but
I don’t need it. Often it also installs the deprecated Perl version 5.26,
which annoys me to no end. And to the best of my knowledge the upgrade command
does not have an option to force it to only upgrade the packages I specified.
So I do the following.
- Empty the package cache (
pkg fetchto get the new packages.
pkg delete -fto delete only the selected old packages.
pkg addto install the new packages from the package cache.
This ensures that only the packages I choose are updated. (These commands have been combined into a shell-script. Since this is rather trivial I didn’t bother putting it on github.)
For comments, please send me an e-mail.
- Updating to FreeBSD 9.1-RELEASE-p1
- Updating to FreeBSD 8.1-RELEASE
- Writing speed on FreeBSD 13.1-p2 amd64 with ZFS
- FreeBSD 13.1 install on a Lenovo IdeaPad 5
- Gnumeric build fix for FreeBSD