The dh_usrlocal manpage sounds a bit cryptic to me:
It finds subdirectories of usr/local in the package build directory, and
removes them, replacing them with maintainer script snippets (unless -n is
used) to create the directories at install time, and remove them when the
package is removed, in a manner compliant with Debian policy. These
snippets are inserted into the maintainer scripts by dh_installdeb. See
dh_installdeb(1) for an explanation of debhelper maintainer script
snippets.
Mainainer scripts, snippets, -n
… OK, but what is the purpose? Does it really just create (empty?) directories?
Can a kind soul explain it to me in a more practical way? Which part of policy I should read? Should I care if my app installs with PREFIX=/usr
?
Best Answer
The purpose is to aid with policy compliance by that package. According to Debian policy (and, IIRC, the Filesystem Hierarchy Standard or FHS), official Debian packages are not permitted to own files or directories under
/usr/local
- that directory tree belongs to the local system administrator.From https://www.debian.org/doc/debian-policy/ch-opersys.html#s9.1.2 :
(bold emphasis added by me)
See also https://wiki.debian.org/FilesystemHierarchyStandard
dh_usrlocal
removes any such directories from the package and replaces them with code in the package scripts (the.postinst
and.prerm
scripts) to create/delete them at install/uninstall time, following the example given in the policy.This may seem to make little practical difference because the directories are still created on install and deleted on uninstall, but Debian considers the failure of a package to comply with policy to be as serious a bug as any other - consistent and scrupulous adherence to policy is a major factor in quality assurance for Debian packages.