Recently in Ubuntu Category

In an earlier post I said that I'd post details on how to manually remove stale diversions with dpkg-divert if anyone wanted them. Uwe Koch asked, so here it is!

Solution

The first problem is to find the stale diversions. If you type something like:

$ dpkg-divert --list
You'll get several lines like this:
diversion of /usr/lib/libGL.so.1.2 to /usr/lib/fglrx/libGL.so.1.2.xlibmesa by xorg-driver-fglrx

Since you want to filter out the ones that apply to the ATI drivers, and all of them contain fglrx, you can do this:

$ dpkg-divert --list | grep fglrx

The bit you want is the first path. You can extract that with either:

$ dpkg-divert --list | grep fglrx | cut -d' ' -f3

or

$ dpkg-divert --list | awk '/fglrx/ {print $3}'

You should get a list like this:

/usr/lib/libGL.so.1.2
/usr/X11R6/lib/libGL.so.1.2
/usr/X11R6/lib32/libGL.so.1.2
/usr/X11R6/lib32/libGL.so.1
/usr/lib32/libGL.so.1.2
/usr/lib32/libGL.so.1

You can then manually go through the list, removing the diversions one-by-one:

$ sudo dpkg-divert --remove /usr/lib/libGL.so.1.2

Alternatively, if you're highly confident in your own bash-fu skills:

$ dpkg-divert --list | awk '/fglrx/ {print $3}' | \
> while read; do \
>    sudo dpkg-divert --remove $REPLY; \
> done

The above is shown broken over four lines just so that it isn't too wide for the web-page: in practice, I would type it all on one line. This is what is “really looks like” completely: the backslashes (\) are typed in and escape the newline which must follow immediately. Bash supplies the > character at the start of each line, which is the secondary shell prompt.

Job done!

On Ubuntu 8.04 “Hardy”, the ATI Catalyst 8.4 Driver .deb packages for amd64 will build from the ATI download, but one of the four packages, xorg-driver-fglrx_8.476, will not install out of the box when you try to install the packages in the usual way.

The problem is an error in the preinstall script for the package. In a Debian package, one of the things that a package script sometimes does is “divert” files. The idea is that a package can specify that any attempt by a future package to install a file having a particular name is to be handled by renaming the file to something else, or diverting it. In this way, a package can protect files from being overwritten without causing another package to fail to install. If you have customised a package-supplied file, which might be overwritten by a package upgrade, you can use dpkg-divert to protect your version.

The ATI xorg driver package uses this facility to stop MesaGL, a software Open GL renderer, from overwriting the ATI hardware drivers. That's a good thing, but the problem is that the preinstall script diverts two files to the same target. In other words, it says “instead of installing /foo/bar, rename it /foo/quux” then a second later, “instead of installing /foo/baz, rename it /foo/quux as well”. That's not allowed (because it's obviously stupid).

This accounts for the seemingly bizarre error-message that xorg-driver-fglrx_8.476 is trying to divert to a file target that it, itself, has already diverted another file to!

I suspect that the person who wrote the script copy'n'pasted the line, remembered to edit the filename to divert, but forgot to change where it was diverted to. An easy, if silly, mistake to make. ATI have made a lot of progress in providing decent Linux driver, maybe we shouldn't be too hard on them for lousy QA.

The fix follows below the fold…

The later “Catalyst” version of the ATI proprietary drivers, 8.2 (8.45.5), 8.1 (8.45.2), and 7.11 (8.43.3) do not have this problem, so this page is now obsolete.

The previous non-Catalyst version, 8.42.3, solved a long-standing problem with the ATI proprietary drivers for the first time: not being able to run Compiz or Beryl easily because of lack of support for compositing.

The driver packages, for all versions, allow you to build .deb packages for a variety of distributions, including Ubuntu/gutsy, like this:

$ sh ./ati-driver-installer-8.42.3-x86.x86_64.run --buildpkg Ubuntu/gutsy

Unfortunately, on x86_64 (aka amd64), building the 8.42.3 package failed with an error message about missing files in X11R6/lib:

# amd64 needs some library redirection

[snip]

dh_install -pxorg-driver-fglrx "usr/X11R6/lib/modules/dri"     "usr/lib32"
cp: cannot stat `./usr/X11R6/lib/modules/dri': No such file or directory
dh_install: command returned error code 256
make: *** [binary] Error 1
Removing temporary directory: fglrx-install.E10832

The problem was that ATI's build script looked for some 32-bit libraries, common to both the 64bit and 32bit drivers, in the wrong place.

Solution

The solution is very easy, you just do the following:

  • Extract the package
  • Copy missing files to their correct location
  • Build the package

Assuming that you've downloaded the package into the “current” directory, all you do is:

$ bash ati-driver-installer-8.42.3-x86.x86_64.run --extract ati-driver
$ cd ati-driver
$ cp -r arch/x86/usr/X11R6/lib arch/x86_64/usr/X11R6/
$ ./packages/Ubuntu/ati-packager.sh --buildpkg gutsy

The packages should build correctly.

After doing this, I was able to install the packages and follow this guide to get Compiz working on Ubuntu/gutsy on an Athlon64 with an ATI X1550.

Boot Process

Ubuntu has abandoned inittab in favour of their homegrown upstart, not in itself a bad thing, but as shipped it is not configured in such a way that some very useful behaviour of inittab is replicated.