OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

8.4.2. Configuration Scripts‌


image

In addition to the control file, the control.tar.gz archive for each Debian package may contain a number of scripts (postinst, postrm, preinst, prerm) called by dpkg at different stages in the processing of a package. We can use dpkg -I to show these files as they reside in a .deb package archive:


$ dpkg -I /var/cache/apt/archives/zsh_5.3-1_amd64.deb | head

new debian package, version 2.0.

size 814486 bytes: control archive=2557 bytes.

$ dpkg -I /var/cache/apt/archives/zsh_5.3-1_amd64.deb | head

new debian package, version 2.0.

size 814486 bytes: control archive=2557 bytes.


838 bytes,

3327 bytes,

969 bytes,

348 bytes,

175 bytes,

175 bytes, Package: zsh Version: 5.3-1

20 lines

43 lines

41 lines

20 lines

5 lines

5 lines

control

md5sums

* postinst

* postrm

* preinst

* prerm

#!/bin/sh

#!/bin/sh

#!/bin/sh

#!/bin/sh

838 bytes,

3327 bytes,

969 bytes,

348 bytes,

175 bytes,

175 bytes, Package: zsh Version: 5.3-1


$ dpkg -I zsh_5.3-1_amd64.deb preinst

#!/bin/sh set -e

# Automatically added by dh_installdeb

dpkg-maintscript-helper symlink_to_dir /usr/share/doc/zsh zsh-common 5.0.7-3 -- ”$@”

# End automatically added section

$ dpkg -I zsh_5.3-1_amd64.deb preinst

#!/bin/sh set -e

# Automatically added by dh_installdeb

dpkg-maintscript-helper symlink_to_dir /usr/share/doc/zsh zsh-common 5.0.7-3 -- ”$@”

# End automatically added section



The Debian Policy describes each of these files in detail, specifying the scripts called and the argu- ments they receive. These sequences may be complicated, since if one of the scripts fails, dpkg will try to return to a satisfactory state by canceling the installation or removal in progress (insofar as it is possible).


The dpkg Database You can traverse the dpkg database on the filesystem at /var/lib/dpkg/. This di- rectory contains a running record of all the packages that have been installed on the system. All of the configuration scripts for installed packages are stored in the

/var/lib/dpkg/info/ directory, in the form of a file prefixed with the package’s name:

$ ls /var/lib/dpkg/info/zsh.*

/var/lib/dpkg/info/zsh.list

/var/lib/dpkg/info/zsh.md5sums

/var/lib/dpkg/info/zsh.postinst

/var/lib/dpkg/info/zsh.postrm

/var/lib/dpkg/info/zsh.preinst

/var/lib/dpkg/info/zsh.prerm


This directory also includes a file with the .list extension for each package, contain- ing the list of files that belong to that package:

$ head /var/lib/dpkg/info/zsh.list

/.

/bin

/bin/zsh

/bin/zsh5

/usr

/usr/lib

/usr/lib/x86_64-linux-gnu

/usr/lib/x86_64-linux-gnu/zsh

/usr/lib/x86_64-linux-gnu/zsh/5.2

/usr/lib/x86_64-linux-gnu/zsh/5.2/zsh [...]


The /var/lib/dpkg/status file contains a series of data blocks (in the format of the famous mail headers request for comment, RFC 2822) describing the status of each package. The information from the control file of the installed packages is also replicated there.

$ more /var/lib/dpkg/status Package: gnome-characters Status: install ok installed Priority: optional

Section: gnome Installed-Size: 1785

Maintainer: Debian GNOME Maintainers <pkg-gnome-

[email protected]> Architecture: amd64

Version: 3.20.1-1 [...]

Let’s discuss the configuration files and see how they interact. In general, the preinst script is executed prior to installation of the package, while the postinst follows it. Likewise, prerm is invoked before removal of a package and postrm afterwards. An update of a package is equivalent to removal of the previous version and installation of the new one. It is not possible to describe in detail all the possible scenarios here but we will discuss the most common two: an installation/up- date and a removal.

These sequences can be quite confusing, but a visual representation may help. Manoj Srivastava made these diagrams explaining how the configuration scripts are called by dpkg. Similar dia- grams have also been developed by the Debian Women project; they are a bit simpler to under- stand, but less complete.

https://people.debian.org/~srivasta/MaintainerScripts.html

image

https://wiki.debian.org/MaintainerScripts


Caution The sequences described in this section call configuration scripts by specific names,

Caution The sequences described in this section call configuration scripts by specific names,


Symbolic Names of the

Scripts

such as old-prerm or new-postinst. They are, respectively, the prerm script con-

tained in the old version of the package (installed before the update) and the postinst

script contained in the new version (installed by the update).

Symbolic Names of the

Scripts


 

Top OS Cloud Computing at OnWorks: