How to forcefully upgrade all your FreeBSD ports using portupgrade
When moving from one major FreeBSD branch to another, you are almost compelled to upgrade all of your installed FreeBSD ports. If you move from the RELENG_7
branch to RELENG_8
, as an example, the old pty
interface is deprecated, and ports such as screen
(sysutils/screen
) must be recompiled and reinstalled to take advantage of the new pts
interface.
As a precaution, you should first remove all traces of the GNU auto tools. They are only build tools and the presence of old versions may affect the upgrade process negatively.
cd /var/db/pkg pkg_delete -i auto*
If you are using portupgrade
(from ports-mgmt/portupgrade
) to handle the upgrade, then you should first forcefully upgrade Berkeley DB 4.1 (databases/db41
), Ruby 1.8 (lang/ruby18
), and everything that depends on Berkeley DB 4.1 and Ruby 1.8. This will give you a fresh set of tools for upgrading the remaining ports.
Just to be sure, check and see what incarnation of Berkeley DB databases/ruby-bdb
actually depends on.
less -S /var/db/pkg/ruby18-bdb-*/+CONTENTS
Look for lines similar to these.
@pkgdep db41-4.1.25_4 @comment DEPORIGIN:databases/db41
If, say databases/db42
is shown instead of databases/db41
, then replace databases/db41
with databases/db42
in every command presented below.
This command takes care of upgrading the ports relevant to the portupgrade
utility.
/usr/local/sbin/portupgrade -fprv databases/db41 lang/ruby18
Next, you should update and verify the integrity of the pkg and ports databases utilized by the portupgrade
utility.
/usr/local/sbin/pkgdb -u /usr/local/sbin/pkgdb -F /usr/local/sbin/portsdb -u /usr/local/sbin/portsdb -F
If, for some reason, pkgdb
or portsdb
complains about the internal structure of the pkg and/or ports databases, simply delete the database files and recreate them from scratch using these commands:
rm /var/db/pkg/pkgdb.db rm /usr/ports/INDEX-?.db /usr/local/sbin/pkgdb -u /usr/local/sbin/portsdb -u
Now, you must upgrade all installed ports. This command upgrades all your installed ports, including those ports upgraded by the previous command.
/usr/local/sbin/portupgrade -afprv
Should the upgrade process skip a few ports, it may be necessary to remove stray work directories from the /usr/ports
hierarchy before attempting another run.
find /usr/ports -depth 3 -name work -type d -print > /usr/ports/work-directories.tmp rm -Rf `cat /usr/ports/work-directories.tmp` rm /usr/ports/work-directories.tmp
If you are curious about what portupgrade
is planning to do, you might want to throw in the -n
switch to do a dry run of the upgrade process.
/usr/local/sbin/portupgrade -nfprv databases/db41 lang/ruby18 /usr/local/sbin/portupgrade -nafprv
Remember to run portupgrade
without the -n
switch to actually accomplish the upgrade.