6.6 What is a Debian preinst, postinst, prerm, and postrm script?
These files are executable scripts which are automatically run before or after
a package is installed. Along with a file named control, all of
these files are part of the "control" section of a Debian archive
file.
The individual files are:
- preinst
-
This script executes before that package will be unpacked from its Debian
archive (".deb") file. Many 'preinst' scripts stop services for
packages which are being upgraded until their installation or upgrade is
completed (following the successful execution of the 'postinst' script).
- postinst
-
This script typically completes any required configuration of the package
foo once foo has been unpacked from its Debian
archive (".deb") file. Often, 'postinst' scripts ask the user for
input, and/or warn the user that if he accepts default values, he should
remember to go back and re-configure that package as the situation warrants.
Many 'postinst' scripts then execute any commands necessary to start or restart
a service once a new package has been installed or upgraded.
- prerm
-
This script typically stops any daemons which are associated with a package.
It is executed before the removal of files associated with the package.
- postrm
-
This script typically modifies links or other files associated with
foo, and/or removes files created by the package. (Also see What is a Virtual Package?, Section 6.8.)
Currently all of the control files can be found in directory
/var/lib/dpkg/info. The files relevant to package
foo begin with the name "foo" and have file extensions
of "preinst", "postinst", etc., as appropriate. The file
foo.list in that directory lists all of the files that were
installed with the package foo. (Note that the location of these
files is a dpkg internal; you should not rely on it.)