From a2a213bf32a68d316e580b2a13adb20f6904357e Mon Sep 17 00:00:00 2001 From: Steffen Hemer Date: Wed, 12 Nov 2025 14:58:24 +0100 Subject: [PATCH 1/3] bash-completion: Add initial draft All commands, options, and command parameters should be completed correctly. Some option parameter won't complete. Signed-off-by: Steffen Hemer --- partup-completion.bash | 122 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 partup-completion.bash diff --git a/partup-completion.bash b/partup-completion.bash new file mode 100644 index 00000000..0e36e877 --- /dev/null +++ b/partup-completion.bash @@ -0,0 +1,122 @@ +#/usr/bin/env bash + +partup_commands="install package show version" +help_options="-h --help" +app_options="-q --quiet -d --debug -D --debug-domains" +install_options="-s --skip-checksums" +package_options="-f --force -C, --directory" +show_options="-s --size" + +function exists_in_list() +{ + LIST=$1 + DELIMITER=$2 + VALUE=$3 + [[ "$LIST" =~ ($DELIMITER|^)$VALUE($DELIMITER|$) ]] +} + +function add_command_help() +{ + if [[ ${previous} == ${command} ]] ; then + # only add help if we are first after command + COMPREPLY+=( $(compgen -W "${help_options}" -- ${current}) ) + fi + if exists_in_list "${help_options}" " " "${previous}" ; then + # if we have choosen help option, nothing should follow + return 0 + fi +} + + +_partup_completions() +{ + local current="" + local previous="" + local command="" + + if [[ ${COMP_CWORD} > 0 ]] ; then + current="${COMP_WORDS[COMP_CWORD]}" + + if [[ ${COMP_CWORD} > 1 ]] ; then + # iterate over all COMP_WORDS + for s in "${COMP_WORDS[@]:1}"; do + if exists_in_list "${partup_commands}" " " "${s}" ; then + command="${s}" + fi + ((i++)) + done + previous="${COMP_WORDS[COMP_CWORD - 1]}" + fi + fi + + if [[ -z ${command} ]] ; then + COMPREPLY=( $(compgen -W "${help_options} ${partup_commands} ${app_options}" -- ${current}) ) + return 0 + fi + + # we may have things like "partup --debug install ..." + + if [[ ${command} == install ]] ; then + add_command_help ${command} ${current} ${previous} + + COMPREPLY+=( $(compgen -W "${install_options} ${app_options}" -- ${current}) ) + + # PACKAGE + COMPREPLY+=( $(compgen -f -o plusdirs -X '!*.partup' -- ${current}) ) + + # DEVICE -> if previous ends with partup, complete only from /dev + if [[ ${previous} == *.partup ]] ; then + if [[ -z ${current} ]] ; then + COMPREPLY=( '/dev' ) + return 0 + else + COMPREPLY+=( $(compgen -f -o plusdirs -- ${current} ) ) + fi + fi + + # don't allow options after dev + if [[ ${previous} == /dev/* ]] ; then + COMPREPLY=() + fi + + return 0 + fi + + if [[ ${command} == package ]] ; then + add_command_help ${command} ${current} ${previous} + + COMPREPLY+=( $(compgen -W "${package_options} ${app_options}" -- ${current}) ) + + # -C, --directory=DIR + # PACKAGE FILES… + + if exists_in_list "${package_options}" " " ${previous} ; then + #if output is previous, a file must follow + COMPREPLY=( $(compgen -f -- ${current}) ) + fi + + return 0 + fi + + if [[ ${command} == show ]] ; then + add_command_help ${command} ${current} ${previous} + + COMPREPLY+=( $(compgen -W "${show_options} ${app_options}" -- ${current}) ) + + # PACKAGE - if we do not already have one, complete available partup files + if [[ ${previous} != *.partup ]] ; then + COMPREPLY+=( $(compgen -f -o plusdirs -X '!*.partup' -- ${current}) ) + fi + + return 0 + fi + + if [[ ${command} == version ]] ; then + COMPREPLY=() + return 0 + fi + + return 1 +} + +complete -o filenames -F _partup_completions partup From 6a9d0bd29fc442754023531a232e1f4031b25ef7 Mon Sep 17 00:00:00 2001 From: Steffen Hemer Date: Sat, 22 Aug 2026 11:02:19 +0200 Subject: [PATCH 2/3] debian: Package bash-completion script Signed-off-by: Steffen Hemer --- debian/control | 3 ++- debian/partup.bash-completion | 1 + debian/rules | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 debian/partup.bash-completion diff --git a/debian/control b/debian/control index a6baf3fc..ad7cd751 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,8 @@ Build-Depends: libyaml-dev, libparted-dev, util-linux, - meson + meson, + bash-completion Standards-Version: 4.7.2 Homepage: https://github.com/phytec/partup Vcs-Git: https://github.com/phytec/partup.git diff --git a/debian/partup.bash-completion b/debian/partup.bash-completion new file mode 100644 index 00000000..c6b068de --- /dev/null +++ b/debian/partup.bash-completion @@ -0,0 +1 @@ +partup-completion.bash diff --git a/debian/rules b/debian/rules index 71a79be6..79d7d8c3 100755 --- a/debian/rules +++ b/debian/rules @@ -3,7 +3,7 @@ export DH_VERBOSE=1 %: - dh $@ + dh $@ --with bash-completion override_dh_auto_configure: rm -rf build From f2f1116ae472d13071a0fa5e2724b6614a1173c3 Mon Sep 17 00:00:00 2001 From: Steffen Hemer Date: Tue, 1 Sep 2026 10:41:34 +0200 Subject: [PATCH 3/3] gitignore: Add Debian package build artefacts When test-building the package locally, these otherwise float the untracked files. Signed-off-by: Steffen Hemer --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 2e33ca4e..dc765bfc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ /build/ env/ tags +debian/.debhelper/ +debian/partup/ +debian/files +debian/debhelper-build-stamp +debian/partup.debhelper.log +debian/partup.substvars