commit:     5d7567783a27dd52fa8dff1096f4d9a6b077b191
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Mon Jun  9 08:18:04 2025 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Aug 17 19:00:37 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5d756778

EAPI 9 has ver_replacing

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 bin/eapi.sh              |  1 +
 bin/save-ebuild-env.sh   |  1 +
 bin/version-functions.sh | 21 ++++++++++++++++++++-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 8e51a8ac54..97eb19d036 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -45,6 +45,7 @@ ___eapi_has_nonfatal()           [[ ${1-${EAPI-0}} != [0-3] ]]
 ___eapi_has_pipestatus()         [[ ${1-${EAPI-0}} != [0-8] ]]
 ___eapi_has_useq()               [[ ${1-${EAPI-0}} == [0-7] ]]
 ___eapi_has_usex()               [[ ${1-${EAPI-0}} != [0-4] ]]
+___eapi_has_ver_replacing()      [[ ${1-${EAPI-0}} != [0-8] ]]
 ___eapi_has_version_functions()  [[ ${1-${EAPI-0}} != [0-6] ]]
 
 # HELPERS BEHAVIOR

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 01bdcdd994..1cddf6370a 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -130,6 +130,7 @@ __save_ebuild_env() (
        ___eapi_has_eapply && REPLY+=( __eapply_patch eapply patch )
        ___eapi_has_usex && REPLY+=( usex )
        ___eapi_has_pipestatus && REPLY+=( pipestatus )
+       ___eapi_has_ver_replacing && REPLY+=( ver_replacing )
 
        # Destroy the collected functions.
        unset -f "${REPLY[@]}"

diff --git a/bin/version-functions.sh b/bin/version-functions.sh
index f07b03192c..11f0ffe0e5 100644
--- a/bin/version-functions.sh
+++ b/bin/version-functions.sh
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 # shellcheck disable=SC2128
 
@@ -190,3 +190,22 @@ ver_test() {
        __ver_compare "${va}" "${vb}"
        test $? "${op}" 2
 }
+
+if ___eapi_has_ver_replacing; then
+       ver_replacing() {
+               case ${EBUILD_PHASE} in
+                       pretend|setup|preinst|postinst) ;;
+                       *)
+                               die "ver_replacing is meaningless in the 
${EBUILD_PHASE} phase"
+                               ;;
+               esac
+
+               [[ $# -eq 2 ]] || die "Usage: ver_replacing <op> <ver>"
+
+               local v
+               for v in ${REPLACING_VERSIONS}; do
+                       ver_test "${v}" "$@" && return 0
+               done
+               return 1
+       }
+fi

Reply via email to