multilib-build.eclass: update to upstream Remove EAPI check to be compatible with ChromeOS BUG=b/425627696 TEST=presubmit RELEASE_NOTE=None cos-patch: security-high Change-Id: I1b3e7324a894bffea86d0740321c7f1efd09ed06 Reviewed-on: https://cos-review.googlesource.com/c/third_party/overlays/eclass-overlay/+/107861 Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com> Reviewed-by: He Gao <hegao@google.com>
diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass index 3df63aa..d4ee029 100644 --- a/eclass/multilib-build.eclass +++ b/eclass/multilib-build.eclass
@@ -1,12 +1,12 @@ -# Copyright 1999-2018 Gentoo Foundation +# Copyright 2013-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: multilib-build.eclass # @MAINTAINER: -# gx86-multilib team <multilib@gentoo.org> +# Michał Górny <mgorny@gentoo.org> # @AUTHOR: # Author: Michał Górny <mgorny@gentoo.org> -# @SUPPORTED_EAPIS: 4 5 6 7 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: flags and utility functions for building multilib packages # @DESCRIPTION: # The multilib-build.eclass exports USE flags and utility functions @@ -17,18 +17,12 @@ # dependencies shall use the USE dependency string in ${MULTILIB_USEDEP} # to properly request multilib enabled. -if [[ ! ${_MULTILIB_BUILD} ]]; then +if [[ -z ${_MULTILIB_BUILD_ECLASS} ]]; then +_MULTILIB_BUILD_ECLASS=1 -# EAPI=4 is required for meaningful MULTILIB_USEDEP. -case ${EAPI:-0} in - 4|5|6|7) ;; - *) die "EAPI=${EAPI} is not supported" ;; -esac - -[[ ${EAPI} == [45] ]] && inherit eutils inherit multibuild multilib -# @ECLASS-VARIABLE: _MULTILIB_FLAGS +# @ECLASS_VARIABLE: _MULTILIB_FLAGS # @INTERNAL # @DESCRIPTION: # The list of multilib flags and corresponding ABI values. If the same @@ -45,8 +39,8 @@ abi_mips_n32:n32 abi_mips_n64:n64 abi_mips_o32:o32 - abi_ppc_32:ppc,ppc_aix,ppc_macos - abi_ppc_64:ppc64 +# abi_ppc_32:ppc,ppc_aix,ppc_macos +# abi_ppc_64:ppc64 abi_s390_32:s390 abi_s390_64:s390x abi_arm_32:arm @@ -54,7 +48,7 @@ ) readonly _MULTILIB_FLAGS -# @ECLASS-VARIABLE: MULTILIB_COMPAT +# @ECLASS_VARIABLE: MULTILIB_COMPAT # @DEFAULT_UNSET # @DESCRIPTION: # List of multilib ABIs supported by the ebuild. If unset, defaults to @@ -78,7 +72,8 @@ # MULTILIB_COMPAT=( abi_x86_{32,64} ) # @CODE -# @ECLASS-VARIABLE: MULTILIB_USEDEP +# @ECLASS_VARIABLE: MULTILIB_USEDEP +# @OUTPUT_VARIABLE # @DESCRIPTION: # The USE-dependency to be used on dependencies (libraries) needing # to support multilib as well. @@ -89,8 +84,8 @@ # net-libs/libbar[ssl,${MULTILIB_USEDEP}]" # @CODE -# @ECLASS-VARIABLE: MULTILIB_ABI_FLAG -# @DEFAULT_UNSET +# @ECLASS_VARIABLE: MULTILIB_ABI_FLAG +# @OUTPUT_VARIABLE # @DESCRIPTION: # The complete ABI name. Resembles the USE flag name. # @@ -141,7 +136,7 @@ # If multilib is disabled, the default ABI will be returned # in order to enforce consistent testing with multilib code. multilib_get_enabled_abis() { - debug-print-function ${FUNCNAME} "${@}" + debug-print-function ${FUNCNAME} "$@" local pairs=( $(multilib_get_enabled_abi_pairs) ) echo "${pairs[@]#*.}" @@ -156,7 +151,7 @@ # If multilib is disabled, the default ABI will be returned # along with empty <use-flag>. multilib_get_enabled_abi_pairs() { - debug-print-function ${FUNCNAME} "${@}" + debug-print-function ${FUNCNAME} "$@" local abis=( $(get_all_abis) ) @@ -199,7 +194,7 @@ # @DESCRIPTION: # Initialize the environment for ABI selected for multibuild. _multilib_multibuild_wrapper() { - debug-print-function ${FUNCNAME} "${@}" + debug-print-function ${FUNCNAME} "$@" local ABI=${MULTIBUILD_VARIANT#*.} local -r MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*} @@ -219,7 +214,7 @@ # If multilib support is disabled, it just runs the commands. No setup # is done. multilib_foreach_abi() { - debug-print-function ${FUNCNAME} "${@}" + debug-print-function ${FUNCNAME} "$@" local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) multibuild_foreach_variant _multilib_multibuild_wrapper "${@}" @@ -238,29 +233,12 @@ # This function used to run multiple commands in parallel. Now it's just # a deprecated alias to multilib_foreach_abi. multilib_parallel_foreach_abi() { - debug-print-function ${FUNCNAME} "${@}" + debug-print-function ${FUNCNAME} "$@" local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) multibuild_foreach_variant _multilib_multibuild_wrapper "${@}" } -# @FUNCTION: multilib_for_best_abi -# @USAGE: <argv>... -# @DESCRIPTION: -# Runs the given command with setup for the 'best' (usually native) ABI. -multilib_for_best_abi() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead" - - eqawarn "QA warning: multilib_for_best_abi() function is deprecated and should" - eqawarn "not be used. The multilib_is_native_abi() check may be used instead." - - local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) - - multibuild_for_best_variant _multilib_multibuild_wrapper "${@}" -} - # @FUNCTION: multilib_check_headers # @DESCRIPTION: # Check whether the header files are consistent between ABIs. @@ -272,8 +250,8 @@ _multilib_header_cksum() { set -o pipefail - if [[ -d ${ED%/}/usr/include ]]; then - find "${ED%/}"/usr/include -type f \ + if [[ -d ${ED}/usr/include ]]; then + find "${ED}"/usr/include -type f \ -exec cksum {} + | sort -k2 fi } @@ -313,13 +291,14 @@ # to ABI-specific build directory matching BUILD_DIR used by # multilib_foreach_abi(). multilib_copy_sources() { - debug-print-function ${FUNCNAME} "${@}" + debug-print-function ${FUNCNAME} "$@" local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) multibuild_copy_sources } -# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS +# @ECLASS_VARIABLE: MULTILIB_WRAPPED_HEADERS +# @DEFAULT_UNSET # @DESCRIPTION: # A list of headers to wrap for multilib support. The listed headers # will be moved to a non-standard location and replaced with a file @@ -341,7 +320,8 @@ # ) # @CODE -# @ECLASS-VARIABLE: MULTILIB_CHOST_TOOLS +# @ECLASS_VARIABLE: MULTILIB_CHOST_TOOLS +# @DEFAULT_UNSET # @DESCRIPTION: # A list of tool executables to preserve for each multilib ABI. # The listed executables will be renamed to ${CHOST}-${basename}, @@ -369,8 +349,8 @@ # MULTILIB_CHOST_TOOLS=( # /usr/bin/foo-config # ) - # @CODE + # @FUNCTION: multilib_prepare_wrappers # @USAGE: [<install-root>] # @DESCRIPTION: @@ -389,11 +369,11 @@ # After all wrappers are prepared, multilib_install_wrappers shall # be called to commit them to the installation tree. multilib_prepare_wrappers() { - debug-print-function ${FUNCNAME} "${@}" + debug-print-function ${FUNCNAME} "$@" [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" - local root=${1:-${ED%/}} + local root=${1:-${ED}} local f if [[ ${COMPLETE_MULTILIB} == yes ]]; then @@ -461,9 +441,9 @@ # Some ABIs may have install less files than others. if [[ -f ${root}/usr/include${f} ]]; then - local wrapper=${ED%/}/tmp/multilib-include${f} + local wrapper=${ED}/tmp/multilib-include${f} - if [[ ! -f ${ED%/}/tmp/multilib-include${f} ]]; then + if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then dodir "/tmp/multilib-include${dir}" # a generic template cat > "${wrapper}" <<_EOF_ || die @@ -481,30 +461,30 @@ #elif defined(__i386__) /* plain x86 */ # error "abi_x86_32 not supported by the package." #elif defined(__mips__) -# if(_MIPS_SIM == _ABIN32) /* n32 */ -# error "abi_mips_n32 not supported by the package." -# elif(_MIPS_SIM == _ABI64) /* n64 */ -# error "abi_mips_n64 not supported by the package." -# elif(_MIPS_SIM == _ABIO32) /* o32 */ -# error "abi_mips_o32 not supported by the package." -# endif +# if(_MIPS_SIM == _ABIN32) /* n32 */ +# error "abi_mips_n32 not supported by the package." +# elif(_MIPS_SIM == _ABI64) /* n64 */ +# error "abi_mips_n64 not supported by the package." +# elif(_MIPS_SIM == _ABIO32) /* o32 */ +# error "abi_mips_o32 not supported by the package." +# endif #elif defined(__sparc__) # if defined(__arch64__) -# error "abi_sparc_64 not supported by the package." +# error "abi_sparc_64 not supported by the package." # else -# error "abi_sparc_32 not supported by the package." +# error "abi_sparc_32 not supported by the package." # endif #elif defined(__s390__) # if defined(__s390x__) -# error "abi_s390_64 not supported by the package." +# error "abi_s390_64 not supported by the package." # else -# error "abi_s390_32 not supported by the package." +# error "abi_s390_32 not supported by the package." # endif #elif defined(__powerpc__) || defined(__ppc__) # if defined(__powerpc64__) || defined(__ppc64__) -# error "abi_ppc_64 not supported by the package." +# error "abi_ppc_64 not supported by the package." # else -# error "abi_ppc_32 not supported by the package." +# error "abi_ppc_32 not supported by the package." # endif #elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */ # error "Native ABI not supported by the package." @@ -521,7 +501,7 @@ # $CHOST shall be set by multilib_toolchain_setup dodir "/tmp/multilib-include/${CHOST}${dir}" - mv "${root}/usr/include${f}" "${ED%/}/tmp/multilib-include/${CHOST}${dir}/" || die + mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die # Note: match a space afterwards to avoid collision potential. sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" \ @@ -553,7 +533,7 @@ # between the calls to multilib_prepare_wrappers # and multilib_install_wrappers. multilib_install_wrappers() { - debug-print-function ${FUNCNAME} "${@}" + debug-print-function ${FUNCNAME} "$@" [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" @@ -561,11 +541,11 @@ local root=${1:-${ED}} - if [[ -d ${ED%/}/tmp/multilib-include ]]; then + if [[ -d ${ED}/tmp/multilib-include ]]; then multibuild_merge_root \ - "${ED%/}"/tmp/multilib-include "${root}"/usr/include + "${ED}"/tmp/multilib-include "${root}"/usr/include # it can fail if something else uses /tmp - rmdir "${ED%/}"/tmp &>/dev/null + rmdir "${ED}"/tmp &>/dev/null fi } @@ -574,25 +554,29 @@ # Determine whether the currently built ABI is the profile native. # Return true status (0) if that is true, otherwise false (1). multilib_is_native_abi() { - debug-print-function ${FUNCNAME} "${@}" + debug-print-function ${FUNCNAME} "$@" [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments" [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]] } -# @FUNCTION: multilib_build_binaries +# @FUNCTION: multilib_native_use +# @USAGE: <flag> # @DESCRIPTION: -# Deprecated synonym for multilib_is_native_abi -multilib_build_binaries() { - debug-print-function ${FUNCNAME} "${@}" +# Like the standard use command, but only yields true if +# multilib_is_native_abi and use <flag> are true, otherwise false. +multilib_native_use() { + multilib_is_native_abi && use "$@" +} - [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead" - - eqawarn "QA warning: multilib_build_binaries is deprecated. Please use the equivalent" - eqawarn "multilib_is_native_abi function instead." - - multilib_is_native_abi "${@}" +# @FUNCTION: multilib_native_usev +# @USAGE: <flag> [<opt-value>] +# @DESCRIPTION: +# Like the standard usev command, but only prints output +# if multilib_is_native_abi and usev <flag> are true. +multilib_native_usev() { + multilib_is_native_abi && usev "$@" } # @FUNCTION: multilib_native_use_with @@ -662,7 +646,6 @@ # of <false1> (or 'no' if unspecified) and <false2>. Arguments # are the same as for usex in the EAPI. # -# Note: in EAPI 4 you need to inherit eutils to use this function. multilib_native_usex() { if multilib_is_native_abi; then usex "${@}" @@ -671,5 +654,4 @@ fi } -_MULTILIB_BUILD=1 fi