Upgrading from xorg-6.9 to xorg-7.2

Back in December 2005, X.Org switched from a monolithic (i.e. a few massive packages, like KDE) to a modular (i.e. many smaller packages, like Gnome) code base. It took a great deal of effort, but xorg-7.2 has finally made its way into FreeBSD Ports!

Upgrading from xorg-6.9 to xorg-7.2 is no small task. Aside from a handful of large packages being split into several hundred small packages, /usr/X11R6 as {X11BASE} has been obsoleted. As a result, all packages are now supposed to install in {LOCALBASE}, which on most systems will be /usr/local (unless the user has modified this value).

Because this upgrade will involve rebuilding a significant portion of your installed packages, it can take a very long time. (Over 100 hours on my ThinkPad 1300, but in fairness I had a very large number of software packages installed on that system). Therefore, you should wait until you can leave the computer on for a significant length of time before undertaking this upgrade.

The following instructions were taken from http://wiki.freebsd.org/XorgUpgradeCorrected and /usr/ports/UPDATING, with a few of my own notes added. If in doubt you should place your trust in /usr/ports/UPDATING. Without further ado, let's upgrade to xorg-7.2:

portupgrade-devel has been reported as fixing some annoying bugs with the older portupgrade package. Therefore, we're going to upgrade this tool first:

portupgrade -o ports-mgmt/portupgrade-devel -f portupgrade

Once portupgrade has been updated, it's time to start the xorg upgrade process. In the event that you run into problems with the upgrade, the xorg developers have asked that you perform the upgrade within a script:

script xorg-upgrade

This will record what happens during the upgrade. Useful to a kind developer trying to help you with any problems that arise.

rm -f /usr/ports/INDEX*.db /var/db/pkg/pkgdb.db

This will force the Ports INDEX database and package databases to be rebuilt when we attempt the upgrade.

If you are using Nvidia's nvidia driver, you'll want to set the following in /etc/make.conf:

WITH_NVIDIA_GL=yes

If you're not sure if you're not sure if you have Nvidia's nvidia driver installed, you can check by running the following command:

pkg_info | grep nvidia-driver

If you have the driver installed, it'll show up. If nothing shows up, you don't have the driver installed and don't need to add that above line to /etc/make.conf.

Back to the xorg upgrade. . .

export XORG_UPGRADE=yes

The above command will work if you're using the default shell, or any other sh-like shell (such as zsh). If you're using csh or a csh-like shell, you'll instead want to use the command "setenv XORG_UPGRADE yes".

Up to this point you can still turn back. If you're sure you're ready to go ahead with this big upgrade. . .

portupgrade -Rf libXft && portupgrade -akO

This will take a very, very long time on older systems like my ThinkPad 1300, especially if you have a lot (i.e. over 500) of packages installed. Alternatively, you could save a bit of time by using binary packages instead of Ports where available, by substituting the above command with:

portupgrade -Rf libXft && portupgrade -aPkO

NOTE: the above command will not make much of a difference unless you have your system configured to use more up-to-date packages by following our instructions here.

At this point, the upgrade on my ThinkPad failed with a portupgrade error. I simply deleted /var/db/pkg/pkgdb.db and /usr/ports/INDEX*.db again, and repeated the above command. After that everything went smoothly. Things didn't go quite as smoothly on my parents' amd64 system, but following this simple formula in the event of an error restarted the process and got things back on track:

cvsup /root/ports-supfile
pkgdb -F

For an explanation of the pkgdb -F tool, check our page here.

export XORG_UPGRADE=yes

Yes, we already set this before, but it won't hurt to do it again just to be safe. This is absolutely necessary if you restarted your computer before reattempting the xorg upgrade.

portupgrade -Rf libXft && portupgrade -aPkO

Hopefully that will get things back on track. It did on our test machines.

Once that very long upgrade process has completed, we're almost there. Just a few more housekeeping matters to take care of:

pkg_delete xorg-manpages\*

Which will delete the old xorg-manpages package from xorg-6.9. Last but not least, a very important step to avoid headaches with some packages that have not yet been migrated fully from /usr/X11R6 to /usr/local:

sh /usr/ports/Tools/scripts/mergebase.sh

On my system, the mergebase.sh script exited with an error about a conflict between {X11BASE} and {LOCALBASE}. (The culprits appeared to be Opera and GConf: I suspect I simply had leftover directories from older versions of each from before they moved to {LOCALBASE} some time ago). Although it shouldn't hurt anything to simply leave /usr/X11R6 intact, I went ahead and deleted /usr/X11R6 (after first copying my custom fonts directories to /usr/local), and most of my installed packages are still working happily. If need be I could manually create a symbolic link to /usr/localbase:

ln -s /usr/localbase /usr/X11R6

You have now upgraded to xorg-7.2! Before your next restart, you'll want to fix the font paths in /etc/X11/xorg.conf:

vi /etc/X11/xorg.conf

Change the lines with /usr/X11R6 in them. (i.e., your font paths). Change these to /usr/local. For example, change the line:

FontPath "/usr/X11R6/lib/x11/fonts/webfonts/"

To the following:

FontPath "/usr/local/lib/x11/fonts/webfonts/"

That way the nice fonts you added to your system will still show up in your upgraded xorg.

To change all of the /usr/X11R6 lines to /usr/local using vim,

:%s/X11R6/local

This will find and replace every instance of X11R6 with local.

Congratulations! You have successfully upgraded to xorg-7.2!

If everything went smoothly, it's time to end our xorg-upgrade script:

exit

You can then delete the file if you want, once you've restarted and confirmed that everything is working properly.

If, on the other hand, something goes wrong during the upgrade, run the following commands:

uname -a
ls -l /var/db/pkg
exit

Then e-mail freebsd-x11@freebsd.org, describing your problem. Make sure to note that you created an xorg-upgrade script that you can send to one of the developers upon request, but do not attach it to your original e-mail. If a developer asks for a copy of your xorg-upgrade script. . .

bzip2 xorg-upgrade

And e-mail it to the requesting developer. Hopefully troubleshooting will be unnecessary, however. The upgrade went smoothly on my ThinkPad (i386, running FreeBSD 7.0-CURRENT), on my parents' amd64 machine (running FreeBSD 6.2-RELEASE), on Dan's i386 machine running 6.2-RELEASE, and on our brother Mark's i386 machine running 6.2-RELEASE, so hopefully it will go smoothly for you as well. If you do run into a problem, be patient, don't panic, explain your problem to one of the developers on the freebsd-x11 mailing list, and relax. FreeBSD has a wonderful support community.