3

The information below seems misleading. I am confused with the example they give that if you lose dpkg (the program that lets you handle .deb files) you can use the other commands ar, tar, and gzip commands to download the .deb file for dpkg itself?

If this is true, what is so special about dpkg that is not available with the other commands?

As a Debian system administrator, you will routinely handle .deb packages, since they contain consistent functional units (applications, documentation, etc.), whose installation and maintenance they facilitate. It is therefore a good idea to know what they are and how to use them. This chapter describes the structure and contents of “binary” and “source” packages. The former are .deb files, directly usable by dpkg, while the latter contain the source code, as well as instructions for building binary packages.

From: http://debian-handbook.info/browse/wheezy/packaging-system.html

5.1. Structure of a Binary Package The Debian package format is designed so that its content may be extracted on any Unix system that has the classic commands ar, tar, and gzip (sometimes xz or bzip2). This seemingly trivial property is important for portability and disaster recovery. Imagine, for example, that you mistakenly deleted the dpkg program, and that you could thus no longer install Debian packages. dpkg being a Debian package itself, it would seem your system would be done for... Fortunately, you know the format of a package and can therefore download the .deb file of the dpkg package and install it manually (see the “TOOLS” sidebar). If by some misfortune one or more of the programs ar, tar or gzip/xz/bzip2 have disappeared, you will only need to copy the missing program from another system (since each of these operates in a completely autonomous manner, without dependencies, a simple copy will suffice).

migrated from stackoverflow.com Jul 27 '14 at 16:38

This question came from our site for professional and enthusiast programmers.

  • Not sure what you are asking. dpkg is the main program that manages the Debian packaging system. It installs binary packages, and can be used for querying the installed packages. – Faheem Mitha Jul 27 '14 at 16:05
6

If this is true, what is so special about dpkg that is not available with the other commands?

The other commands are not a package manager replacement, that's what makes dpkg so special. You can really extract the contents of all the package and drop it in your root directory, but that doesn't mean they will be working properly. You have no way of tracking dependencies, identify what package installed what files, post/pre installation and removal scripts, and many other nifty features that package managers provide.

What they meant with that paragraph, is, that in case you mess up big time, you can download the files, extract them and recover your system, as makeshift replacement for the proper tool:

This seemingly trivial property is important for portability and disaster recovery

So, the importance of DPKG is great, but they have put failsafes in place so that in case of disaster, you can recover fairly quickly.

2

The Debian Administrator's Handbook says:

Fortunately, you know the format of a package and can therefore download the .deb file of the dpkg package and install it manually...

It means that deb files can be downloaded manually (or copied from a media) and then installed by manually extracting the files from the deb file with tar, gzip,... (in case the dpkg program is missing)

You are asking:

If this is true, what is so special about dpkg that is not available with the other commands?

From the dpkg man page:

dpkg is a tool to install, build, remove and manage Debian packages.

From the tar man page:

Tar stores and extracts files from a tape or disk archive.

From the gzip man page:

Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77).

So in short dpkg allows to decompress and extract but also run install scripts, check dependancies between packages, remove packages, purge configuration files,... and much more.

0

This means that if you remove dpkg, you can download its .deb file from a repository and manually extract and install the dpkg .deb file. But you should use dpkg so the package manager database is maintained. Using ar and tar and gzip, the package manager (apt)'s database is not updated to reflect changes.

To keep a stable system, please use dpkg unless absolutely necessary.

0

Basically, this is how initial setup is done: all the packages marked Essential and their dependencies are extracted using ar and tar from outside the newly installed system, into a new directory.

The resulting file system tree contains everything that is needed to chroot into it and run dpkg. The first invocation reinstalls all the Essential packages, overwriting the files with the same contents, and registering the installed packages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.