deb-postrm(5) dpkg suite deb-postrm(5)NAME
deb-postrm - package post-removal maintainer script
SYNOPSIS
postrm
DESCRIPTION
A package can perform several post-removal actions via maintainer scripts, by including an executable postrm file in its control archive
(i.e. DEBIAN/postrm during package creation).
The script can be called in the following ways:
postrm remove
After the package was removed.
postrm purge
After the package was purged.
old-postrm upgrade new-version
After the package was upgraded.
new-postrm failed-upgrade old-version new-version
If the above upgrade call fails.
postrm disappear overwriter-package overwriter-version
After all of the packages files have been replaced.
new-postrm abort-install
If preinst fails during install.
new-postrm abort-install old-version new-version
If preinst fails during upgrade of removed package.
new-postrm abort-upgrade old-version new-version
If preinst fails during upgrade.
SEE ALSO dpkg(1).
1.19.0.5 2018-04-16 deb-postrm(5)
Check Out this Related Man Page
dpkg-maintscript-helper(1) dpkg suite dpkg-maintscript-helper(1)NAME
dpkg-maintscript-helper - works around known dpkg limitations in maintainer scripts
SYNOPSIS
dpkg-maintscript-helper command [parameters...] -- maint-script-parameters
COMMANDS AND PARAMETERS
rm_conffile conffile [lastversion [package]]
mv_conffile oldconffile newconffile [lastversion [package]]
DESCRIPTION
This program is designed to be run within maintainer scripts to achieve some tasks that dpkg can't (yet) handle natively either because of
design decisions or due to current limitations.
Many of those tasks require coordinated actions from several maintainer scripts (preinst, postinst, prerm, postrm). To avoid mistakes the
same call simply needs to be put in all scripts and the program will automatically adapt its behaviour based on the environment variable
DPKG_MAINTSCRIPT_NAME and on the maintainer scripts arguments that you have to forward after a double dash.
CONFFILE RELATED TASKS
When upgrading a package, dpkg will not automatically remove a conffile (a configuration file for which dpkg should preserve user changes)
if it is not present in the newer version. There are two principal reasons for this; the first is that the conffile could've been dropped
by accident and the next version could restore it, users wouldn't want their changes thrown away. The second is to allow packages to tran-
sition files from a dpkg-maintained conffile to a file maintained by the package's maintainer scripts, usually with a tool like debconf or
ucf.
This means that if a package is intended to rename or remove a conffile, it must explicitly do so and dpkg-maintscript-helper can be used
to implement graceful deletion and moving of conffiles within maintainer scripts.
REMOVING A CONFFILE
If a conffile is completely removed, it should be removed from disk, unless the user has modified it. If there are local modifications,
they should be preserved. If the package upgrades aborts, the newly obsolete conffile should not disappear.
All of this is implemented by putting the following shell snippet in the preinst, postinst and postrm maintainer scripts:
dpkg-maintscript-helper rm_conffile
conffile lastversion package -- "$@"
conffile is the filename of the conffile to remove. lastversion is the last version of the package that contained the conffile (or the
last version of the package that did not take care to remove the obsolete conffile if this was not immediately implemented). If lastver-
sion is empty or omitted, then the operation is tried on every upgrade. package is the package name, it's optional as it will default to
$DPKG_MAINTSCRIPT_PACKAGE (this variable is set by dpkg to the name of the package acted upon). All the parameters of the maintainer
scripts have to be forwarded to the program after "--".
Current implementation: in the preinst, it checks if the conffile was modified and renames it either to conffile.dpkg-remove (if not modi-
fied) or to conffile.dpkg-backup (if modified). In the postinst, the latter file is renamed to conffile.dpkg-bak and kept for reference as
it contains user modifications but the former will be removed. If the package upgrade aborts, the postrm reinstalls the original conffile.
During purge, the postrm will also delete the .dpkg-bak file kept up to now.
RENAMING A CONFFILE
If a conffile is moved from one location to another, you need to make sure you move across any changes the user has made. This may seem a
simple change to the preinst script at first, however that will result in the user being prompted by dpkg to approve the conffile edits
even though they are not responsible of them.
Graceful renaming can be implemented by putting the following shell snippet in the preinst, postinst and postrm maintainer scripts:
dpkg-maintscript-helper mv_conffile
oldconffile newconffile lastversion package -- "$@"
oldconffile and newconffile are the old and new name of the conffile to rename. lastversion is the last version of the package that con-
tained the conffile with the old name. If lastversion is empty or omitted, then the operation is tried on every upgrade (note: it's safer
to give the version and have the operation tried only once). package is the package name, it's optional as it will default to
$DPKG_MAINTSCRIPT_PACKAGE (this variable is set by dpkg to the name of the package acted upon). All the parameters of the maintainer
scripts have to be forwarded to the program after "--".
Current implementation: the preinst checks if the conffile has been modified, if yes it's left on place otherwise it's renamed to oldconf-
file.dpkg-remove. On configuration, the postinst removes oldconffile.dpkg-remove and renames oldconffile to newconffile if oldconffile is
still available. On abort-upgrade/abort-install, the postrm renames oldconffile.dpkg-remove back to oldconffile if required.
INTEGRATION IN PACKAGES
Given that dpkg-maintscript-helper is used in the preinst, using it unconditionally requires a pre-dependency to ensure that the required
version of dpkg has been unpacked before. The required version depends on the command used, for rm_conffile and mv_conffile it is 1.15.7.2:
Pre-Depends: dpkg (>= 1.15.7.2)
But in many cases the operation done by the program is not critical for the package, and instead of using a pre-dependency we can call the
program only if we know that the required command is supported by the currently installed dpkg:
if dpkg-maintscript-helper supports <command>; then
dpkg-maintscript-helper <command> ...
fi
AUTHORS
Copyright (C) 2010 Raphael Hertzog
Copyright (C) 2008 Joey Hess
Copyright (C) 2007 Guillem Jover
Copyright (C) 2005 Scott James Remnant
This is free software; see the GNU General Public Licence version 2 or later for copying conditions. There is NO WARRANTY.
Debian Project 2010-04-16 dpkg-maintscript-helper(1)