Results tagged “ATI drivers ubuntu linux” from Tau Leaping

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…