Free Hosting Online for WorkStations

< Previous | Contents | Next >

Installing Packages with dpkg


dpkg is the core tool that you will use (either directly or indirectly through APT) when you need to install a package. It is also a go-to choice if you are operating offline, since it doesn’t require an Internet connection. Remember, dpkg will not install any dependencies that the package might require. To install a package with dpkg, simply provide the -i or --install option and the path to the .deb. This implies that you have previously downloaded (or obtained in some other way) the

.deb file of the package to install.


# dpkg -i man-db_2.7.0.2-5_amd64.deb

(Reading database ... 86425 files and directories currently installed.) Preparing to unpack man-db_2.7.0.2-5_amd64.deb ...

Unpacking man-db (2.7.0.2-5) over (2.7.0.2-4) ... Setting up man-db (2.7.0.2-5) ...

Updating database of manual pages ... Processing triggers for mime-support (3.58) ...

# dpkg -i man-db_2.7.0.2-5_amd64.deb

(Reading database ... 86425 files and directories currently installed.) Preparing to unpack man-db_2.7.0.2-5_amd64.deb ...

Unpacking man-db (2.7.0.2-5) over (2.7.0.2-4) ... Setting up man-db (2.7.0.2-5) ...

Updating database of manual pages ... Processing triggers for mime-support (3.58) ...


We can see the different steps performed by dpkg and can see at what point any error may have occurred. The -i or --install option performs two steps automatically: it unpacks the package and runs the configuration scripts. You can perform these two steps independently (as apt does behind the scenes) with the --unpack and --configure options, respectively:


# dpkg --unpack man-db_2.7.0.2-5_amd64.deb

(Reading database ... 86425 files and directories currently installed.) Preparing to unpack man-db_2.7.0.2-5_amd64.deb ...

Unpacking man-db (2.7.0.2-5) over (2.7.0.2-5) ... Processing triggers for mime-support (3.58) ...

# dpkg --configure man-db

Setting up man-db (2.7.0.2-5) ... Updating database of manual pages ...

# dpkg --unpack man-db_2.7.0.2-5_amd64.deb

(Reading database ... 86425 files and directories currently installed.) Preparing to unpack man-db_2.7.0.2-5_amd64.deb ...

Unpacking man-db (2.7.0.2-5) over (2.7.0.2-5) ... Processing triggers for mime-support (3.58) ...

# dpkg --configure man-db

Setting up man-db (2.7.0.2-5) ... Updating database of manual pages ...


Note that the “Processing triggers” lines refer to code that is automatically executed whenever a package adds, removes, or modifies files in some monitored directories. For instance, the mime- support package monitors /usr/lib/mime/packages and executes the update-mime command whenever something changes in that directory (like /usr/lib/mime/packages/man-db in the specific case of man-db).

Sometimes dpkg will fail to install a package and return an error. However, you can order dpkg to ignore this and only issue a warning with various --force-* options. Issuing the dpkg --force- help command will display a complete list of these options. For example, you can use dpkg to forcibly install zsh:


$ dpkg -i --force-overwrite zsh_5.2-5+b1_amd64.deb

$ dpkg -i --force-overwrite zsh_5.2-5+b1_amd64.deb


A frequent error, which you are bound to encounter sooner or later, is a file collision. When a package contains a file that is already installed by another package, dpkg will refuse to install it. The following types of messages will then appear:


Unpacking libgdm (from .../libgdm_3.8.3-2_amd64.deb) ...

dpkg: error processing /var/cache/apt/archives/libgdm_3.8.3-2_amd64.deb (--unpack):

trying to overwrite ’/usr/bin/gdmflexiserver’, which is also in package gdm3

3.4.1-9

Unpacking libgdm (from .../libgdm_3.8.3-2_amd64.deb) ...

dpkg: error processing /var/cache/apt/archives/libgdm_3.8.3-2_amd64.deb (--unpack):

trying to overwrite ’/usr/bin/gdmflexiserver’, which is also in package gdm3

3.4.1-9


In this case, if you think that replacing this file is not a significant risk to the stability of your system (which is usually the case), you can use --force-overwrite to overwrite the file.

While there are many available --force-* options, only --force-overwrite is likely to be used regu- larly. These options exist for exceptional situations, and it is better to leave them alone as much as possible in order to respect the rules imposed by the packaging mechanism. Do not forget, these rules ensure the consistency and stability of your system.


Top OS Cloud Computing at OnWorks: