DH_TESTROOT(1)

✨ DH_TESTROOT ✨

okay so bestie, this is dh_testroot from the Debhelper manual (section 1, for the record πŸ’…) β€” and it's literally the vibe-checker that makes sure your package gets built with the right level of root permissions 🫢


🌸 NAME 🌸

dh_testroot β€” ensure that a package is built with necessary level of root permissions

like, it's the bouncer at the club door of your build. are you root enough? let's find out πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

dh_testroot [debhelper options]

that's it. that's the whole thing. no cap πŸ’–


πŸŽ€ DESCRIPTION πŸŽ€

dh_testroot is used to determine if the target is being run with suffient access to root(-like) features.

and yes, the original says "suffient", we're keeping it, it's iconic in a typo way 😭

so what even is "sufficient access"? plot twist: it depends!! 🌈 it depends on whether the builder β€” that's the tool invoking the debian/rules target β€” supports the Rules-Requires-Root field, aka RΒ³. if the builder supports RΒ³, then it will set the environment variable DEB_RULES_REQUIRES_ROOT, and dh_testroot will validate that the builder followed the minimum requirements for the given value of DEB_RULES_REQUIRES_ROOT. validation era ✨

if the builder does not support Rules-Requires-Root, then it will not set the DEB_RULES_REQUIRES_ROOT environment variable. which means dh_testroot (and the rest of debhelper, fr fr the whole squad) falls back to assuming that (fake)root is implied. it's giving "we'll just assume, bestie" 🧚

here's the tea on how dh_testroot behaves based on the DEB_RULES_REQUIRES_ROOT environment variable β€” and heads up, leading and trailing whitespace in the variable is ignored:

  • If unset, or set to "binary-targets", then dh_testroot asserts that it is run as root or under fakeroot(1).
  • If set to "no", then dh_testroot returns successfully (without performing any additional checks). slay, no notes, we're done here πŸ’…
  • If set to any other value than the above, then dh_testroot asserts that it is either run as root (or under fakeroot(1)) or the builder has provided the DEB_GAIN_ROOT_CMD environment variable (e.g. via dpkg-buildpackage -r).
⚠️ lowkey important!! please note that dh_testroot does not read the Rules-Requires-Root field. which implies that dh_testroot may produce incorrect result if the builder lies in DEB_RULES_REQUIRES_ROOT. πŸ’€ yes, it can be lied to. on the flip side, it also enables things like testing for what will happen when DEB_RULES_REQUIRES_ROOT is set to a given value. so it's a feature, not a bug, main character energy 🌟

πŸ‘‘ SEE ALSO πŸ‘‘

This program is a part of debhelper.


πŸ’œ AUTHOR πŸ’œ

Joey Hess <joeyh@debian.org>


and that's the whole page bestie, you ate that πŸ“ remember: root or fakeroot or DEB_GAIN_ROOT_CMD, pick your fighter πŸ₯Š

this has been 14.5ubuntu1, dated 2026-09-21 β€” DH_TESTROOT(1), signing off πŸŽ€βœ¨ iykyk

πŸ“¦ where this page comes from