Resolving Unmet .deb Package Dependencies

Ubuntu 15.04 Vivid Vervet was released a few days back and is time for me to properly set it up after I've installed the beta version few weeks back. Upgrade to the stable version was painless as it was a fresh beta release installation. Just the usual apt-get update and upgrade should be okay. No issues encounter so far after a 300-plus MB download.

As usual, Google Chrome will be the first application to be installed. This is just to sync all my bookmarks and histories so I can save a few keystrokes. And as usual, I always use the most straightforward or the only way I can remember to install it.

First, download the .deb package from the download site. Pick the 64-bits version. I always wonder why the 32-bits version still exists and it dawned to me, there are still system running on this architecture.

Next, install the .deb package you've just downloaded. Just use the dpkg command. As the console result shown below, there is an error (emphasized in red) of a missing dependency of libappindicator1 package. libappindicator1 is a library that take your application menu and place them in the top panel.
$ sudo dpkg -i google-chrome-stable_current_amd64.deb 
[sudo] password for ang: 
Selecting previously unselected package google-chrome-stable.
(Reading database ... 202735 files and directories currently installed.)
Preparing to unpack google-chrome-stable_current_amd64.deb ...
Unpacking google-chrome-stable (42.0.2311.90-1) ...
dpkg: dependency problems prevent configuration of google-chrome-stable:
 google-chrome-stable depends on libappindicator1; however:
  Package libappindicator1 is not installed.

dpkg: error processing package google-chrome-stable (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for gnome-menus (3.10.1-0ubuntu5) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...
Processing triggers for bamfdaemon (0.5.1+15.04.20150202-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for mime-support (3.58ubuntu1) ...
Errors were encountered while processing:
 google-chrome-stable

To resolve any dependencies issue with .deb packaging system, just use the command below.
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  libappindicator1 libindicator7
The following NEW packages will be installed:
  libappindicator1 libindicator7
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 40.9 kB of archives.

The -f parameter is to tell apt-get to fix any broken dependencies as written in the man page below. Note I've trimmed the spacing and fix the content below to fit the width of the blog.
$ man apt-get | grep " \-f," -A 5
-f, --fix-broken
Fix; attempt to correct a system with broken dependencies in place. This option, when used with install/remove, can omit any packages to permit APT to deduce a likely solution. If packages are specified, these have to completely correct the problem. The option is sometimes necessary when running APT for the first time; APT itself does not allow broken package dependencies to exist on a system. It is possible that a system's dependency structure can be so corrupt as to require manual intervention (which usually means using dpkg --remove to eliminate some of the offending packages). Use of this option together with -m may produce an error in some situations. Configuration Item: APT::Get::Fix-Broken.

Is there anyway to install a .deb package and resolve its dependencies directly without resorting to apt-get? Yes, there is another tool called gdebi, which unfortunately is not a default preinstalled package. Let's install this and extract the program description from the man page. Note the line emphasized in red regarding limitation of apt.
$ sudo apt-get install gdebi
$ man gdebi | grep DESC -A 2
DESCRIPTION
gdebi lets you install local deb packages resolving and installing its dependencies. apt does the same, but only for remote (http, ftp) located packages. It can also resolve build-depends of debian/control files.

Based on the description above, surprisingly, it seems to me apt-get cannot install local .deb package. Let's verify this.
$ sudo apt-get install google-chrome-stable_current_amd64.deb
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package google-chrome-stable_current_amd64.deb
E: Couldn't find any package by regex 'google-chrome-stable_current_amd64.deb'

Based on my finding right now, it seems to me in order to solve the limitation of the dpkg that cannot resolve dependencies, apt-get -f was created. And to fix the inability of apt-get to install local .deb package, gdebi was developed. Why layer of wrapper was added to exiting program to fix its limitation? Why can't dpkg resolve a .deb package unmet dependencies?

The background information provided by Rafal, which I quoted here (emphasis by author himself), answered my above questions. The thing is, dpkg knows nothing about repositories and hence, cannot find and download the dependent packages. When you use apt to install a package, it will download all its dependencies from the repositories and later pass to dpkg to install it individually according to a sequence.
"dpkg itself is not capable of managing repositories. It is required to use a higher-level tool, like apt-get, to fetch anything from repositories. dkpg is only the core tool, that installs/removes/configures packages, taking care of dependencies and other factors. apt-get and aptitude are tools that manage repositories, download data from them, and use dkpg to install/remove packages from them. This means, that apt-get and aptitude can resolve dependencies and get required packages from repository, but dpkg cannot, because it knows nothing about repositories."
Alternatively, instead of installing using a .deb package. We can we use apt directly through setting up a Chrome repository as detailed below.
$ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 
$ sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
$ sudo apt-get update 
$ sudo apt-get install google-chrome-stable

However, is best to always verify that the signinig key have been added successfully.
$ apt-key list | grep Google -C 2

pub   1024D/7FAC5991 2007-03-08
uid                  Google, Inc. Linux Package Signing Key 
sub   2048g/C07CB649 2007-03-08

But still, one question remains which I still can't google a good answer for. Why can't apt install a local .deb package?





No comments:

Post a Comment