From 2fd57282f0262ca084e05b0f2c63fbada395d02b Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 16 Jan 2022 20:27:28 +0000 Subject: gentoo resync : 16.01.2021 --- eclass/multibuild.eclass | 91 ++++++++---------------------------------------- 1 file changed, 15 insertions(+), 76 deletions(-) (limited to 'eclass/multibuild.eclass') diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass index 37568ebf87cc..a0941ae02ea4 100644 --- a/eclass/multibuild.eclass +++ b/eclass/multibuild.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: multibuild.eclass @@ -6,25 +6,20 @@ # Michał Górny # @AUTHOR: # Author: Michał Górny -# @SUPPORTED_EAPIS: 4 5 6 7 8 +# @SUPPORTED_EAPIS: 6 7 8 # @BLURB: A generic eclass for building multiple variants of packages. # @DESCRIPTION: # The multibuild eclass aims to provide a generic framework for building # multiple 'variants' of a package (e.g. multilib, Python # implementations). -case "${EAPI:-0}" in - [0-3]) - die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" - ;; - [4-8]) - ;; - *) - die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" - ;; +case ${EAPI} in + 6|7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ ! ${_MULTIBUILD} ]]; then +if [[ ! ${_MULTIBUILD_ECLASS} ]]; then +_MULTIBUILD_ECLASS=1 # @ECLASS-VARIABLE: MULTIBUILD_VARIANTS # @REQUIRED @@ -137,25 +132,6 @@ multibuild_foreach_variant() { return ${ret} } -# @FUNCTION: multibuild_parallel_foreach_variant -# @USAGE: [...] -# @DESCRIPTION: -# Run the passed command repeatedly for each of the enabled package -# variants. This used to run the commands in parallel but now it's -# just a deprecated alias to multibuild_foreach_variant. -# -# The function returns 0 if all commands return 0, or the first non-zero -# exit status otherwise. However, it performs all the invocations -# nevertheless. It is preferred to call 'die' inside of the passed -# function. -multibuild_parallel_foreach_variant() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}" - - multibuild_foreach_variant "${@}" -} - # @FUNCTION: multibuild_for_best_variant # @USAGE: [...] # @DESCRIPTION: @@ -172,10 +148,7 @@ multibuild_for_best_variant() { [[ ${MULTIBUILD_VARIANTS} ]] \ || die "MULTIBUILD_VARIANTS need to be set" - # bash-4.1 can't handle negative subscripts - local MULTIBUILD_VARIANTS=( - "${MULTIBUILD_VARIANTS[$(( ${#MULTIBUILD_VARIANTS[@]} - 1 ))]}" - ) + local MULTIBUILD_VARIANTS=( "${MULTIBUILD_VARIANTS[-1]}" ) multibuild_foreach_variant "${@}" } @@ -192,15 +165,10 @@ multibuild_copy_sources() { einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}" - local cp_args=() - if cp --reflink=auto --version &>/dev/null; then - # enable reflinking if possible to make this faster - cp_args+=( --reflink=auto ) - fi - _multibuild_create_source_copy() { einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}" - cp -p -R "${cp_args[@]}" \ + # enable reflinking if possible to make this faster + cp -p -R --reflink=auto \ "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die } @@ -234,43 +202,14 @@ run_in_build_dir() { # (the real root). Both directories have to be real, absolute paths # (i.e. including ${D}). Source root will be removed. multibuild_merge_root() { + debug-print-function ${FUNCNAME} "${@}" + local src=${1} local dest=${2} - local ret - - if use userland_BSD; then - # Most of BSD variants fail to copy broken symlinks, #447370 - # also, they do not support --version - - tar -C "${src}" -f - -c . \ - | tar -x -f - -C "${dest}" - [[ ${PIPESTATUS[*]} == '0 0' ]] - ret=${?} - else - local cp_args=() - - if cp -a --version &>/dev/null; then - cp_args+=( -a ) - else - cp_args+=( -P -R -p ) - fi - - if cp --reflink=auto --version &>/dev/null; then - # enable reflinking if possible to make this faster - cp_args+=( --reflink=auto ) - fi - - cp "${cp_args[@]}" "${src}"/. "${dest}"/ - ret=${?} - fi - - if [[ ${ret} -ne 0 ]]; then - die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed." - fi - - rm -rf "${src}" + # enable reflinking if possible to make this faster + cp -a --reflink=auto "${src}"/. "${dest}"/ || die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed" + rm -rf "${src}" || die } -_MULTIBUILD=1 fi -- cgit v1.2.3