Manually Removing Diversions with dpkg-divert

| | Comments (1) | TrackBacks (0)

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!

0 TrackBacks

Listed below are links to blogs that reference this entry: Manually Removing Diversions with dpkg-divert.

TrackBack URL for this entry: http://caulfield.info/mt/tb.cgi/21

1 Comments

Hi Emmet,

thank you so much for the help. I did what you suggest and get the following message, either after doing it manually or via script:


Eliminando `diversion of /usr/lib32/libGL.so.1 to /usr/lib32/fglrx/libGL.so.1.xlibmesa by xorg-driver-fglrx'
dpkg-divert: renombrar obliga a sobreescribir `/usr/lib32/libGL.so.1' con
un fichero distinto `/usr/lib32/fglrx/libGL.so.1.xlibmesa', no está permitido.

"Removing 'diversion of *.so.1 to *.xlibmesa by xorg-driver-fglrx'
dpkg-divert: renaming forces to overwright '*.so.1' with a different filename '*.si.1', it is not allowed.

Any idea how to force it, if applicable?