Helpful tips about debian packages

I have worked with debian packages for a few years, for the company I work at uses this method to deploy the software we do.

The official documentation is very detailed but it is difficult to find the things we want.

I will give here a few tips that I have learnt in the past years that often helps me a lot.

The folder where the package files (like preinst, postinst, etc) are:

fabio@perrella:~ $ ll /var/lib/dpkg/info/apache2.*
-rw-r--r-- 1 root root  6065 Jan 14 15:46 /var/lib/dpkg/info/apache2.conffiles
-rw-r--r-- 1 root root  7953 Jan 28 20:52 /var/lib/dpkg/info/apache2.list
-rw-r--r-- 1 root root  1464 Jan 14 15:47 /var/lib/dpkg/info/apache2.md5sums
-rwxr-xr-x 1 root root 13714 Jan 14 15:46 /var/lib/dpkg/info/apache2.postinst*
-rwxr-xr-x 1 root root  3905 Jan 14 15:46 /var/lib/dpkg/info/apache2.postrm*
-rwxr-xr-x 1 root root  4602 Jan 14 15:46 /var/lib/dpkg/info/apache2.preinst*
-rwxr-xr-x 1 root root   229 Jan 14 15:46 /var/lib/dpkg/info/apache2.prerm*

The folder where the last installed packages are:


How to configure the package to restart the service automatically when it is installed:

in debian/rules:

dh_installinit --restart-after-upgrade

This will replace the tag #DEBHELPER# in the file debian/postinst by a code to call the service restart.


Put all configuration files into the file debian/conffiles, this will prevent the package to replace the server configuration files while installing a new version of the package. By doing this, it is not necessary to remove the configuration files from the package or add them as .sample files to the repository.

Do you have any useful tips? Please add a comment below!