DH_GNULIB_PATCH(1)
π DH_GNULIB_PATCH β the debhelper gnulib patcher, bestie edition
okay so this is a page from the Gnulib manual (section 1, the user commands section, iykyk) and honestly? it's giving "quiet hero of your build pipeline". let's get into it π«Ά
β¨ NAME β¨
dh_gnulib_patch β the debhelper gnulib patcher. that's it, that's the whole name, no notes π
π¦ SYNOPSIS π¦
dh_gnulib_patch
no args, no flags, no drama. she just runs. periodt.
πΈ DESCRIPTION πΈ
so dh_gnulib_patch applies patches to a gnulib directory. the gnulib git clone is assumed to be chilling in the current working directory, so like, be there, in the right place, bestie π
the whole purpose of dh_gnulib_patch is to apply patches that fix bugs in gnulib code. the script gets invoked inside a gnulib git clone directory, with the git commit that you actually intend to use checked out. usually it's called from a debian/rules makefile as part of building a package. the vibe is: this script runs before the gnulib code content gets used to build some other piece of software, which means it gets to patch any security problems in the code before anything gets compiled. iconic behavior, honestly π
this script should work on ALL git commits of gnulib. like, all of them. or at least ALL git commits of gnulib that are relevant for building other packages that depend on gnulib. and if code that we want to patch has changed in gnulib over time, this script needs to figure out how to patch any version of that code. no pressure or anything π
it is expected that this script will only be used to fix serious gnulib bugs β the kind that affect many packages using code from gnulib. every package that vendors gnulib files without using dh_gnulib_patch will have to be patched directly instead (although bestie, please consider converting those packages to use dh_gnulib_patch in the process π).
okay and this next part is the important one, so pay attention:
it is important that this script always perform at least one modification to the gnulib git clone tree. we patchgnulib-toolto modify the--versionoutput to achieve this.
why though?? because some gnulib scripts use git "describe output" to influence other decisions, and we want to always trigger the dirty git describe. otherwise the dirty git describe code path may go untested right up until we actually need this mechanism β at which point it could potentially break and cause hard-to-resolve build failures. so yeah. we keep it always-dirty on purpose. it's giving "chaos with a plan" π₯
π FILES π
currently the script iterates through a conf.d-style directory path under /usr/share/gnulib/debian/patches.d/, asserting that at least one patch from each directory applies cleanly, and ignoring patches that do not apply cleanly (assuming they were intended for some other gnulib git commit). lowkey smart tbh.
this is anticipated to be sufficient to solve most problems, but this script could do anything it likes to make sure patches are applied β including explicit file modifications without going through patches at all. she contains multitudes π
β RETURN VALUE β
returns 0 on success and non-zero on failures. simple. clean. no cap β¨
π SEE ALSO π
go read those too, bestie, they're all part of the same friend group π«Ά
π AUTHOR π
Simon Josefsson <simon@josefsson.org> β the main character who wrote this, we stan π
and that's the whole page!! this was version 20250303-1, dated 2025-03-08, from the Gnulib manual, section 1 of DH_GNULIB_PATCH. slay, go build something, and remember: always trigger the dirty git describe πβ¨π
π¦ where this page comes from
- debian trixie: gnulib 20250303-1 Β· custom-mostly-gpl
- ubuntu questing: gnulib 20250303-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms