From: "Ulrich Müller" <ulm@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Ulrich Müller" <ulm@gentoo.org>
Subject: [gentoo-dev] [PATCH] eapi9-ver.eclass: New eclass
Date: Mon, 10 Feb 2025 20:08:59 +0100 [thread overview]
Message-ID: <20250210190909.23180-1-ulm@gentoo.org> (raw)
This implements the ver_replacing command, as proposed for EAPI 9:
| Takes an operator and a version string as arguments, which follow the
| same specification as in ver_test. Iterates over the elements of
| REPLACING_VERSIONS, using ver_test to compare each element with the
| version string. Returns shell true (0) if the specified relation is
| fulfilled for any element. Note that if REPLACING_VERSIONS is empty,
| shell false (1) is returned.
|
| The command is only meaningful in phases where \t{REPLACING_VERSIONS}
| is defined.
Bug: https://bugs.gentoo.org/947530
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
eclass/eapi9-ver.eclass | 50 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 eclass/eapi9-ver.eclass
diff --git a/eclass/eapi9-ver.eclass b/eclass/eapi9-ver.eclass
new file mode 100644
index 000000000000..9908fec37de8
--- /dev/null
+++ b/eclass/eapi9-ver.eclass
@@ -0,0 +1,50 @@
+# Copyright 2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: eapi9-ver.eclass
+# @MAINTAINER:
+# Ulrich Müller <ulm@gentoo.org>
+# @AUTHOR:
+# Ulrich Müller <ulm@gentoo.org>
+# @SUPPORTED_EAPIS: 7 8
+# @BLURB: Testing implementation of EAPI 9 ver_replacing
+# @DESCRIPTION:
+# A stand-alone implementation of the ver_replacing function aimed
+# for EAPI 9. Intended to be used for wider testing of the proposed
+# function and to allow ebuilds to switch to the new model early, with
+# minimal change needed for the actual EAPI 9.
+#
+# @CODE
+# if ver_replacing -lt 1.2; then
+# elog "The frobnicate command was dropped in version 1.2"
+# fi
+# @CODE
+
+case ${EAPI} in
+ 7|8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+# @FUNCTION: ver_replacing
+# @USAGE: <op> <ver>
+# @RETURN: 0 if any element of REPLACING_VERSIONS qualifies, 1 otherwise
+# @DESCRIPTION:
+# Compare each element <v> of REPLACING_VERSIONS with version <ver>
+# using ver_test(). Return 0 (true) if any element <v> fulfills
+# "ver_test <v> <op> <ver>", 1 (false) otherwise.
+#
+# Note: If REPLACING_VERSIONS is empty, 1 (false) is returned.
+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
+}
--
2.48.1
reply other threads:[~2025-02-10 19:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250210190909.23180-1-ulm@gentoo.org \
--to=ulm@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox