Package: dh-doc-privacy
Hi,
Here's a preliminary patch that implements dh-sequence-doc-privacy,
allowing more compact usage of dh-doc-privacy when the default behaviour
of cleaning README.* files is enough.
- Add dh-sequence-doc-privacy to Build-Depends.
- Pass "--with doc-privacy" to debhelper, and add dh-doc-privacy to
Build-Depends.
Debhelper may pass various arguments to the tool, which have to be
ignored. The test case testing for an error on unknown arguments has
been replaced by a test that passes a real debhelper option, and doesn't
produce an error.
This could be extended further by adding an optional configuration file
("debian/doc-privacy" ?) for situations where more files need to be
cleaned.
Comments?
>From af19e5f07050c0b9071fb1de176ad0061dcc5b39 Mon Sep 17 00:00:00 2001
From: Teemu Hukkanen <[email protected]>
Date: Mon, 3 Aug 2026 00:44:57 +0300
Subject: [PATCH] Implement dh-sequence-doc-privacy
Allows adding "dh-sequence-doc-privacy" to package Build-Depends,
without having to add anything to debian/rules, or alternatively
passing "--with doc-privacy" to debhelper.
Requires ignoring unknown debhelper arguments. The corresponding test
case has been rewritten to test such a scenario.
---
README.md | 10 ++++++++--
debian/control | 2 ++
debian/dh-doc-privacy.install | 2 ++
dh/doc_privacy.pm | 10 ++++++++++
dh_doc_privacy | 3 ---
tests/test_dh_doc_privacy.py | 9 ++++-----
6 files changed, 26 insertions(+), 10 deletions(-)
create mode 100644 debian/dh-doc-privacy.install
create mode 100644 dh/doc_privacy.pm
diff --git a/README.md b/README.md
index a960797..340cb85 100644
--- a/README.md
+++ b/README.md
@@ -34,9 +34,15 @@ The tool is packaged for Debian and available in the archive:
---
## Usage in packages
-`dh_doc_privacy` must be invoked manually at an appropriate point in `debian/rules`, before documentation is built or installed.
+There are three ways to use `dh_doc_privacy`:
-The most common placement is in an override of `dh_auto_build` (or a hook like `execute_after_dh_auto_build`), before running tools like Sphinx, Doxygen, etc.
+1. Add dh-sequence-doc-privacy to Build-Depends.
+
+2. Pass `--with doc_privacy` to debhelper, and add `dh-doc-privacy` to
+ Build-Depends.
+
+3. Add `dh-doc-privacy` to Build-Depends, and invoke `dh_doc_privacy` at an appropriate point in `debian/rules`, before documentation is built or installed.
+ The most common placement is in an override of `dh_auto_build` (or a hook like `execute_after_dh_auto_build`), before running tools like Sphinx, Doxygen, etc.
### Examples
diff --git a/debian/control b/debian/control
index 6a73210..1f7fe97 100644
--- a/debian/control
+++ b/debian/control
@@ -21,6 +21,8 @@ Depends:
debhelper,
python3:any,
${misc:Depends},
+Provides:
+ dh-sequence-doc-privacy,
Description: debhelper addon to remove external web resources from package documentation
This debhelper addon automatically removes remotely-hosted images (such as
build status badges, coverage badges, version badges from shields.io, GitHub,
diff --git a/debian/dh-doc-privacy.install b/debian/dh-doc-privacy.install
new file mode 100644
index 0000000..e64efc1
--- /dev/null
+++ b/debian/dh-doc-privacy.install
@@ -0,0 +1,2 @@
+dh/doc_privacy.pm usr/share/perl5/Debian/Debhelper/Sequence/
+build/dh_doc_privacy usr/bin/
diff --git a/dh/doc_privacy.pm b/dh/doc_privacy.pm
new file mode 100644
index 0000000..aed88b8
--- /dev/null
+++ b/dh/doc_privacy.pm
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+# debhelper sequence file for dh_doc_privacy
+
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+insert_before("dh_update_autotools_config", "dh_doc_privacy");
+
+1;
diff --git a/dh_doc_privacy b/dh_doc_privacy
index 359f8a1..bee1e92 100755
--- a/dh_doc_privacy
+++ b/dh_doc_privacy
@@ -114,9 +114,6 @@ def parse_args(argv: list[str]) -> tuple[Options, list[str]]:
help="treat DIR as the package source root instead of the current directory",
)
parsed, rest = parser.parse_known_args(argv)
- unknown = [arg for arg in rest if arg.startswith("-")]
- if unknown:
- error(f"unknown option(s): {' '.join(unknown)}")
sourcedir = Path(parsed.sourcedir) if parsed.sourcedir else None
options = Options(
excludes=parsed.exclude,
diff --git a/tests/test_dh_doc_privacy.py b/tests/test_dh_doc_privacy.py
index a35087e..225d071 100644
--- a/tests/test_dh_doc_privacy.py
+++ b/tests/test_dh_doc_privacy.py
@@ -515,12 +515,11 @@ def test_no_act_processes_readme() -> None:
shutil.rmtree(test_root / "debian/tmp", ignore_errors=True)
-def test_unknown_option_error() -> None:
- """An unknown option exits with status 1 and an error message."""
+def test_unknown_option_ignore() -> None:
+ """Debhelper options should be ignored."""
test_root = prepare_test_root()
- result = run_dh_tool(["dh_doc_privacy", "--no-such-option"], cwd=test_root)
- assert result.returncode == 1
- assert "unknown option" in result.stderr
+ result = run_dh_tool(["dh_doc_privacy", "-O--buildsystem=pybuild"], cwd=test_root)
+ assert result.returncode == 0
def test_nonexistent_path_error() -> None:
--
2.53.0