🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #3019

Bug#1061450: [PATCH v2 2/2] completion: Add bash completion for dpkg-buildpackage

#3019
From: Cheng Li
Date: Tue, 03 Nov 2026 08:50
254 lines
11263 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
Technical Details
Message-ID: <NVinn-9zqs-9@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!fu-berlin.de!bofh.it!news.nic.it!robomod
References: <NUnfr-93Yz-1@gated-at.bofh.it> <NVinn-9zqs-3@gated-at.bofh.it> <HZQX0-5jPa-15@gated-at.bofh.it> <NVinn-9zqs-3@gated-at.bofh.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!fu-berlin.de!bofh.it!news.nic.it!robomod
From: Cheng Li <shiptux@gmail.com>
Newsgroups: linux.debian.bugs.dist,linux.debian.maint.dpkg
Subject: Bug#1061450: [PATCH v2 2/2] completion: Add bash completion for dpkg-buildpackage
Date: Tue, 03 Nov 2026 09:50:01 +0100
Message-ID: <NVinn-9zqs-9@gated-at.bofh.it>
References: <NUnfr-93Yz-1@gated-at.bofh.it> <NVinn-9zqs-3@gated-at.bofh.it> <HZQX0-5jPa-15@gated-at.bofh.it> <NVinn-9zqs-3@gated-at.bofh.it>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Tue Nov  3 08:41:12 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -0.547
Reply-To: Cheng Li <shiptux@gmail.com>, 1061450@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: debian-dpkg@lists.debian.org
X-Debian-Pr-Message: followup 1061450
X-Debian-Pr-Package: dpkg-dev
X-Debian-Pr-Keywords: patch newcomer
X-Debian-Pr-Source: dpkg
X-Gm-Message-State: APuU4Z+zxvjgu90wR1/SXL21x/cvRGMy+HZvvePVu8xc2PG2ZbxNa+Pc
	Ro2esHMFG+Uc6JEhSoS3ZTc8pgAI0jaxlgktxHCm6gDMHQBEOSD3c8cypQsrW5CG
X-Gm-Gg: AYBFou3bthRS2i1ee+jHICOs5o8B9svff378XAti3a8AmmniF6tzEo7uD58fap2GqRa
	mne94wTx9f6dK39BSQZuGS8XuZkc2M7vHlG1J/e/ToarF4U0rcVhIIKktUVIixFGX648X4PE6Vw
	v0mpeFiLxS+segbujAzUby6v4fKXBQf6cgFyY8Bs2/Wdc7Zm6u6JMgdAdM9GlUgl98YeCpCRk7E
	M29J1tTraUB63OXwcdj7CmyqjcPl6tW6Gs/kUBRK6Tm4GpwHI0GoVuZXwdxYgxQsphSqvTQw5T5
	PB6pzJkLaHroLMURVuqDw0FQW4xsxB352dc2QEtTbdyhOcJYKHU8D/7hut0dY3+NXRF+w3jkpuo
	aMeX6YXxqrZlH44nQrTKakt8LL5LIOyEY81oR0hpGFGqi/ngq+93rfQxGHItDptdn8Q3ELRNhZt
	8cGqB9D6vRSxHVCXNMbq95X72IiNpd9RN8l01YZXoCJUIsU1tvljVL/POPAAR7ST55rCxiNi+tY
	n7r9lKHk3HOrJJC2hSQqdygTIk+NB/IAukD5Bpb//M2losr2Eelvxiig7CV7R2IStASmLHCKQYK
	JggEVNHDpAS20hbtdBA+L6FNP/LjyVzFeb6lA/1FLXW+ZexfpXQ1bD7bbB5YOwQxDi/SHm9+oB5
	N8TFOiape
X-Received: by 2002:a17:90b:2742:b0:3a4:b418:94cf with SMTP id 98e67ed59e1d1-3ae897158ddmr10712909a91.14.1793695131372;
        Tue, 03 Nov 2026 00:38:51 -0800 (PST)
X-Mailer: git-send-email 2.47.3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2000373
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 254
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Cc: Guillem Jover <guillem@debian.org>
X-Original-Date: Tue,  3 Nov 2026 17:38:39 +0900
X-Original-Message-ID: <20261103083839.1737133-3-shiptux@gmail.com>
X-Original-References: <auZEc9gZS01yWzHJ@thunder.hadrons.org> <20261103083839.1737133-1-shiptux@gmail.com> <170612389523.16223.12946706258590361740.reportbug@ag474u.eng.vyatta.net> <20261103083839.1737133-1-shiptux@gmail.com>