What does installation script do in apt-get install?
In short: apt-get install
does everything that is needed that your system can successfully execute the new installed software application.
Longer version:
Preliminaries:
From the manpage:
All packages required by the package(s) specified for installation will also be retrieved and installed.
Those packages are stored on a repository in the network (internet). So, apt-get
downloads all the needed packages into a temporary directory (/var/cache/apt/archives/
). They will be downloaded from a web- or an ftp-server. They are specified in the so called sources.list
; a list of repositories for the package manager apt. From then on, they get installed one by one procedurally.
The first ones to be installed are the ones that have no further dependencies; so no other package has to be installed for them to work properly. Through that, other packages (that had dependencies previously) haven't now dependencies anymore. The system keeps doing that process over and over until the specified packages are installed.
Each package undergoes an installation procedure.
Package installation procedure:
In Debian-based Linux distributions, such as Ubuntu or Mint, those packages are in a specified standardized format called: deb --> The Debian binary package format.
Such a package contains the files to be installed on the system. Also they contain a control file. That file contains scripts that the packaging system should execute in a specific situation; the so-called maintainer scripts. Those scripts are split in:
-
preinst
: before the installation of the files into the systems file hierarchy -
postinst
: after the installation -
prerm
: before the uninstallation -
postrm
: after the uninstallation
Those scripts are the place where specific users are created or some services that need to be restarted or other preliminaries that are needed for the package to work.
Besides those scripts, the package system has triggers that are intended for specific events. For example, the regeneration of initrds when installing a new kernel version or ldconfig or the man-db. They are activated by one or more packages and run in the end of the whole installation process.
There is an interesting picture, showing the procedure of an installation of a new package:
There are also more control-files, the most important are as follows:
-
control
: A list of dependencies, and other useful information to identify the package -
conffiles
: A list of config files (usually those in/etc
) -
debian-binary
: contains the deb-package version, currently 2.0 -
md5sums
: A list of md5sums of each file in the package for verifying -
templates
: A file with error descriptions and dialogs during installation
If you are interested, you can unpack a deb package (after downloading) manually and watch what's inside:
# to only download the package (no installation)
apt-get download package
# to unpack the deb file
ar x package.deb
Now you see a file called data.tar.gz
containing the files and a file called control.tar.gz
containing the four maintainer scripts and the above-mentioned control-files.