[Solved] Broken Packages In Ubuntu

One of the worst things about working for a big company distributed world-wide is that you don't have a direct contact with the leaders of the IT department. So, if they decide to put in place a proxy, it's not easy to tell them not to cache Ubuntu packages. However, if all packages are cached, it wouldn't be so bad.

Last week, the proxy decided that I could access only cached packages. Unfortunately not all the dependencies were satisfied. Then I made my part mess and I chose to install anyway. And this is the result.

# apt-get upgrade 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 dpkg-dev : Depends: libdpkg-perl (= 1.18.4ubuntu1.1) but 1.18.4ubuntu1 is installed
 gnome-software : Depends: gnome-software-common (= 3.20.1+git20160426.1.a976144-ubuntu-> xenial-0ubuntu1) but 3.20.1+git20160420.1.ca63436.ubuntu-xenial-0ubuntu2 is installed
 libudev-dev : Depends: libudev1 (= 229-4ubuntu5) but 229-4ubuntu4 is installed
 linux-headers-generic : Depends: linux-headers-4.4.0-22-generic but it is not installable
 linux-image-extra-4.4.0-22-generic : Depends: linux-image-4.4.0-22-generic but it is not installable
 linux-image-generic : Depends: linux-image-4.4.0-22-generic but it is not installable
 network-manager-gnome : Depends: libnma0 (= 1.1.93-1ubuntu1) but 1.2.0-0ubuntu0.16.04.1 is installed
 openssh-sftp-server : Depends: openssh-client (= 1:7.2p2-4) but 1:7.2p2-4ubuntu1 is installed
 plymouth-label : Depends: plymouth (= 0.9.2-3ubuntu13.1) but 0.9.2-3ubuntu13 is installed
 plymouth-theme-ubuntu-text : Depends: plymouth (= 0.9.2-3ubuntu13.1) but 0.9.2-3ubuntu13 is installed
 systemd : Depends: libsystemd0 (= 229-4ubuntu4) but 229-4ubuntu5 is installed
 udev : Depends: libudev1 (= 229-4ubuntu5) but 229-4ubuntu4 is installed
E: Unmet dependencies. Try using -f.

The standard way to resolve the issue is to remove the broken packages and reinstall them again. Unfortunately systemd is one of them and I'm afraid that after removing it I would not be able to boot my system anymore. So now? Well, if the automatic procedure doesn't work, let's try with the manual one. On packages.ubuntu.com it is possible to download the various deb packages. After that, installing them is trivial.

# dpkg --install systemd_229-4ubuntu5_i386.deb
# dpkg --install libudev1_229-4ubuntu5_i386.deb
...

In the end, apt-get upgrade takes care of fixing the situation with previously broken packages.

# apt-get upgrade 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  linux-image-4.2.0-35-generic linux-image-extra-4.2.0-35-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
10 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]         

Problem solved! [Sigh of relief]


Cover image by csc1950 taken from Flickr licensed under the Creative Commons Attribution 2.0 Generic license.