Ascertaining installed ports for a specific architecture
When upgrading from one major version of FreeBSD to another, in my case from FreeBSD/amd64 stable/9 to FreeBSD/amd64 stable/10, it’s customary to upgrade the installed ports afterwards, beginning with ports-mgmt/pkg
.
I forcefully upgraded all installed ports using portupgrade -afpv
, but the upgrade of lang/ruby21
failed miserably.
I removed all traces of Ruby 2.1, i.e. ports-mgmt/portupgrade
and databases/ruby-bdb
, before manually compiling and installing lang/ruby21
, databases/ruby-bdb
, and ports-mgmt/portupgrade
using the ports collection.
Now, I needed to know which remaining ports were still compiled for stable/9. The following snippet allowed me to gather the origins of such ports:
pkg query -a %o:%q | grep freebsd:9: | cut -d : -f 1
Now, I could feed that list to the newly installed portupgrade
and upgrade the remaining ports:
portupgrade -fprv `pkg query -a %o:%q | grep freebsd:9: | cut -d : -f 1`
In the end, I should have removed lang/ruby21
completely after upgrading ports-mgmt/pkg
, and reinstalled ports-mgmt/portupgrade
manually using the ports collection. Only then is it safe to forcefully rebuild and reinstall all the other ports. Don’t forget to add devel/cvs
if you used to rely on cvs
in base, and adjust all references from /usr/bin/cvs
to /usr/local/bin/cvs
.