The
debconf
Tool
The
debconf
tool was created to resolve a recurring problem in Debian. All Debian
packages unable to function without a minimum of configuration used to ask ques-
tions with calls to the
echo
and
read
commands in
postinst
shell scripts (and other
similar scripts). This forced the installer to babysit large installations or updates in
order to respond to various configuration queries as they arose. These manual inter-
actions have now been almost entirely dispensed with, thanks to
debconf
.
The
debconf
tool has many interesting features: It requires the developer to specify
user interaction; it allows localization of all the displayed strings (all translations are
stored in the
templates
file describing the interactions); it provides different fron-
tends for questions (text mode, graphical mode, non-interactive); and it allows cre-
ation of a central database of responses to share the same configuration with several
computers. The most important feature is that all of the questions can be presented in
a row, all at once, prior to starting a long installation or update process. Now, you can
go about your business while the system handles the installation on its own, without
having to stay there staring at the screen, waiting for questions to pop up.
8.4.3. Checksums, Conffiles
In addition to the maintainer scripts and control data already mentioned in the previous sections,
the
control.tar.gz
archive of a Debian package may contain other interesting files:
# ar p /var/cache/apt/archives/bash_4.4-2_amd64.deb control.tar.gz | tar -tzf -
./
./conffiles
./control
./md5sums
./postinst
./postrm
./preinst
./prerm
The first—
md5sums
—contains the MD5 checksums for all of the package’s files. Its main advantage
is that it allows
dpkg --verify
to check if these files have been modified since their installation.
Note that when this file doesn’t exist,
dpkg
will generate it dynamically at installation time (and
store it in the dpkg database just like other control files).
220
Kali Linux Revealed
conffiles
lists package files that must be handled as configuration files. Configuration files can
be modified by the administrator, and
dpkg
will try to preserve those changes during a package
update.
In effect, in this situation,
dpkg
behaves as intelligently as possible: if the standard configuration
file has not changed between the two versions, it does nothing. If, however, the file has changed,
it will try to update this file. Two cases are possible: either the administrator has not touched this
configuration file, in which case
dpkg
automatically installs the new version; or the file has been
modified, in which case
dpkg
asks the administrator which version they wish to use (the old one
with modifications, or the new one provided with the package). To assist in making this decision,
dpkg
offers to display a
diff
that shows the difference between the two versions. If you choose to
retain the old version, the new one will be stored in the same location in a file with the
.dpkg-dist
suffix. If you choose the new version, the old one is retained in a file with the
.dpkg-old
suffix.
Another available action consists of momentarily interrupting
dpkg
to edit the file and attempt to
reinstate the relevant modifications (previously identified with
diff
).
dpkg
handles configuration file updates, but, while doing so, regularly interrupts its work to ask
for input from the administrator. This can be time consuming and inconvenient. Fortunately,
you can instruct
dpkg
to respond to these prompts automatically. The
--force-confold
option
retains the old version of the file, while
--force-confnew
will use the new version. These choices
are respected, even if the file has not been changed by the administrator, which only rarely has
the desired effect. Adding the
--force-confdef
option tells
dpkg
to decide by itself when pos-
sible (in other words, when the original configuration file has not been touched), and only uses
--force-confnew
or
--force-confold
for other cases.
These options apply to
dpkg
, but most of the time the administrator will work directly with the
aptitude
or
apt
programs. It is, thus, necessary to know the syntax used to indicate the options
to pass to the
dpkg
command (their command line interfaces are very similar).
# apt -o DPkg::options::=”--force-confdef” -o DPkg::options::=”--force-confold” full-
å
upgrade
These options can be stored directly in
apt
’s configuration. To do so, simply write the following
line in the
/etc/apt/apt.conf.d/local
file:
DPkg::options { ”--force-confdef”; ”--force-confold”; }
Including this option in the configuration file means that it will also be used in a graphical inter-
face such as
aptitude
.
Conversely, you can also force
dpkg
to ask configuration file questions. The
--force-confask
option instructs
dpkg
to display the questions about the configuration files, even in cases where
they would not normally be necessary. Thus, when reinstalling a package with this option,
dpkg
will ask the questions again for all of the configuration files modified by the administrator. This is
very convenient, especially for reinstalling the original configuration file if it has been deleted and
221
Chapter 8 — Debian Package Management
no other copy is available: a normal re-installation won’t work, because
dpkg
considers removal
as a form of legitimate modification, and, thus, doesn’t install the desired configuration file.
|