From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CD580138331 for ; Tue, 1 May 2018 16:26:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 017B1E09C9; Tue, 1 May 2018 16:26:03 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BD45DE09C9 for ; Tue, 1 May 2018 16:26:02 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A8AD9335C93 for ; Tue, 1 May 2018 16:26:01 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1A1A52A7 for ; Tue, 1 May 2018 16:26:00 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1525163324.43b6be7423aaebee26e4659d580a9a17b4fde01e.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/eapi.sh bin/phase-helpers.sh X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 43b6be7423aaebee26e4659d580a9a17b4fde01e X-VCS-Branch: master Date: Tue, 1 May 2018 16:26:00 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: c5f526eb-c88f-4286-92a0-bb84d1c7f19e X-Archives-Hash: fa2c7a4331f393dcc969d3bdddd78ff2 commit: 43b6be7423aaebee26e4659d580a9a17b4fde01e Author: James Le Cuirot gentoo org> AuthorDate: Tue Nov 7 23:14:40 2017 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue May 1 08:28:44 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=43b6be74 phase-helpers.sh: Implement -r|-d|-b options for best/has_version The code for these functions is practically identical so refactor them around a common function. bin/eapi.sh | 6 ++- bin/phase-helpers.sh | 146 ++++++++++++++++++++------------------------------- 2 files changed, 63 insertions(+), 89 deletions(-) diff --git a/bin/eapi.sh b/bin/eapi.sh index 3b6a5c1a9..455bc9b0d 100644 --- a/bin/eapi.sh +++ b/bin/eapi.sh @@ -155,7 +155,11 @@ ___eapi_has_package_manager_build_group() { # HELPERS BEHAVIOR ___eapi_best_version_and_has_version_support_--host-root() { - [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]] + [[ ${1-${EAPI-0}} =~ ^(5|5-progress|6)$ ]] +} + +___eapi_best_version_and_has_version_support_-b_-d_-r() { + [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-progress|6)$ ]] } ___eapi_unpack_supports_xz() { diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index f6c9ef6fc..59c19cf67 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -878,46 +878,55 @@ __eapi6_src_install() { einstalldocs } -# @FUNCTION: has_version -# @USAGE: [--host-root] -# @DESCRIPTION: -# Return true if given package is installed. Otherwise return false. -# Callers may override the ROOT variable in order to match packages from an -# alternative ROOT. -has_version() { - - local atom eroot host_root=false root=${ROOT} - if [[ $1 == --host-root ]] ; then - host_root=true - shift - fi +___best_version_and_has_version_common() { + local atom root root_arg + case $1 in + --host-root|-r|-d|-b) + root_arg=$1 + shift ;; + esac atom=$1 shift - [ $# -gt 0 ] && die "${FUNCNAME[0]}: unused argument(s): $*" + [ $# -gt 0 ] && die "${FUNCNAME[1]}: unused argument(s): $*" - if ${host_root} ; then - if ! ___eapi_best_version_and_has_version_support_--host-root; then - die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}" - fi - root=/ - fi + case ${root_arg} in + "") if ___eapi_has_prefix_variables; then + root=${EROOT} + else + root=${ROOT} + fi ;; + --host-root) + if ! ___eapi_best_version_and_has_version_support_--host-root; then + die "${FUNCNAME[1]}: option ${root_arg} is not supported with EAPI ${EAPI}" + fi + if ___eapi_has_prefix_variables; then + root=/${PORTAGE_OVERRIDE_EPREFIX#/} + else + root=/ + fi ;; + -r|-d|-b) + if ! ___eapi_best_version_and_has_version_support_-b_-d_-r; then + die "${FUNCNAME[1]}: option ${root_arg} is not supported with EAPI ${EAPI}" + fi + if ___eapi_has_prefix_variables; then + case ${root_arg} in + -r) root=${EROOT} ;; + -d) root=${ESYSROOT} ;; + -b) root=${BROOT:-/} ;; + esac + else + case ${root_arg} in + -r) root=${ROOT} ;; + -d) root=${SYSROOT} ;; + -b) root=/ ;; + esac + fi ;; + esac - if ___eapi_has_prefix_variables; then - # [[ ${root} == / ]] would be ambiguous here, - # since both prefixes can share root=/ while - # having different EPREFIX offsets. - if ${host_root} ; then - eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/ - else - eroot=${root%/}${EPREFIX}/ - fi - else - eroot=${root} - fi if [[ -n $PORTAGE_IPC_DAEMON ]] ; then - "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "${eroot}" "${atom}" + "${PORTAGE_BIN_PATH}"/ebuild-ipc "${FUNCNAME[1]}" "${root}" "${atom}" else - "${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" has_version "${eroot}" "${atom}" + "${PORTAGE_BIN_PATH}"/ebuild-helpers/portageq "${FUNCNAME[1]}" "${root}" "${atom}" fi local retval=$? case "${retval}" in @@ -925,75 +934,36 @@ has_version() { return ${retval} ;; 2) - die "${FUNCNAME[0]}: invalid atom: ${atom}" + die "${FUNCNAME[1]}: invalid atom: ${atom}" ;; *) if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then - die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}" + die "${FUNCNAME[1]}: unexpected ebuild-ipc exit code: ${retval}" else - die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}" + die "${FUNCNAME[1]}: unexpected portageq exit code: ${retval}" fi ;; esac } +# @FUNCTION: has_version +# @USAGE: [--host-root|-r|-d|-b] +# @DESCRIPTION: +# Return true if given package is installed. Otherwise return false. +# Callers may override the ROOT variable in order to match packages from an +# alternative ROOT. +has_version() { + ___best_version_and_has_version_common "$@" +} + # @FUNCTION: best_version -# @USAGE: [--host-root] +# @USAGE: [--host-root|-r|-d|-b] # @DESCRIPTION: # Returns highest installed matching category/package-version (without .ebuild). # Callers may override the ROOT variable in order to match packages from an # alternative ROOT. best_version() { - - local atom eroot host_root=false root=${ROOT} - if [[ $1 == --host-root ]] ; then - host_root=true - shift - fi - atom=$1 - shift - [ $# -gt 0 ] && die "${FUNCNAME[0]}: unused argument(s): $*" - - if ${host_root} ; then - if ! ___eapi_best_version_and_has_version_support_--host-root; then - die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}" - fi - root=/ - fi - - if ___eapi_has_prefix_variables; then - # [[ ${root} == / ]] would be ambiguous here, - # since both prefixes can share root=/ while - # having different EPREFIX offsets. - if ${host_root} ; then - eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/ - else - eroot=${root%/}${EPREFIX}/ - fi - else - eroot=${root} - fi - if [[ -n $PORTAGE_IPC_DAEMON ]] ; then - "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "${eroot}" "${atom}" - else - "${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" best_version "${eroot}" "${atom}" - fi - local retval=$? - case "${retval}" in - 0|1) - return ${retval} - ;; - 2) - die "${FUNCNAME[0]}: invalid atom: ${atom}" - ;; - *) - if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then - die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}" - else - die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}" - fi - ;; - esac + ___best_version_and_has_version_common "$@" } if ___eapi_has_get_libdir; then