From 016b49f445387ad70d5864cbebc333b0cac07ee0 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 22 Jun 2026 19:34:40 +0200 Subject: [PATCH 1/6] shell-completion.eclass: include functions of bash-completion-r1.eclass Include the functions of bash-completion-r1.eclass instead of inheriting bash-completion-r1.eclass. The idea is to phase out bash-completion-r1.eclass in favor of shell-completion.eclass with EAPI 9. Signed-off-by: Florian Schmaus Part-of: https://github.com/gentoo/gentoo/pull/46458 --- eclass/shell-completion.eclass | 114 +++++++++++++++++++++++++++++++-- 1 file changed, 110 insertions(+), 4 deletions(-) diff --git a/eclass/shell-completion.eclass b/eclass/shell-completion.eclass index caccdee7b19bb..225db4123f166 100644 --- a/eclass/shell-completion.eclass +++ b/eclass/shell-completion.eclass @@ -1,14 +1,14 @@ -# Copyright 2023-2024 Gentoo Authors +# Copyright 2023-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: shell-completion.eclass # @MAINTAINER: # Jonas Frei # Florian Schmaus +# mgorny@gentoo.org # @AUTHOR: # Alfred Wingate # @SUPPORTED_EAPIS: 8 -# @PROVIDES: bash-completion-r1 # @BLURB: a few quick functions to install various shell completion files # @DESCRIPTION: # This eclass provides a standardised way to install shell completions @@ -23,8 +23,114 @@ esac if [[ -z ${_SHELL_COMPLETION_ECLASS} ]]; then _SHELL_COMPLETION_ECLASS=1 -# Extend bash-completion-r1 -inherit bash-completion-r1 +inherit toolchain-funcs + +# @FUNCTION: _bash-completion-r1_get_bashdir +# @INTERNAL +# @DESCRIPTION: +# First argument is name of the string in bash-completion.pc +# Second argument is the fallback directory if the string is not found +# @EXAMPLE: +# _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion +_bash-completion-r1_get_bashdir() { + debug-print-function ${FUNCNAME} "$@" + + if $(tc-getPKG_CONFIG) --exists bash-completion &>/dev/null; then + local path + path=$($(tc-getPKG_CONFIG) --variable="${1}" bash-completion) || die + # we need to return unprefixed, so strip from what pkg-config returns + # to us, bug #477692 + echo "${path#"${EPREFIX}"}" + else + echo "${2}" + fi +} + +# @FUNCTION: _bash-completion-r1_get_bashcompdir +# @INTERNAL +# @DESCRIPTION: +# Get unprefixed bash-completion completions directory. +_bash-completion-r1_get_bashcompdir() { + debug-print-function ${FUNCNAME} "$@" + + _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions +} + +# @FUNCTION: _bash-completion-r1_get_bashhelpersdir +# @INTERNAL +# @DESCRIPTION: +# Get unprefixed bash-completion helpers directory. +_bash-completion-r1_get_bashhelpersdir() { + debug-print-function ${FUNCNAME} "$@" + + _bash-completion-r1_get_bashdir helpersdir /usr/share/bash-completion/helpers +} + +# @FUNCTION: get_bashcompdir +# @DESCRIPTION: +# Get the bash-completion completions directory. +get_bashcompdir() { + debug-print-function ${FUNCNAME} "$@" + + echo "${EPREFIX}$(_bash-completion-r1_get_bashcompdir)" +} + +# @FUNCTION: get_bashhelpersdir +# @INTERNAL +# @DESCRIPTION: +# Get the bash-completion helpers directory. +get_bashhelpersdir() { + debug-print-function ${FUNCNAME} "$@" + + echo "${EPREFIX}$(_bash-completion-r1_get_bashhelpersdir)" +} + +# @FUNCTION: dobashcomp +# @USAGE: [...] +# @DESCRIPTION: +# Install bash-completion files passed as args. Has EAPI-dependent failure +# behavior (like doins). +dobashcomp() { + debug-print-function ${FUNCNAME} "$@" + + ( + insopts -m 0644 + insinto "$(_bash-completion-r1_get_bashcompdir)" + doins "${@}" + ) +} + +# @FUNCTION: newbashcomp +# @USAGE: +# @DESCRIPTION: +# Install bash-completion file under a new name. Has EAPI-dependent failure +# behavior (like newins). +newbashcomp() { + debug-print-function ${FUNCNAME} "$@" + + ( + insopts -m 0644 + insinto "$(_bash-completion-r1_get_bashcompdir)" + newins "${@}" + ) +} + +# @FUNCTION: bashcomp_alias +# @USAGE: ... +# @DESCRIPTION: +# Alias completion to one or more commands (es). +bashcomp_alias() { + debug-print-function ${FUNCNAME} "$@" + + [[ ${#} -lt 2 ]] && die "Usage: ${FUNCNAME} ..." + local base=${1} f + shift + + for f; do + dosym "${base}" "$(_bash-completion-r1_get_bashcompdir)/${f}" \ + || return + done +} # @FUNCTION: _shell-completion_get_fishcompdir # @INTERNAL From c57a5e02c2e2688223281cac5c41b2c3e5b72f28 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 22 Jun 2026 19:35:28 +0200 Subject: [PATCH 2/6] shell-completion.eclass: support EAPI 9 Signed-off-by: Florian Schmaus Part-of: https://github.com/gentoo/gentoo/pull/46458 --- eclass/shell-completion.eclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eclass/shell-completion.eclass b/eclass/shell-completion.eclass index 225db4123f166..5390f317cad37 100644 --- a/eclass/shell-completion.eclass +++ b/eclass/shell-completion.eclass @@ -8,7 +8,7 @@ # mgorny@gentoo.org # @AUTHOR: # Alfred Wingate -# @SUPPORTED_EAPIS: 8 +# @SUPPORTED_EAPIS: 8 9 # @BLURB: a few quick functions to install various shell completion files # @DESCRIPTION: # This eclass provides a standardised way to install shell completions @@ -16,7 +16,7 @@ # 'bash-completion-r1', thus extending on its functionality. case ${EAPI} in - 8) ;; + 8|9) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" esac From 9fd28d02a9077178b3cec54c367934db0dc06966 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 22 Jun 2026 19:36:49 +0200 Subject: [PATCH 3/6] bash-completion-r1.eclass: add notice about EAPI 9 Signed-off-by: Florian Schmaus Part-of: https://github.com/gentoo/gentoo/pull/46458 --- eclass/bash-completion-r1.eclass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eclass/bash-completion-r1.eclass b/eclass/bash-completion-r1.eclass index 9fffbbe4bb6f3..580f7f85911fd 100644 --- a/eclass/bash-completion-r1.eclass +++ b/eclass/bash-completion-r1.eclass @@ -6,6 +6,9 @@ # mgorny@gentoo.org # @SUPPORTED_EAPIS: 7 8 # @BLURB: A few quick functions to install bash-completion files +# @DESCRIPTION: +# This eclass provides functions to install bash-completion files. +# For EAPI 9 or newer, use shell-completion.eclass instead. # @EXAMPLE: # # @CODE From 3973afc510e697a8c079cd827ad61ebfda544bf9 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 22 Jun 2026 21:11:24 +0200 Subject: [PATCH 4/6] shell-completion.eclass: support EAPI 7 The shell-completion.eclass will soon be inherited by bash-completion-r1.eclass, which supports EAPI 7. In preperation for this, mark shell-completion.eclass to also support EAPI 7. Signed-off-by: Florian Schmaus Part-of: https://github.com/gentoo/gentoo/pull/46458 --- eclass/shell-completion.eclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eclass/shell-completion.eclass b/eclass/shell-completion.eclass index 5390f317cad37..acbc850ced2ab 100644 --- a/eclass/shell-completion.eclass +++ b/eclass/shell-completion.eclass @@ -8,7 +8,7 @@ # mgorny@gentoo.org # @AUTHOR: # Alfred Wingate -# @SUPPORTED_EAPIS: 8 9 +# @SUPPORTED_EAPIS: 7 8 9 # @BLURB: a few quick functions to install various shell completion files # @DESCRIPTION: # This eclass provides a standardised way to install shell completions @@ -16,7 +16,7 @@ # 'bash-completion-r1', thus extending on its functionality. case ${EAPI} in - 8|9) ;; + 7|8|9) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" esac From 4b99041553d6fa2ce69b3ab736d145b4d76eeed9 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 22 Jun 2026 21:12:52 +0200 Subject: [PATCH 5/6] bash-completion-r1.eclass: inherit shell-completion To avoid duplicated code, replace the body of bash-completion-r1.eclass wit inherit shell-completion since everything is now in shell-completion.elcass. Signed-off-by: Florian Schmaus Part-of: https://github.com/gentoo/gentoo/pull/46458 --- eclass/bash-completion-r1.eclass | 115 +------------------------------ 1 file changed, 2 insertions(+), 113 deletions(-) diff --git a/eclass/bash-completion-r1.eclass b/eclass/bash-completion-r1.eclass index 580f7f85911fd..02425859d7128 100644 --- a/eclass/bash-completion-r1.eclass +++ b/eclass/bash-completion-r1.eclass @@ -5,6 +5,7 @@ # @MAINTAINER: # mgorny@gentoo.org # @SUPPORTED_EAPIS: 7 8 +# @PROVIDES: shell-completion # @BLURB: A few quick functions to install bash-completion files # @DESCRIPTION: # This eclass provides functions to install bash-completion files. @@ -29,118 +30,6 @@ if [[ -z ${_BASH_COMPLETION_R1_ECLASS} ]]; then _BASH_COMPLETION_R1_ECLASS=1 -inherit toolchain-funcs - -case ${EAPI} in - 7|8) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - -# @FUNCTION: _bash-completion-r1_get_bashdir -# @INTERNAL -# @DESCRIPTION: -# First argument is name of the string in bash-completion.pc -# Second argument is the fallback directory if the string is not found -# @EXAMPLE: -# _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion -_bash-completion-r1_get_bashdir() { - debug-print-function ${FUNCNAME} "$@" - - if $(tc-getPKG_CONFIG) --exists bash-completion &>/dev/null; then - local path - path=$($(tc-getPKG_CONFIG) --variable="${1}" bash-completion) || die - # we need to return unprefixed, so strip from what pkg-config returns - # to us, bug #477692 - echo "${path#"${EPREFIX}"}" - else - echo "${2}" - fi -} - -# @FUNCTION: _bash-completion-r1_get_bashcompdir -# @INTERNAL -# @DESCRIPTION: -# Get unprefixed bash-completion completions directory. -_bash-completion-r1_get_bashcompdir() { - debug-print-function ${FUNCNAME} "$@" - - _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions -} - -# @FUNCTION: _bash-completion-r1_get_bashhelpersdir -# @INTERNAL -# @DESCRIPTION: -# Get unprefixed bash-completion helpers directory. -_bash-completion-r1_get_bashhelpersdir() { - debug-print-function ${FUNCNAME} "$@" - - _bash-completion-r1_get_bashdir helpersdir /usr/share/bash-completion/helpers -} - -# @FUNCTION: get_bashcompdir -# @DESCRIPTION: -# Get the bash-completion completions directory. -get_bashcompdir() { - debug-print-function ${FUNCNAME} "$@" - - echo "${EPREFIX}$(_bash-completion-r1_get_bashcompdir)" -} - -# @FUNCTION: get_bashhelpersdir -# @INTERNAL -# @DESCRIPTION: -# Get the bash-completion helpers directory. -get_bashhelpersdir() { - debug-print-function ${FUNCNAME} "$@" - - echo "${EPREFIX}$(_bash-completion-r1_get_bashhelpersdir)" -} - -# @FUNCTION: dobashcomp -# @USAGE: [...] -# @DESCRIPTION: -# Install bash-completion files passed as args. Has EAPI-dependent failure -# behavior (like doins). -dobashcomp() { - debug-print-function ${FUNCNAME} "$@" - - ( - insopts -m 0644 - insinto "$(_bash-completion-r1_get_bashcompdir)" - doins "${@}" - ) -} - -# @FUNCTION: newbashcomp -# @USAGE: -# @DESCRIPTION: -# Install bash-completion file under a new name. Has EAPI-dependent failure -# behavior (like newins). -newbashcomp() { - debug-print-function ${FUNCNAME} "$@" - - ( - insopts -m 0644 - insinto "$(_bash-completion-r1_get_bashcompdir)" - newins "${@}" - ) -} - -# @FUNCTION: bashcomp_alias -# @USAGE: ... -# @DESCRIPTION: -# Alias completion to one or more commands (es). -bashcomp_alias() { - debug-print-function ${FUNCNAME} "$@" - - [[ ${#} -lt 2 ]] && die "Usage: ${FUNCNAME} ..." - local base=${1} f - shift - - for f; do - dosym "${base}" "$(_bash-completion-r1_get_bashcompdir)/${f}" \ - || return - done -} +inherit shell-completion fi From de37656f8b551173f98d4394a198b78700338944 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 23 Jun 2026 14:44:48 +0200 Subject: [PATCH 6/6] shell-completion.eclass: obtain bashcompdir via pkg-config only if EAPI < 9 Adjust _bash_completion-r1_get_bashdir() to not respect pkg-config files to obtain the completion directory in EAPI 9 to avoid inconsitent installations. Signed-off-by: Florian Schmaus Part-of: https://github.com/gentoo/gentoo/pull/46458 Closes: https://github.com/gentoo/gentoo/pull/46458 --- eclass/shell-completion.eclass | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/eclass/shell-completion.eclass b/eclass/shell-completion.eclass index acbc850ced2ab..f1281f6d2a4cf 100644 --- a/eclass/shell-completion.eclass +++ b/eclass/shell-completion.eclass @@ -23,27 +23,31 @@ esac if [[ -z ${_SHELL_COMPLETION_ECLASS} ]]; then _SHELL_COMPLETION_ECLASS=1 +if [[ ${EAPI} != 9 ]]; then inherit toolchain-funcs +fi # @FUNCTION: _bash-completion-r1_get_bashdir # @INTERNAL # @DESCRIPTION: # First argument is name of the string in bash-completion.pc # Second argument is the fallback directory if the string is not found +# Note that the first argument is only used on EAPI < 9. # @EXAMPLE: # _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion _bash-completion-r1_get_bashdir() { debug-print-function ${FUNCNAME} "$@" - if $(tc-getPKG_CONFIG) --exists bash-completion &>/dev/null; then + if [[ ${EAPI} != 9 ]] && $(tc-getPKG_CONFIG) --exists bash-completion &>/dev/null; then local path path=$($(tc-getPKG_CONFIG) --variable="${1}" bash-completion) || die # we need to return unprefixed, so strip from what pkg-config returns # to us, bug #477692 echo "${path#"${EPREFIX}"}" - else - echo "${2}" + return fi + + echo "${2}" } # @FUNCTION: _bash-completion-r1_get_bashcompdir