Hi!

On Sun, 2023-05-28 at 10:26:46 +0200, Niels Thykier wrote:
> Package: dpkg
> Version: 1.21.22
> Severity: minor
> X-Debbugs-Cc: ni...@thykier.net

> I was playing around with doing a custom name space for Rules-Requires-Root,
> and then dpkg said it owned the namespace:
> 
> ```
> $ grep Rules-Requires-Root debian/control
> Rules-Requires-Root: debputy/deb-assembly
> $ dpkg-buildpackage -us -uc -nc -B -Pnoudeb
> dpkg-buildpackage: error: Rules-Requires-Root field keyword
> "debputy/deb-assembly" is unknown in dpkg namespace
> ```
> 
> Personally, I was a bit surprised because I did not feel like dpkg has a
> claim on this namespace. It turns out that dpkg currently believes it owns
> *all* namespaces:
> 
> ```
> $ grep Rules-Requires-Root debian/control
> Rules-Requires-Root: foo/bar
> $ dpkg-buildpackage -us -uc -nc -B -Pnoudeb
> dpkg-buildpackage: error: Rules-Requires-Root field keyword "foo/bar" is
> unknown in dpkg namespace
> ```
> 
> Please review the namespace check. Behaviour-wise there is a bug in it
> somewhere.

Ugh, so from code staring and git log, it seems this has not worked since
the code got added. Which should also mean the debhelper namespace which
is documented in the spec does not work either. :/

I've prepared the attached patch which I think should be fixing this,
but will test and add some functional tests to check for this to make
sure and avoid regressions.

I might look into whether to target stable releases too given that
it's a small fix (although no one else reported this until now, but
that might only mean people thought this was allowed…).

Thanks,
Guillem
diff --git i/scripts/dpkg-buildpackage.pl w/scripts/dpkg-buildpackage.pl
index bf43fb5cf..f119f11f5 100755
--- i/scripts/dpkg-buildpackage.pl
+++ w/scripts/dpkg-buildpackage.pl
@@ -846,7 +846,7 @@ sub parse_rules_requires_root {
             if ($keyword =~ m{^dpkg/target/(.*)$}p and $target_official{$1}) {
                 error(g_('disallowed target in %s field keyword "%s"'),
                       'Rules-Requires-Root', $keyword);
-            } elsif ($keyword ne 'dpkg/target-subcommand') {
+            } elsif ($keyword =~ m{^dpkg/(.*)$} and $1 ne 'target-subcommand') {
                 error(g_('%s field keyword "%s" is unknown in dpkg namespace'),
                       'Rules-Requires-Root', $keyword);
             }

Reply via email to