Rescue Ubuntu from unstable PPA issues

ubuntu_logo_81x81It’s too tempting to test out development versions of software and subsystems from PPAs and sometimes there are chances that you will end up in an unstable Ubuntu system. While it is very easy to figure out and fix issues with a single application, things can get complicated when you have an unstable subsystem like X or your desktop environment. I faced a similar situation recently. As I have no plans to move to Ubuntu Saucy from Raring now, I updated to Gnome 3.8 to get a taste of it. Things were running smoothly till I couldn’t wait to check out Gnome 3.10 as well. I installed packages from gnome3-staging and the ricotz-testing PPA and on the next login my notifications won’t work correctly, my custom theme got broken and the panel started refreshing on every window close. I had to struggle a while but I finally sorted things out by moving back to Gnome 3.6 from the Raring official repositories. This article explains how. Symptoms and related packages might be different on another system but the procedure to recover should be similar. Be warned, you need patience to get this done if your system is messed up pretty bad, sometimes even hours depending on your expertise and network speed.

First, you may need to install a different desktop environment to work within. For example, you can’t remove and recover Gnome from within it. As I already had LXDE, I logged-in to LXDE. In addition, have synaptic and ppa-purge installed beforehand. You will have a great advantage if you already had synaptic installed on your system and had history enabled (read, have history enabled from now if you are disabling it). Also, do not reboot till you are done as your system may not boot if you have tampered some boot related packages.

The next step is to try ppa-purge. Try removing the PPAs that led to the problems. The syntax is:

$ sudo ppa-purge ppa:gnome3-team/gnome3 //replace with intended PPA name

Keep a very keen eye on the changes it is going to do to your system before confirming anything, specially the following two sections if they are present:

Remove the following packages:
1) apturl
2) compiz
3) compiz-core
4) compiz-gnome
5) compiz-plugins-default
6) compizconfig-settings-manager
7) evince
...

Leave the following dependencies unresolved:
43) gnome-terminal-data recommends gnome-terminal
44) gucharmap recommends yelp
45) indicator-appmenu recommends indicator-applet | indicator-renderer
...

You may need to manually handle the packages listed in these two sections later, so save them in a text file. If nothing is listed, great! Probably this is the last step you need and you can skip the rest of this article. Otherwise, read ahead. Run:

$ sudo apt-get update

Once you are done with purging the PPAs and you have ended up with a huge list of removed software, open synaptic as root if it is still installed. Otherwise, skip and jump to the next paragraph from here. Try to find the packages (at least some) you have just upgraded (synaptic history could be of great help here if you had it enabled). Select any of the packages and go to Package ▸ Force Version… In the drop down list select the latest version from the base repositories (e.g. in my case raring or raring-updates). Once done, apply the changes. If any package is broken, either remove those as well or, to be safe, stop at the point something is broken and apply just the previous changes. After some iterations this exercise becomes tedious from synaptic due to the numerous dependency packages. Stop and go to the next paragraph to do the same from the terminal in another way.

Open a terminal and become root as you probably won’t love to type sudo repeatedly from now. Open the test file you got from ppa-purge above. Try to start with the important base packages as they will handle their dependencies while installing. For me it was gnome-session. But as you may still have some packages in the system which are at a higher version than provided by base release repositories you will not be able to install everything using apt-get. Here is an example of what I mean; follow the text in bold and the corresponding comments:

root@Tux # apt-get install gnome-terminal //trying to install gnome-terminal
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
gnome-terminal : Depends: libvte-2.90-9 (>= 1:0.30.1-2ubuntu1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

root@Tux # apt-get install libvte-2.90-9 //gnome-terminal depends on libvte-xxx
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libvte-2.90-9 : Depends: libvte-2.90-common (= 1:0.34.2-0ubuntu2) but 1:0.34.6-1ubuntu1~ubuntu13.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.

root@Tux # apt-get install libvte-2.90-common //libvte epends on libvte-xxx-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
libvte-2.90-common is already the newest version. //already at a higher version from another PPA
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

root@Tux # apt-get remove libvte-2.90-common //remove higer version from other PPA
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libvte-2.90-common
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 1,390 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 113274 files and directories currently installed.)
Removing libvte-2.90-common ...

root@Tux # apt-get install libvte-2.90-common //install libvte-xxx-common from standard repo
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libvte-2.90-common
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 22.5 kB of archives.
After this operation, 455 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ raring/main libvte-2.90-common all 1:0.34.2-0ubuntu2 [22.5 kB]
Fetched 22.5 kB in 0s (25.3 kB/s)
Selecting previously unselected package libvte-2.90-common.
(Reading database ... 113174 files and directories currently installed.)
Unpacking libvte-2.90-common (from .../libvte-2.90-common_1%3a0.34.2-0ubuntu2_all.deb) ...
Setting up libvte-2.90-common (1:0.34.2-0ubuntu2) ...
Installing new version of config file /etc/profile.d/vte.sh ...
localepurge: Disk space freed in /usr/share/locale: 0 KiB
localepurge: Disk space freed in /usr/share/man: 0 KiB
localepurge: Disk space freed in /usr/share/gnome/help: 0 KiB
localepurge: Disk space freed in /usr/share/omf: 0 KiB

Total disk space freed by localepurge: 0 KiB

root@Tux # apt-get install gnome-terminal //install gnome-terminal
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
gnome-terminal-data gnome-user-guide libvte-2.90-9 libwebkitgtk-3.0-0
libyelp0 yelp
Suggested packages:
gstreamer1.0-ffmpeg
The following NEW packages will be installed:
gnome-terminal gnome-terminal-data gnome-user-guide libvte-2.90-9
libwebkitgtk-3.0-0 libyelp0 yelp
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 10.3 MB/10.4 MB of archives.
After this operation, 57.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ raring/main libvte-2.90-9 amd64 1:0.34.2-0ubuntu2 [258 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ raring/main libwebkitgtk-3.0-0 amd64 1.10.2-0ubuntu1 [8,231 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ raring/main libyelp0 amd64 3.6.2-0ubuntu1 [109 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ raring/main yelp amd64 3.6.2-0ubuntu1 [43.3 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ raring/main gnome-user-guide all 3.6.2-0ubuntu1 [1,632 kB]
Fetched 10.3 MB in 49s (208 kB/s)
Selecting previously unselected package libvte-2.90-9.
(Reading database ... 113180 files and directories currently installed.)
Unpacking libvte-2.90-9 (from .../libvte-2.90-9_1%3a0.34.2-0ubuntu2_amd64.deb) ...
Selecting previously unselected package gnome-terminal-data.
Unpacking gnome-terminal-data (from .../gnome-terminal-data_3.6.1-0ubuntu4_all.deb) ...
Selecting previously unselected package gnome-terminal.
Unpacking gnome-terminal (from .../gnome-terminal_3.6.1-0ubuntu4_amd64.deb) ...
Selecting previously unselected package libwebkitgtk-3.0-0.
Unpacking libwebkitgtk-3.0-0 (from .../libwebkitgtk-3.0-0_1.10.2-0ubuntu1_amd64.deb) ...
Selecting previously unselected package libyelp0.
Unpacking libyelp0 (from .../libyelp0_3.6.2-0ubuntu1_amd64.deb) ...
Selecting previously unselected package yelp.
Unpacking yelp (from .../yelp_3.6.2-0ubuntu1_amd64.deb) ...
Selecting previously unselected package gnome-user-guide.
Unpacking gnome-user-guide (from .../gnome-user-guide_3.6.2-0ubuntu1_all.deb) ...
Processing triggers for gconf2 ...
Processing triggers for menu ...
Processing triggers for gnome-menus ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for desktop-file-utils ...
Processing triggers for man-db ...
Processing triggers for libglib2.0-0:amd64 ...
Setting up libvte-2.90-9 (1:0.34.2-0ubuntu2) ...
Setting up gnome-terminal-data (3.6.1-0ubuntu4) ...
Setting up gnome-terminal (3.6.1-0ubuntu4) ...
Setting up libwebkitgtk-3.0-0 (1.10.2-0ubuntu1) ...
Setting up libyelp0 (3.6.2-0ubuntu1) ...
Setting up yelp (3.6.2-0ubuntu1) ...
Setting up gnome-user-guide (3.6.2-0ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Processing triggers for menu ...
localepurge: Disk space freed in /usr/share/locale: 0 KiB
localepurge: Disk space freed in /usr/share/man: 0 KiB
localepurge: Disk space freed in /usr/share/gnome/help: 0 KiB
localepurge: Disk space freed in /usr/share/omf: 0 KiB

Total disk space freed by localepurge: 0 KiB

root@Tux # //done with gnome-terminal

This shows that you need to dig to the last conflict, remove the rogue package and then install it again whence it will be installed from the default release repositories. However, you can reduce the number of steps greatly if you start with the important base packages. In addition, remember that one package might also have multiple unresolved conflicts and the procedure is same for all.

Once done, probably you will be back to your standard repository packages ;). Log out and try logging in to Unity.