DH_USRLOCAL(1)

πŸ’– DH_USRLOCAL(1) πŸ’–

okay bestie, so this is a page from the Debhelper manual, and it's all about dh_usrlocal β€” the little icon that migrates your usr/local directories into maintainer scripts. yes queen, let's get into it πŸŽ€


✨ NAME ✨

dh_usrlocal β€” migrate usr/local directories to maintainer scripts πŸ¦‹


🌸 SYNOPSIS 🌸

dh_usrlocal [debhelper options] [-n]

πŸ‘‘ DESCRIPTION πŸ‘‘

So like, dh_usrlocal is a debhelper program you use when you're building packages that are gonna provide a subdirectory inside /usr/local once they're installed. main character behavior, honestly πŸ’…

Here's the tea: it goes looking through the package build directory for subdirectories of usr/local, and it removes them, swapping them out for maintainer script snippets instead (unless you pass -n, more on that below). Those snippets then create the directories at install time and remove them when the package gets removed β€” all done in a manner that's compliant with Debian policy. periodt. ✨

Those snippets get inserted into the maintainer scripts by dh_installdeb. If you want the whole explanation of what debhelper maintainer script snippets even are, go check out dh_installdeb(1). πŸ“–

Now, concerning the DEB_RULES_REQUIRES_ROOT environment variable, because she's important:

  • When DEB_RULES_REQUIRES_ROOT is not (effectively) binary-targets, the directories in /usr/local get handled as if they were owned by <code>root:root</code> (see below, bestie πŸ‘‡).
  • When DEB_RULES_REQUIRES_ROOT has an effective value of binary-targets, the owners, groups and permissions will be preserved β€” with the sole exception of where the directory is owned by root:root.

And if a directory is owned by root:root? Then ownership gets determined at install time. The ownership and permission bits will either be root:root mode 0755 or root:staff mode 02775. Which one you get depends on whether the system has /etc/staff-group-for-usr-local β€” as documented in the Debian Policy Manual Β§9.1.2 since version 4.1.4. no cap πŸ“š


πŸ’… OPTIONS πŸ’…

  • -n, --no-scripts β€” Do not modify postinst/prerm scripts. she simply does not touch them πŸ™ˆ

⚠️ NOTES ⚠️

Heads up bestie, this command is not idempotent. 😭

dh_prep(1) should be called between invocations of this command. Otherwise, it may cause multiple instances of the same text to be added to maintainer scripts. not the duplicate snippets era πŸ’€


πŸŽ€ CONFORMS TO πŸŽ€

Debian policy, version 2.2 πŸ¦‹


πŸ”₯ SEE ALSO πŸ”₯

This program is a part of debhelper. 🫢


🌈 AUTHOR 🌈

Andrew Stribblehill <ads@debian.org> πŸ‘‘


and that's the whole page, bestie!! this was dh_usrlocal from debhelper version 14.5ubuntu1, dated 2026-09-21. go forth and migrate those usr/local dirs responsibly, mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from