Adding Special Files

Learn how to add special files to the Debian package.

We'll cover the following

Adding special files

There are some files that we simply place into our debian/ directory and that various debhelpers automatically pick up and install for us:

  • preinst or <package-name>.preinst is run before package installation.
  • postinst or <package-name>.postinst is run after package installation.
  • prerm or <package-name>.prerm is run before package removal.
  • postrm or <package-name>.postrm is run after package removal.
  • init or <package-name>.init is used as an init script for our package (though it has largely been replaced by systemd).
  • copyright is supposed to be a machine-readable description of copyright and licenses that is installed to /usr/share/doc/<package-name>/copyright.

Note: In all of these cases, the <package-name>.<suffix> form is usually recommended and required for multi-package builds.

Some of the debhelper scripts assume that the (pre, post) (inst, rm) scripts are shell scripts and inject their own code into them. To enable that, we must include the special marker #DEBHELPER# as a line on its own in these scripts.

Get hands-on with 1400+ tech skills courses.