13 | | Each package can have up to 4 maintainer scripts: |
14 | | * `preisnt`: |
| 15 | Each package can have up to 4 maintainer scripts, which are placed in the `debian/` directory when building the package. Like all debhelper files, they can be prepended with the package's name (e.g. package1.postinst). |
| 16 | * `postinst`:The package’s postinst maintainer script. |
| 17 | * `preinst`:The package’s postinst maintainer script. |
| 18 | * `postrm`:The package’s postinst maintainer script. |
| 19 | * `prerm`:The package’s postinst maintainer script. |
| 20 | |
| 21 | All scripts should include the tag `#DEBHELPER#` as the penultimate line of the script, should explicitly exit with status 0 at the end of the script, and should handle all possible arguments (see below). When creating new maintainer scripts, you should use the examples in `/usr/share/debhelper/dh_make/debian/`. In there, you'll fine `postinst.ex`, `preinst.ex`, etc. |
| 22 | |
| 23 | == Arguments == |
| 24 | |
| 25 | Each of the maintainer scripts can be called with a number of arguments that indicate what particular dpkg operation is going on. Your script must be able to handle all possible arguments, and error out with unrecognized ones. (Again, the examples described above do this for you already). In most cases, however, you'll only handle one or two of the arguments. Each of the examples in `/usr/share/debhelper/dh_make/debian/` contains a comment block at the top indicating all possible invocations. |
| 26 | |
| 27 | == Testing == |
| 28 | |
| 29 | When testing new packages, it's important to test both clean installs _and_ upgrades from previous versions. It's possible to make a mistake such that installs work, but not upgrades (or vice versa). This requires a lot of cleanup and can inconvenience many users. |