Hi!

On Wed, 2026-02-18 at 11:35:48 +0100, Gioele Barabucci wrote:
> Package: dpkg-dev
> Version: 1.23.5
> Severity: wishlist

> Running `dpkg-scanpackages --arch=amd64 dir/` generates a Packages
> file that includes both arch-amd64 and arch-all packages.
> 
> (This made sense previously because Debian and other derivatives did
> not have a `main/binary-all` binary path, just `main/binary-$arch`.
> And it probably still makes sense until bugs like #915948 [1] are
> fully resolved.)

> [1] <https://bugs.debian.org/915948>

I think for local repos it still makes sense, independently from how
Debian and derivatives organizes its repositories.

> However it would be nice to have a way to exclude arch-all packages
> while generating Packages files.

But I agree it would be nice to have the option to generate split
repos.

> Could `--arch=foo` be modified to mean "strictly foo, without all"?
> Alternatively could a new option like `--arch-strict=foo` be
> introduced, if you believe that the old behavior should not change?

I don't think changing the semantics for --arch would be correct, as
this is how it has been documented, and how people have relied on this
option working. Instead I've added a new --no-implicit-arch option,
which removes the implicit addition of the arch-all packages, so then
you can run twice with --arch=foo and then --arch=all for example.

(Attached the current change which I've queued for my next push
targeting the next dpkg release.)

Thanks,
Guillem
From cffafc7f9e4b9d557610e91fcc2691879925990b Mon Sep 17 00:00:00 2001
From: Guillem Jover <[email protected]>
Date: Thu, 19 Feb 2026 03:41:09 +0100
Subject: [PATCH] dpkg-scanpackages: Add new --no-implicit-arch option
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This option makes --arch not include the implicit «all» architecture
when scanning for binary packages, so that callers can generate
separate architecture specific and architecture independent Packages
files.

Closes: #1128325
---
 man/dpkg-scanpackages.pod    | 12 ++++++++++--
 scripts/dpkg-scanpackages.pl |  9 ++++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/man/dpkg-scanpackages.pod b/man/dpkg-scanpackages.pod
index e8cba1fcd..ad2c8e163 100644
--- a/man/dpkg-scanpackages.pod
+++ b/man/dpkg-scanpackages.pod
@@ -103,8 +103,16 @@ for more information on its format.
 
 =item B<-a>, B<--arch> I<arch>
 
-Use a pattern consisting of I<*_all.deb> and I<*_arch.deb> instead of
-scanning for all debs.
+Use a pattern consisting of I<*_all.deb> and I<*_arch.deb>,
+or I<*_arch.deb> if B<--no-implicit-arch> has been specified,
+instead of scanning for all debs.
+
+=item B<--no-implicit-arch>
+
+Do not implicitly add architecture B<all> binary packages when specifying
+B<--arch>.
+
+Supported since dpkg 1.23.6.
 
 =item B<-h>, B<--hash> I<hash-list>
 
diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl
index b5d0c8498..b01793468 100755
--- a/scripts/dpkg-scanpackages.pl
+++ b/scripts/dpkg-scanpackages.pl
@@ -54,6 +54,7 @@ my %options = (
     },
     type            => undef,
     arch            => undef,
+    'implicit-arch' => 1,
     hash            => undef,
     multiversion    => 0,
     'extra-override' => undef,
@@ -65,6 +66,7 @@ my @options_spec = (
     'version',
     'type|t=s',
     'arch|a=s',
+    'implicit-arch!',
     'hash|h=s',
     'multiversion|m!',
     'extra-override|e=s',
@@ -82,6 +84,7 @@ sub usage {
 Options:
   -t, --type <type>        scan for <type> packages (default is 'deb').
   -a, --arch <arch>        architecture to scan for.
+      --no-implicit-arch   do not add implicit architecture all to --arch.
   -h, --hash <hash-list>   only generate hashes for the specified list.
   -m, --multiversion       allow multiple versions of a single package.
   -e, --extra-override <file>
@@ -257,7 +260,11 @@ $pathprefix //= '';
 
 my $find_filter;
 if ($options{arch}) {
-    $find_filter = qr/_(?:all|${arch})\.$type$/;
+    if ($options{'implicit-arch'}) {
+        $find_filter = qr/_(?:all|${arch})\.$type$/;
+    } else {
+        $find_filter = qr/_${arch}\.$type$/;
+    }
 } else {
     $find_filter = qr/\.$type$/;
 }
-- 
2.51.0

Reply via email to