eclass/app-alternatives: Sync with Gentoo

It's from Gentoo commit c8af7eb1285a2683460618b71e2e9a14ca6badcd.
This commit is contained in:
Flatcar Buildbot 2024-10-21 07:06:04 +00:00
parent 1c7aee24b7
commit a4f6f68e47

View File

@ -1,4 +1,4 @@
# Copyright 2022 Gentoo Authors # Copyright 2022-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
# @ECLASS: app-alternatives.eclass # @ECLASS: app-alternatives.eclass
@ -21,7 +21,7 @@ case ${EAPI} in
*) die "${ECLASS}: EAPI ${EAPI:-0} unsupported." *) die "${ECLASS}: EAPI ${EAPI:-0} unsupported."
esac esac
if [[ ! ${_APP_ALTERNATIVES_ECLASS} ]]; then if [[ -z ${_APP_ALTERNATIVES_ECLASS} ]]; then
_APP_ALTERNATIVES_ECLASS=1 _APP_ALTERNATIVES_ECLASS=1
# @ECLASS_VARIABLE: ALTERNATIVES # @ECLASS_VARIABLE: ALTERNATIVES
@ -36,7 +36,7 @@ _APP_ALTERNATIVES_ECLASS=1
# @DESCRIPTION: # @DESCRIPTION:
# Set ebuild metadata variables. # Set ebuild metadata variables.
_app-alternatives_set_globals() { _app-alternatives_set_globals() {
debug-print-function ${FUNCNAME} "${@}" debug-print-function ${FUNCNAME} "$@"
if [[ ${ALTERNATIVES@a} != *a* ]]; then if [[ ${ALTERNATIVES@a} != *a* ]]; then
die 'ALTERNATIVES must be an array.' die 'ALTERNATIVES must be an array.'
@ -71,7 +71,7 @@ _app-alternatives_set_globals
# @DESCRIPTION: # @DESCRIPTION:
# Get the flag name for the selected alternative (i.e. the USE flag set). # Get the flag name for the selected alternative (i.e. the USE flag set).
get_alternative() { get_alternative() {
debug-print-function ${FUNCNAME} "${@}" debug-print-function ${FUNCNAME} "$@"
local flag local flag
for flag in "${ALTERNATIVES[@]%%:*}"; do for flag in "${ALTERNATIVES[@]%%:*}"; do