🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.debian.maint.dpkg
8 messages
8 total messages Started by Cheng Li Fri, 30 Oct 2026 11:50
Bug#1061450: dpkg-dev: Please add bash completion for dpkg-buildpackage
#6
Author: Cheng Li
Date: Fri, 30 Oct 2026 11:50
79 lines
6665 bytes
Control: tags -1 + patch

Hi Guillem,

Here is the patch series you asked for back in July; sorry for the long
delay.  It is two patches on top of current main (7492eb3d9).

Patch 1 fixes a bug I ran into while enumerating the options.  The
--help output has documented -ap's long form as --sign-pause since the
long options were added in 1.18.8 (293bd243a), but the parser was
written as --sign-pausa, so the documented spelling has never been
accepted, and the accepted one has never been documented, neither in
--help nor in the man page.  I did not keep the misspelling as a
deprecated alias: it was never part of the documented interface, and
-ap has always worked, so there is nothing to deprecate; --sign-pausa
now gets the usual unknown option error, which names the option.  The
patch also adds the man page entry, which has been missing all along,
annotated as "Support for long option since dpkg 1.23.12", as that is
when the long option starts to actually work; please adjust if this
lands in a different release.  A test asserts that the documented
spelling is accepted.

Patch 2 is the completion itself, following the dpkg-source file on
main and the bash-completion 2.12 API, together with the packaging
bits, in the shape of 9d6fa2c83.  It completes option names and, where
there is something sensible to offer, option values: build types, rules
targets, architectures, build profiles, OpenPGP backends, compression
parameters, command arguments for --root-command, --sign-command,
--check-command and --hook-*, pathname arguments, and the positional
.dsc file or source directory.  The --buildinfo-id, -E and -W options
are deliberately not completed, as they are accepted but have no
effect.

One packaging note: debian/dpkg-dev.install lists the files
individually, and with debhelper compat 13 dh_missing --fail-missing is
the default, so without that line dpkg's own package build fails.

I tested the completion with an offline harness that drives the
function directly (26 cases, covering option names and values) against
bash-completion 2.16; make check passes in a configured tree; and a
full "dpkg-buildpackage -b" of dpkg itself succeeds, with dh_missing
quiet and lintian reporting nothing on dpkg-dev.

Two unrelated things I noticed, both happy to turn into patches if you
want them:

- scripts/.gitignore uses unanchored script names, so the new
  completion file matches the "dpkg-buildpackage" entry and needs
  git add -f; the imported dpkg-source completion has the same
  property.  Anchoring the entries with a leading "/" would avoid it.

- Test::Dpkg::all_shell_files does not pick up
  scripts/completion/bash/, so t/shellcheck.t has never covered the
  completion files, dpkg-source included.  I ran shellcheck by hand
  with the exclude list from t/shellcheck.t, which is how I noticed
  SC1010 on the "done" hook name; patch 2 quotes it.

I can also push the series as a branch to my Salsa fork if that is
easier to look at, and I am happy to rework anything.

Best regards,
Cheng Li

Cheng Li (2):
  dpkg-buildpackage: Fix --sign-pause long option name
  completion: Add bash completion for dpkg-buildpackage

 debian/copyright                          |   1 +
 debian/dpkg-dev.install                   |   1 +
 man/dpkg-buildpackage.pod                 |   7 +
 scripts/Makefile.am                       |   1 +
 scripts/completion/bash/dpkg-buildpackage | 170 ++++++++++++++++++++++
 scripts/dpkg-buildpackage.pl              |   2 +-
 scripts/t/dpkg_buildpackage.t             |  17 ++-
 7 files changed, 197 insertions(+), 2 deletions(-)
 create mode 100644 scripts/completion/bash/dpkg-buildpackage

-- 
2.47.3
Bug#1061450: [PATCH 2/2] completion: Add bash completion for dpkg-buildpackage
#5
Author: Cheng Li
Date: Fri, 30 Oct 2026 11:50
240 lines
10709 bytes
Follow the layout and idioms of the dpkg-source completion, using the
bash-completion 2.12 API.  Complete option names, and values for the
options that take one: build types, rules targets, architectures via
dpkg-architecture --list-known, build profiles, OpenPGP backends,
compression parameters, hook and other command arguments, pathname
arguments, and the positional .dsc filename or source directory.
Unlike dpkg-source, split the words on "=" and complete the long options
in that spelling, as many of them only accept a value in that form.

The options taking a comma-separated list (--build, --rules-target and
--build-profiles) are completed element per element, and the ones taking
an optional value only in the "=" form (--jobs and friends,
--diff-ignore and --tar-ignore) offer both spellings.

The --buildinfo-id, -E and -W options, which are accepted but without
effect, are intentionally not completed.

Closes: #1061450
---
 debian/copyright                          |   1 +
 debian/dpkg-dev.install                   |   1 +
 scripts/Makefile.am                       |   1 +
 scripts/completion/bash/dpkg-buildpackage | 170 ++++++++++++++++++++++
 4 files changed, 173 insertions(+)
 create mode 100644 scripts/completion/bash/dpkg-buildpackage

diff --git a/debian/copyright b/debian/copyright
index d8a445fd1..7ddcf9e6c 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -87,6 +87,7 @@ Copyright:
  Copyright © 2018 Uwe Storbeck <uwe@ibr.ch>
  Copyright © 2021-2024 Koichi Murase <myoga.murase@gmail.com>
  Copyright © 2024 Arnaud Rebillout <arnaudr@kali.org>
+ Copyright © 2026 Cheng Li <shiptux@gmail.com>
  Copyright © 2026 Guillem Jover <guillem@debian.org>
 License: GPL-2+
 
diff --git a/debian/dpkg-dev.install b/debian/dpkg-dev.install
index 3d87080cc..4a509496a 100644
--- a/debian/dpkg-dev.install
+++ b/debian/dpkg-dev.install
@@ -21,6 +21,7 @@ usr/bin/dpkg-scansources
 usr/bin/dpkg-shlibdeps
 usr/bin/dpkg-source
 usr/bin/dpkg-vendor
+usr/share/bash-completion/completions/dpkg-buildpackage
 usr/share/bash-completion/completions/dpkg-source
 usr/share/dpkg/*.mk
 usr/share/zsh/vendor-completions/_dpkg-parsechangelog
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 0fa3165bf..4d91e602c 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -155,6 +155,7 @@ CLEANFILES += \
 	# EOL
 
 dist_bashcompletions_DATA = \
+	completion/bash/dpkg-buildpackage \
 	completion/bash/dpkg-source \
 	# EOL
 
diff --git a/scripts/completion/bash/dpkg-buildpackage b/scripts/completion/bash/dpkg-buildpackage
new file mode 100644
index 000000000..3497e309a
--- /dev/null
+++ b/scripts/completion/bash/dpkg-buildpackage
@@ -0,0 +1,170 @@
+#!/bin/bash
+# dpkg-buildpackage(1) bash completion
+#
+# Copyright © 2026 Cheng Li <shiptux@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+_comp_cmd_dpkg_buildpackage()
+{
+  # shellcheck disable=SC2034
+  local cur prev words cword was_split comp_args
+  _comp_initialize -s -- "$@" || return
+
+  local -a options buildtypes rulestargets hookopts sourceopts
+  local hook
+
+  buildtypes=(
+    source
+    any
+    all
+    binary
+    full
+  )
+  rulestargets=(
+    clean
+    build
+    build-arch
+    build-indep
+    binary
+    binary-arch
+    binary-indep
+  )
+  hookopts=()
+  for hook in preinit init preclean source build binary buildinfo \
+              changes postclean check sign 'done'; do
+    hookopts+=("--hook-$hook=")
+  done
+  sourceopts=(
+    -si -sa -sd
+    -sn -ss -sA -sk -su -sr -sK -sU -sR
+    -i --diff-ignore --diff-ignore=
+    -I --tar-ignore --tar-ignore=
+    -z --compression-level=
+    -Z --compression=
+    --source-option=
+  )
+  options=(
+    --help --version
+    --admindir=
+    --build=
+    -b -B -A -S -G -g -F
+    -T --target= --rules-target=
+    --as-root
+    --rules-requires-root
+    -R --rules-file=
+    --pre-clean -nc --no-pre-clean
+    -tc --post-clean --no-post-clean
+    --sanitize-env
+    -d -D --check-builddeps --no-check-builddeps
+    --ignore-builtin-builddeps
+    -j -J --jobs --jobs= --jobs-try --jobs-try= --jobs-force --jobs-force=
+    -a --host-arch=
+    -t --host-type=
+    --target-arch= --target-type=
+    -P --build-profiles=
+    -v -C
+    -m --source-by= --build-by=
+    -e --changed-by= --release-by=
+    --changes-option= --changes-file=
+    --buildinfo-option= --buildinfo-file=
+    --check-command= --check-option=
+    -r --root-command=
+    --sign-backend=
+    -p --sign-command=
+    --sign-keyfile=
+    -k --sign-keyid=
+    --sign-key=
+    --force-sign --no-sign
+    -us --unsigned-source
+    -ui --unsigned-buildinfo
+    -uc --unsigned-changes
+    -ap --sign-pause
+    "${hookopts[@]}"
+    "${sourceopts[@]}"
+  )
+
+  case $prev in
+  --admindir)
+    _comp_compgen_filedir -d
+    return
+    ;;
+  --build)
+    _comp_delimited , -W "${buildtypes[*]}"
+    return
+    ;;
+  -T | --target | --rules-target)
+    _comp_delimited , -W "${rulestargets[*]}"
+    return
+    ;;
+  -a | --host-arch | --target-arch)
+    _comp_compgen_split -- "$(command dpkg-architecture --list-known 2>/dev/null)"
+    return
+    ;;
+  --build-profiles)
+    # Complete the registered common profiles.
+    _comp_delimited , -W 'cross nocheck nodoc noinsttest nopython noudeb
+      stage1 stage2'
+    return
+    ;;
+  --rules-file | --sign-keyfile | --buildinfo-file | --changes-file)
+    _comp_compgen_filedir
+    return
+    ;;
+  --root-command | --sign-command | --check-command | --hook-*)
+    _comp_compgen_commands
+    return
+    ;;
+  --sign-backend)
+    _comp_compgen -- -W 'auto gpg sq sop'
+    return
+    ;;
+  --compression)
+    _comp_compgen -- -W 'gzip xz bzip2 lzma'
+    return
+    ;;
+  --compression-level)
+    _comp_compgen -- -W '{0..9}'
+    return
+    ;;
+  --jobs | --jobs-try | --jobs-force)
+    # These options accept an optional value only in the = form.
+    [[ $was_split ]] || return
+    _comp_compgen -- -W 'auto'
+    return
+    ;;
+  -t | --host-type | --target-type)
+    # GNU system types, no sensible completion.
+    return
+    ;;
+  --source-by | --build-by | --changed-by | --release-by | \
+  --sign-key | --sign-keyid | --source-option | --changes-option | \
+  --buildinfo-option | --check-option)
+    # Free-form values, no sensible completion.
+    return
+    ;;
+  esac
+
+  # A value glued to a long option with "=" was already handled above.
+  [[ $was_split ]] && return
+
+  if [[ $cur == -* ]]; then
+    _comp_compgen -- -W "${options[*]}"
+    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+    return
+  fi
+
+  # The optional positional argument is a .dsc file or a source directory.
+  _comp_compgen_filedir 'dsc'
+} && complete -F _comp_cmd_dpkg_buildpackage dpkg-buildpackage
-- 
2.47.3
Bug#1061450: [PATCH 1/2] dpkg-buildpackage: Fix --sign-pause long option name
#7
Author: Cheng Li
Date: Fri, 30 Oct 2026 11:50
87 lines
5875 bytes
The long options were added in dpkg 1.18.8, where the --help output
documented this one as --sign-pause, while the parser was written as
--sign-pausa.  The documented spelling has therefore never been
accepted, and the accepted spelling has never been documented, neither
in --help nor in the man page.

Correct the parser to use the documented and intended spelling.  Do not
keep the misspelling as a deprecated alias, as it was never part of the
documented interface, and the short -ap option has always worked; it now
gets the usual unknown option error, which names the offending option.

Document the option in the man page, which has been missing an entry for
it all along.
---
 man/dpkg-buildpackage.pod     |  7 +++++++
 scripts/dpkg-buildpackage.pl  |  2 +-
 scripts/t/dpkg_buildpackage.t | 17 ++++++++++++++++-
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/man/dpkg-buildpackage.pod b/man/dpkg-buildpackage.pod
index cd49ba2d0..89eb110a8 100644
--- a/man/dpkg-buildpackage.pod
+++ b/man/dpkg-buildpackage.pod
@@ -731,6 +731,13 @@ password.
 
 Supported since dpkg 1.21.10.
 
+=item B<-ap>, B<--sign-pause>
+
+Wait for the user to press B<Enter> before starting the signing process.
+This only has an effect if at least one file is going to be signed.
+
+Support for long option since dpkg 1.23.12.
+
 =item B<-us>, B<--unsigned-source>
 
 Do not sign the source package.
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index f057a64cf..3e41911d9 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -545,7 +545,7 @@ while (@ARGV) {
     } elsif (/^-uc$/ or /^--unsigned-changes$/) {
         $signbuildinfo = 0;
         $signchanges = 0;
-    } elsif (/^-ap$/ or /^--sign-pausa$/) {
+    } elsif (/^-ap$/ or /^--sign-pause$/) {
         $signpause = 1;
     } elsif (/^-a$/ or /^--host-arch$/) {
         $host_arch = shift;
diff --git a/scripts/t/dpkg_buildpackage.t b/scripts/t/dpkg_buildpackage.t
index cbfe03b78..405388831 100644
--- a/scripts/t/dpkg_buildpackage.t
+++ b/scripts/t/dpkg_buildpackage.t
@@ -29,7 +29,7 @@ use Dpkg::BuildTypes;
 use Dpkg::Substvars;
 
 test_needs_command('fakeroot');
-plan tests => 17;
+plan tests => 18;
 
 my $srcdir = rel2abs($ENV{srcdir} || '.');
 my $datadir = "$srcdir/t/dpkg_buildpackage";
@@ -52,6 +52,21 @@ $ENV{PATH} = "$srcdir/t/mock-bin:$ENV{PATH}";
 
 chdir $tmpdir;
 
+my $stderr;
+
+spawn(
+    exec => [
+        $ENV{PERL}, "$srcdir/dpkg-buildpackage.pl",
+        '--sign-pause', '--help',
+    ],
+    to_file => '/dev/null',
+    error_to_string => \$stderr,
+    wait_child => 1,
+    no_check => 1,
+);
+ok($? == 0 && $stderr eq '', '--sign-pause is accepted');
+diag($stderr) unless $? == 0;
+
 my $tmpl_format = <<'TMPL_FORMAT';
 3.0 (native)
 TMPL_FORMAT
-- 
2.47.3
Bug#1061450: dpkg-dev: Please add bash completion for dpkg-buildpackage
#8
Author: Guillem Jover
Date: Sat, 31 Oct 2026 19:50
94 lines
6452 bytes
Hi!

On Fri, 2026-10-30 at 20:44:01 +0900, Cheng Li wrote:
> Control: tags -1 + patch

> Here is the patch series you asked for back in July; sorry for the long
> delay.  It is two patches on top of current main (7492eb3d9).

Thanks!

> Patch 1 fixes a bug I ran into while enumerating the options.  The
> --help output has documented -ap's long form as --sign-pause since the
> long options were added in 1.18.8 (293bd243a), but the parser was
> written as --sign-pausa, so the documented spelling has never been
> accepted, and the accepted one has never been documented, neither in
> --help nor in the man page.  I did not keep the misspelling as a
> deprecated alias: it was never part of the documented interface, and
> -ap has always worked, so there is nothing to deprecate; --sign-pausa
> now gets the usual unknown option error, which names the option.  The
> patch also adds the man page entry, which has been missing all along,
> annotated as "Support for long option since dpkg 1.23.12", as that is
> when the long option starts to actually work; please adjust if this
> lands in a different release.  A test asserts that the documented
> spelling is accepted.

Nice catch, perfect! I've merged this locally and will include in my
next push.

> Patch 2 is the completion itself, following the dpkg-source file on
> main and the bash-completion 2.12 API, together with the packaging
> bits, in the shape of 9d6fa2c83.  It completes option names and, where
> there is something sensible to offer, option values: build types, rules
> targets, architectures, build profiles, OpenPGP backends, compression
> parameters, command arguments for --root-command, --sign-command,
> --check-command and --hook-*, pathname arguments, and the positional
> .dsc file or source directory.  The --buildinfo-id, -E and -W options
> are deliberately not completed, as they are accepted but have no
> effect.

Ah, thanks! I had also started adding the missing completions for all
commands last month, and ended up partially doing dpkg-buildpackage,
in the following WIP pu/bash-completions branch from this repo, which
I just rebased and pushed to:

  <https://git.hadrons.org/cgit/debian/dpkg/dpkg.git>

But it seems some of my changes complement some of yours. So it would
make sense if you adopted some of those into your patch?

> One packaging note: debian/dpkg-dev.install lists the files
> individually, and with debhelper compat 13 dh_missing --fail-missing is
> the default, so without that line dpkg's own package build fails.

Sure, it is expected that we add explicit lines for each new script,
instead of using globs, so that we control when something appears or
disappears (on purpose or by accident).

> I tested the completion with an offline harness that drives the
> function directly (26 cases, covering option names and values) against
> bash-completion 2.16; make check passes in a configured tree; and a
> full "dpkg-buildpackage -b" of dpkg itself succeeds, with dh_missing
> quiet and lintian reporting nothing on dpkg-dev.

Ah great!

> Two unrelated things I noticed, both happy to turn into patches if you
> want them:
> 
> - scripts/.gitignore uses unanchored script names, so the new
>   completion file matches the "dpkg-buildpackage" entry and needs
>   git add -f; the imported dpkg-source completion has the same
>   property.  Anchoring the entries with a leading "/" would avoid it.

Right, it looks I was also bothered by this, and ended up adding negated
entries (in a commit in that branch). But I think I do prefer your
proposed fix better. So feel free to provide a patch for that.

> - Test::Dpkg::all_shell_files does not pick up
>   scripts/completion/bash/, so t/shellcheck.t has never covered the
>   completion files, dpkg-source included.  I ran shellcheck by hand
>   with the exclude list from t/shellcheck.t, which is how I noticed
>   SC1010 on the "done" hook name; patch 2 quotes it.

Nice catch as well. I was curious whether the current completion files
were fine, so added this locally now (with attribution), and fixed a
couple of issues with the dpkg-deb completion.

> I can also push the series as a branch to my Salsa fork if that is
> easier to look at, and I am happy to rework anything.

No worries, this is good.

Thanks,
Guillem
Bug#1061450: [PATCH v2 1/2] build: Anchor .gitignore entries for generated files
#9
Author: Cheng Li
Date: Tue, 03 Nov 2026 08:50
128 lines
6052 bytes
All the entries in these four directories name files generated at the
top level of the directory, but none of them is anchored, so they also
match any file with the same name in a subdirectory.

The bash completion files are named after the programs they complete and
live in <dir>/completion/bash/, so each of them is currently matched by
the entry for its own generated program.  Adding a new completion file
needs git add -f, and git add -A skips it silently.

Anchor every entry with a leading "/" so that it only matches the
generated file it is meant to match.

Ref: #1061450
---
 dselect/.gitignore |  6 +++---
 scripts/.gitignore | 48 +++++++++++++++++++++++-----------------------
 src/.gitignore     | 24 +++++++++++------------
 utils/.gitignore   |  8 ++++----
 4 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/dselect/.gitignore b/dselect/.gitignore
index bba6d3455..20629e6cf 100644
--- a/dselect/.gitignore
+++ b/dselect/.gitignore
@@ -1,3 +1,3 @@
-curkeys.h
-curkeys.hpp
-dselect
+/curkeys.h
+/curkeys.hpp
+/dselect
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 8bbf4e05b..17c8d7d89 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -1,24 +1,24 @@
-Build.PL
-README.cpan
-dpkg-architecture
-dpkg-buildapi
-dpkg-buildflags
-dpkg-buildpackage
-dpkg-buildtree
-dpkg-checkbuilddeps
-dpkg-distaddfile
-dpkg-genbuildinfo
-dpkg-genchanges
-dpkg-gencontrol
-dpkg-gensymbols
-dpkg-mergechangelogs
-dpkg-name
-dpkg-parsechangelog
-dpkg-scanpackages
-dpkg-scansources
-dpkg-shlibdeps
-dpkg-source
-dpkg-statoverride
-dpkg-vendor
-t.tmp
-cover_db
+/Build.PL
+/README.cpan
+/dpkg-architecture
+/dpkg-buildapi
+/dpkg-buildflags
+/dpkg-buildpackage
+/dpkg-buildtree
+/dpkg-checkbuilddeps
+/dpkg-distaddfile
+/dpkg-genbuildinfo
+/dpkg-genchanges
+/dpkg-gencontrol
+/dpkg-gensymbols
+/dpkg-mergechangelogs
+/dpkg-name
+/dpkg-parsechangelog
+/dpkg-scanpackages
+/dpkg-scansources
+/dpkg-shlibdeps
+/dpkg-source
+/dpkg-statoverride
+/dpkg-vendor
+/t.tmp
+/cover_db
diff --git a/src/.gitignore b/src/.gitignore
index 3a122bf11..13279a60d 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,12 +1,12 @@
-dpkg
-dpkg-db-backup
-dpkg-db-keeper
-dpkg-deb
-dpkg-divert
-dpkg-maintscript-helper
-dpkg-query
-dpkg-realpath
-dpkg-split
-dpkg-statoverride
-dpkg-trigger
-t.tmp
+/dpkg
+/dpkg-db-backup
+/dpkg-db-keeper
+/dpkg-deb
+/dpkg-divert
+/dpkg-maintscript-helper
+/dpkg-query
+/dpkg-realpath
+/dpkg-split
+/dpkg-statoverride
+/dpkg-trigger
+/t.tmp
diff --git a/utils/.gitignore b/utils/.gitignore
index edc11e367..005b37350 100644
--- a/utils/.gitignore
+++ b/utils/.gitignore
@@ -1,4 +1,4 @@
-org.dpkg.pkexec.update-alternatives.policy
-start-stop-daemon
-update-alternatives
-t.tmp
+/org.dpkg.pkexec.update-alternatives.policy
+/start-stop-daemon
+/update-alternatives
+/t.tmp
-- 
2.47.3
Bug#1061450: [PATCH v2 2/2] completion: Add bash completion for dpkg-buildpackage
#10
Author: Cheng Li
Date: Tue, 03 Nov 2026 08:50
254 lines
11346 bytes
Follow the layout and idioms of the dpkg-source completion, using the
bash-completion 2.12 API.  Complete option names, and values for the
options that take one: build types, rules targets, architectures via
dpkg-architecture --list-known, build profiles, OpenPGP backends and
signing commands, compression parameters, hook and other command
arguments, pathname arguments, and the positional .dsc filename or
source directory.
Unlike dpkg-source, split the words on "=" and complete the long options
in that spelling, as many of them only accept a value in that form.

The options taking a comma-separated list (--build, --rules-target and
--build-profiles) are completed element per element, and the ones taking
an optional value only in the "=" form (--jobs and friends,
--diff-ignore and --tar-ignore) offer both spellings.

For --sign-command, complete the signing commands of the supported
OpenPGP backends rather than any command name, as those are the expected
values.  Unlike for --sign-backend, "auto" and "none" are not offered,
as the value is looked up in PATH and both would error out.

The --buildinfo-id, -E and -W options, which are accepted but without
effect, are intentionally not completed.

Improved-by: Guillem Jover <guillem@debian.org>
Closes: #1061450
---
 debian/copyright                          |   1 +
 debian/dpkg-dev.install                   |   1 +
 scripts/Makefile.am                       |   1 +
 scripts/completion/bash/dpkg-buildpackage | 177 ++++++++++++++++++++++
 4 files changed, 180 insertions(+)
 create mode 100644 scripts/completion/bash/dpkg-buildpackage

diff --git a/debian/copyright b/debian/copyright
index d8a445fd1..7ddcf9e6c 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -87,6 +87,7 @@ Copyright:
  Copyright © 2018 Uwe Storbeck <uwe@ibr.ch>
  Copyright © 2021-2024 Koichi Murase <myoga.murase@gmail.com>
  Copyright © 2024 Arnaud Rebillout <arnaudr@kali.org>
+ Copyright © 2026 Cheng Li <shiptux@gmail.com>
  Copyright © 2026 Guillem Jover <guillem@debian.org>
 License: GPL-2+
 
diff --git a/debian/dpkg-dev.install b/debian/dpkg-dev.install
index 3d87080cc..4a509496a 100644
--- a/debian/dpkg-dev.install
+++ b/debian/dpkg-dev.install
@@ -21,6 +21,7 @@ usr/bin/dpkg-scansources
 usr/bin/dpkg-shlibdeps
 usr/bin/dpkg-source
 usr/bin/dpkg-vendor
+usr/share/bash-completion/completions/dpkg-buildpackage
 usr/share/bash-completion/completions/dpkg-source
 usr/share/dpkg/*.mk
 usr/share/zsh/vendor-completions/_dpkg-parsechangelog
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 0fa3165bf..4d91e602c 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -155,6 +155,7 @@ CLEANFILES += \
 	# EOL
 
 dist_bashcompletions_DATA = \
+	completion/bash/dpkg-buildpackage \
 	completion/bash/dpkg-source \
 	# EOL
 
diff --git a/scripts/completion/bash/dpkg-buildpackage b/scripts/completion/bash/dpkg-buildpackage
new file mode 100644
index 000000000..315f7f26a
--- /dev/null
+++ b/scripts/completion/bash/dpkg-buildpackage
@@ -0,0 +1,177 @@
+#!/bin/bash
+# dpkg-buildpackage(1) bash completion
+#
+# Copyright © 2026 Cheng Li <shiptux@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+_comp_cmd_dpkg_buildpackage()
+{
+  # shellcheck disable=SC2034
+  local cur prev words cword was_split comp_args
+  _comp_initialize -s -- "$@" || return
+
+  local -a options buildtypes rulestargets hookopts sourceopts
+  local hook
+
+  buildtypes=(
+    source
+    any
+    all
+    binary
+    full
+  )
+  rulestargets=(
+    clean
+    build
+    build-arch
+    build-indep
+    binary
+    binary-arch
+    binary-indep
+  )
+  hookopts=()
+  for hook in preinit init preclean source build binary buildinfo \
+              changes postclean check sign 'done'; do
+    hookopts+=("--hook-$hook=")
+  done
+  sourceopts=(
+    -si -sa -sd
+    -sn -ss -sA -sk -su -sr -sK -sU -sR
+    -i --diff-ignore --diff-ignore=
+    -I --tar-ignore --tar-ignore=
+    -z --compression-level=
+    -Z --compression=
+    --source-option=
+  )
+  options=(
+    --help --version
+    --admindir=
+    --build=
+    -b -B -A -S -G -g -F
+    -T --target= --rules-target=
+    --as-root
+    --rules-requires-root
+    -R --rules-file=
+    --pre-clean -nc --no-pre-clean
+    -tc --post-clean --no-post-clean
+    --sanitize-env
+    -d -D --check-builddeps --no-check-builddeps
+    --ignore-builtin-builddeps
+    -j -J --jobs --jobs= --jobs-try --jobs-try= --jobs-force --jobs-force=
+    -a --host-arch=
+    -t --host-type=
+    --target-arch= --target-type=
+    -P --build-profiles=
+    -v -C
+    -m --source-by= --build-by=
+    -e --changed-by= --release-by=
+    --changes-option= --changes-file=
+    --buildinfo-option= --buildinfo-file=
+    --check-command= --check-option=
+    -r --root-command=
+    --sign-backend=
+    -p --sign-command=
+    --sign-keyfile=
+    -k --sign-keyid=
+    --sign-key=
+    --force-sign --no-sign
+    -us --unsigned-source
+    -ui --unsigned-buildinfo
+    -uc --unsigned-changes
+    -ap --sign-pause
+    "${hookopts[@]}"
+    "${sourceopts[@]}"
+  )
+
+  case $prev in
+  --admindir)
+    _comp_compgen_filedir -d
+    return
+    ;;
+  --build)
+    _comp_delimited , -W "${buildtypes[*]}"
+    return
+    ;;
+  -T | --target | --rules-target)
+    _comp_delimited , -W "${rulestargets[*]}"
+    return
+    ;;
+  -a | --host-arch | --target-arch)
+    _comp_compgen_split -- "$(command dpkg-architecture --list-known 2>/dev/null)"
+    return
+    ;;
+  --build-profiles)
+    # Complete the registered common profiles.
+    _comp_delimited , -W 'cross nocheck nodoc noinsttest nopython noudeb
+      stage1 stage2'
+    return
+    ;;
+  --rules-file | --sign-keyfile | --buildinfo-file | --changes-file)
+    _comp_compgen_filedir
+    return
+    ;;
+  --root-command | --check-command | --hook-*)
+    _comp_compgen_commands
+    return
+    ;;
+  --sign-backend)
+    _comp_compgen -- -W 'auto gpg sq sop'
+    return
+    ;;
+  --sign-command)
+    # The signing commands of the supported OpenPGP backends, in backend
+    # preference order.  The value is looked up in PATH, so unlike for
+    # --sign-backend, "auto" and "none" are not accepted here.
+    _comp_compgen -- -W 'sqop rsop gosop hop pgpainless-cli sq gpg-sq gpg'
+    return
+    ;;
+  --compression)
+    _comp_compgen -- -W 'gzip xz bzip2 lzma'
+    return
+    ;;
+  --compression-level)
+    _comp_compgen -- -W '{0..9}'
+    return
+    ;;
+  --jobs | --jobs-try | --jobs-force)
+    # These options accept an optional value only in the = form.
+    [[ $was_split ]] || return
+    _comp_compgen -- -W 'auto'
+    return
+    ;;
+  -t | --host-type | --target-type)
+    # GNU system types, no sensible completion.
+    return
+    ;;
+  --source-by | --build-by | --changed-by | --release-by | \
+  --sign-key | --sign-keyid | --source-option | --changes-option | \
+  --buildinfo-option | --check-option)
+    # Free-form values, no sensible completion.
+    return
+    ;;
+  esac
+
+  # A value glued to a long option with "=" was already handled above.
+  [[ $was_split ]] && return
+
+  if [[ $cur == -* ]]; then
+    _comp_compgen -- -W "${options[*]}"
+    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+    return
+  fi
+
+  # The optional positional argument is a .dsc file or a source directory.
+  _comp_compgen_filedir 'dsc'
+} && complete -F _comp_cmd_dpkg_buildpackage dpkg-buildpackage
-- 
2.47.3
Bug#1061450: dpkg-dev: Please add bash completion for dpkg-buildpackage
#11
Author: Cheng Li
Date: Tue, 03 Nov 2026 08:50
45 lines
5113 bytes
Hi Guillem,

Here is v2 of the series. It no longer contains the --sign-pause fix,
since you have merged that locally already. Patch 1/2 is new (the
.gitignore change), and patch 2/2 is the updated completion file.

> But it seems some of my changes complement some of yours. So it would
> make sense if you adopted some of those into your patch?

I fetched your pu/bash-completions branch (4198c5e9b) and compared it
with mine. I adopted your approach of completing --sign-command with a
curated list: mine used _comp_compgen_commands, which expands to 7024
entries here, so it was not usable interactively.

My values differ from yours in two ways. First, neither auto nor none is
offered, as dpkg-buildpackage validates the value with find_command()
before it reaches the backend (scripts/dpkg-buildpackage.pl:674), so
both error out with "sign-command 'auto' not found". Second, the *v
commands (sqopv, rsopv, sqv, gpgv-sq and gpgv) are the verification
commands (DEFAULT_CMDV), rather than the signing ones. The final list is
the DEFAULT_CMD of each supported backend, in the backend preference
order from dpkg-buildpackage(1).

I did not adopt -x dpkg_architecture, because the xfunc is defined in
the dpkg-architecture completion file, which is not in main yet; adding
it now makes --host-arch complete nothing. I will switch to it once that
file lands.

> Right, it looks I was also bothered by this, and ended up adding negated
> entries (in a commit in that branch). But I think I do prefer your
> proposed fix better. So feel free to provide a patch for that.

Patch 1/2 does this. It anchors every entry in scripts/, src/, dselect/
and utils/, which are the four directories containing a completion/bash/
subdirectory. Once it is applied, the negated entries you added in
3c498a0c3 will no longer be needed.

> Nice catch as well. I was curious whether the current completion files
> were fine, so added this locally now (with attribution), and fixed a
> couple of issues with the dpkg-deb completion.

Thank you, both for adding the test and for the attribution.

Best regards,
Cheng Li
Bug#1061450: [PATCH v3] completion: Add bash completion for dpkg-buildpackage
#19
Author: Cheng Li
Date: Mon, 23 Nov 2026 07:20
261 lines
11442 bytes
Follow the layout and idioms of the dpkg-source completion, using the
bash-completion 2.12 API.  Complete option names, and values for the
options that take one: build types, rules targets, architectures via
dpkg-architecture --list-known, build profiles, OpenPGP backends and
signing commands, compression parameters, hook and other command
arguments, pathname arguments, and the positional .dsc filename or
source directory.
Unlike dpkg-source, split the words on "=" and complete the long options
in that spelling, as many of them only accept a value in that form.

The options taking a comma-separated list (--build, --rules-target and
--build-profiles) are completed element per element, and the ones taking
an optional value only in the "=" form (--jobs and friends,
--diff-ignore and --tar-ignore) offer both spellings.

For --sign-command, complete "auto", "none" and the signing commands of
the supported OpenPGP backends rather than any command name, as those
are the expected values.

The --buildinfo-id, -E and -W options, which are accepted but without
effect, are intentionally not completed.

Improved-by: Guillem Jover <guillem@debian.org>
Closes: #1061450
---
Notes for v3:
- Rebased onto current main (1.23.13 cycle), dropping patch 1/2 from v2
  (merged as 0223b032 in 1.23.12).
- Offer "auto" and "none" for --sign-command now that commit 07aaca91
  accepts both, and align --sign-backend order with @BACKENDS.
  (Thanks for merging the prerequisites in 1.23.12 and for the
  attributions!)

 debian/copyright                          |   1 +
 debian/dpkg-dev.install                   |   1 +
 scripts/Makefile.am                       |   1 +
 scripts/completion/bash/dpkg-buildpackage | 177 ++++++++++++++++++++++
 4 files changed, 180 insertions(+)
 create mode 100644 scripts/completion/bash/dpkg-buildpackage

diff --git a/debian/copyright b/debian/copyright
index d8a445fd1..7ddcf9e6c 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -87,6 +87,7 @@ Copyright:
  Copyright © 2018 Uwe Storbeck <uwe@ibr.ch>
  Copyright © 2021-2024 Koichi Murase <myoga.murase@gmail.com>
  Copyright © 2024 Arnaud Rebillout <arnaudr@kali.org>
+ Copyright © 2026 Cheng Li <shiptux@gmail.com>
  Copyright © 2026 Guillem Jover <guillem@debian.org>
 License: GPL-2+
 
diff --git a/debian/dpkg-dev.install b/debian/dpkg-dev.install
index 3d87080cc..4a509496a 100644
--- a/debian/dpkg-dev.install
+++ b/debian/dpkg-dev.install
@@ -21,6 +21,7 @@ usr/bin/dpkg-scansources
 usr/bin/dpkg-shlibdeps
 usr/bin/dpkg-source
 usr/bin/dpkg-vendor
+usr/share/bash-completion/completions/dpkg-buildpackage
 usr/share/bash-completion/completions/dpkg-source
 usr/share/dpkg/*.mk
 usr/share/zsh/vendor-completions/_dpkg-parsechangelog
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 0fa3165bf..4d91e602c 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -155,6 +155,7 @@ CLEANFILES += \
 	# EOL
 
 dist_bashcompletions_DATA = \
+	completion/bash/dpkg-buildpackage \
 	completion/bash/dpkg-source \
 	# EOL
 
diff --git a/scripts/completion/bash/dpkg-buildpackage b/scripts/completion/bash/dpkg-buildpackage
new file mode 100644
index 000000000..0bc08e523
--- /dev/null
+++ b/scripts/completion/bash/dpkg-buildpackage
@@ -0,0 +1,177 @@
+#!/bin/bash
+# dpkg-buildpackage(1) bash completion
+#
+# Copyright © 2026 Cheng Li <shiptux@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+_comp_cmd_dpkg_buildpackage()
+{
+  # shellcheck disable=SC2034
+  local cur prev words cword was_split comp_args
+  _comp_initialize -s -- "$@" || return
+
+  local -a options buildtypes rulestargets hookopts sourceopts
+  local hook
+
+  buildtypes=(
+    source
+    any
+    all
+    binary
+    full
+  )
+  rulestargets=(
+    clean
+    build
+    build-arch
+    build-indep
+    binary
+    binary-arch
+    binary-indep
+  )
+  hookopts=()
+  for hook in preinit init preclean source build binary buildinfo \
+              changes postclean check sign 'done'; do
+    hookopts+=("--hook-$hook=")
+  done
+  sourceopts=(
+    -si -sa -sd
+    -sn -ss -sA -sk -su -sr -sK -sU -sR
+    -i --diff-ignore --diff-ignore=
+    -I --tar-ignore --tar-ignore=
+    -z --compression-level=
+    -Z --compression=
+    --source-option=
+  )
+  options=(
+    --help --version
+    --admindir=
+    --build=
+    -b -B -A -S -G -g -F
+    -T --target= --rules-target=
+    --as-root
+    --rules-requires-root
+    -R --rules-file=
+    --pre-clean -nc --no-pre-clean
+    -tc --post-clean --no-post-clean
+    --sanitize-env
+    -d -D --check-builddeps --no-check-builddeps
+    --ignore-builtin-builddeps
+    -j -J --jobs --jobs= --jobs-try --jobs-try= --jobs-force --jobs-force=
+    -a --host-arch=
+    -t --host-type=
+    --target-arch= --target-type=
+    -P --build-profiles=
+    -v -C
+    -m --source-by= --build-by=
+    -e --changed-by= --release-by=
+    --changes-option= --changes-file=
+    --buildinfo-option= --buildinfo-file=
+    --check-command= --check-option=
+    -r --root-command=
+    --sign-backend=
+    -p --sign-command=
+    --sign-keyfile=
+    -k --sign-keyid=
+    --sign-key=
+    --force-sign --no-sign
+    -us --unsigned-source
+    -ui --unsigned-buildinfo
+    -uc --unsigned-changes
+    -ap --sign-pause
+    "${hookopts[@]}"
+    "${sourceopts[@]}"
+  )
+
+  case $prev in
+  --admindir)
+    _comp_compgen_filedir -d
+    return
+    ;;
+  --build)
+    _comp_delimited , -W "${buildtypes[*]}"
+    return
+    ;;
+  -T | --target | --rules-target)
+    _comp_delimited , -W "${rulestargets[*]}"
+    return
+    ;;
+  -a | --host-arch | --target-arch)
+    _comp_compgen_split -- "$(command dpkg-architecture --list-known 2>/dev/null)"
+    return
+    ;;
+  --build-profiles)
+    # Complete the registered common profiles.
+    _comp_delimited , -W 'cross nocheck nodoc noinsttest nopython noudeb
+      stage1 stage2'
+    return
+    ;;
+  --rules-file | --sign-keyfile | --buildinfo-file | --changes-file)
+    _comp_compgen_filedir
+    return
+    ;;
+  --root-command | --check-command | --hook-*)
+    _comp_compgen_commands
+    return
+    ;;
+  --sign-backend)
+    _comp_compgen -- -W 'auto sop sq gpg'
+    return
+    ;;
+  --sign-command)
+    # The special values and the signing commands of the supported OpenPGP
+    # backends, in backend preference order.
+    _comp_compgen -- -W 'auto none sqop rsop gosop hop pgpainless-cli sq
+      gpg-sq gpg'
+    return
+    ;;
+  --compression)
+    _comp_compgen -- -W 'gzip xz bzip2 lzma'
+    return
+    ;;
+  --compression-level)
+    _comp_compgen -- -W '{0..9}'
+    return
+    ;;
+  --jobs | --jobs-try | --jobs-force)
+    # These options accept an optional value only in the = form.
+    [[ $was_split ]] || return
+    _comp_compgen -- -W 'auto'
+    return
+    ;;
+  -t | --host-type | --target-type)
+    # GNU system types, no sensible completion.
+    return
+    ;;
+  --source-by | --build-by | --changed-by | --release-by | \
+  --sign-key | --sign-keyid | --source-option | --changes-option | \
+  --buildinfo-option | --check-option)
+    # Free-form values, no sensible completion.
+    return
+    ;;
+  esac
+
+  # A value glued to a long option with "=" was already handled above.
+  [[ $was_split ]] && return
+
+  if [[ $cur == -* ]]; then
+    _comp_compgen -- -W "${options[*]}"
+    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+    return
+  fi
+
+  # The optional positional argument is a .dsc file or a source directory.
+  _comp_compgen_filedir 'dsc'
+} && complete -F _comp_cmd_dpkg_buildpackage dpkg-buildpackage
-- 
2.47.3
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads