* [gentoo-dev] [PATCH v3] bash-completion-r1.eclass: Add EAPI 8 support
@ 2021-07-16 16:28 Michał Górny
2021-07-16 17:17 ` Ulrich Mueller
0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2021-07-16 16:28 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/bash-completion-r1.eclass | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/eclass/bash-completion-r1.eclass b/eclass/bash-completion-r1.eclass
index 80f2d5fcd32a..7451019931ad 100644
--- a/eclass/bash-completion-r1.eclass
+++ b/eclass/bash-completion-r1.eclass
@@ -1,138 +1,143 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: bash-completion-r1.eclass
# @MAINTAINER:
# mgorny@gentoo.org
-# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
+# @SUPPORTED_EAPIS: 5 6 7 8
# @BLURB: A few quick functions to install bash-completion files
# @EXAMPLE:
#
# @CODE
-# EAPI=5
+# EAPI=8
#
# src_configure() {
# econf \
# --with-bash-completion-dir="$(get_bashcompdir)"
# }
#
# src_install() {
# default
#
# newbashcomp contrib/${PN}.bash-completion ${PN}
# }
# @CODE
+if [[ ! ${_BASH_COMPLETION_R1_ECLASS} ]]; then
+
inherit toolchain-funcs
case ${EAPI:-0} in
- 0|1|2|3|4|5|6|7) ;;
- *) die "EAPI ${EAPI} unsupported (yet)."
+ 5|6|7|8) ;;
+ *) die "EAPI ${EAPI} unsupported."
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_helpersdir
# @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: <file> [...]
# @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: <file> <newname>
# @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: <basename> <alias>...
# @DESCRIPTION:
# Alias <basename> completion to one or more commands (<alias>es).
bashcomp_alias() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${#} -lt 2 ]] && die "Usage: ${FUNCNAME} <basename> <alias>..."
local base=${1} f
shift
for f; do
dosym "${base}" "$(_bash-completion-r1_get_bashcompdir)/${f}" \
|| return
done
}
+
+_BASH_COMPLETION_R1_ECLASS=1
+fi
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-dev] [PATCH v3] bash-completion-r1.eclass: Add EAPI 8 support
2021-07-16 16:28 [gentoo-dev] [PATCH v3] bash-completion-r1.eclass: Add EAPI 8 support Michał Górny
@ 2021-07-16 17:17 ` Ulrich Mueller
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Mueller @ 2021-07-16 17:17 UTC (permalink / raw
To: Michał Górny; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 758 bytes --]
>>>>> On Fri, 16 Jul 2021, Michał Górny wrote:
> case ${EAPI:-0} in
This could be simplified to ${EAPI}.
> - 0|1|2|3|4|5|6|7) ;;
> - *) die "EAPI ${EAPI} unsupported (yet)."
> + 5|6|7|8) ;;
> + *) die "EAPI ${EAPI} unsupported."
> esac
Add the eclass name to the message? Other eclasses have this:
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
Also, the ;; is missing in the last clause. If that it working, then at
least it is undocumented behaviour. The Bash manual explicitly says that
"[e]ach clause must be terminated".
> +
> +_BASH_COMPLETION_R1_ECLASS=1
> +fi
This assignment belongs immediately after the corresponding check,
before any inherits. Otherwise, it won't prevent inherit circles.
Ulrich
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-16 17:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-16 16:28 [gentoo-dev] [PATCH v3] bash-completion-r1.eclass: Add EAPI 8 support Michał Górny
2021-07-16 17:17 ` Ulrich Mueller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox