From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 28A9C1582EF for ; Mon, 10 Feb 2025 19:12:01 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 2FD733431CE for ; Mon, 10 Feb 2025 19:10:06 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 61AA7110479; Mon, 10 Feb 2025 19:09:23 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id A5AC011042D for ; Mon, 10 Feb 2025 19:09:22 +0000 (UTC) Received: from localhost (p57bb175b.dip0.t-ipconnect.de [87.187.23.91]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ulm) by smtp.gentoo.org (Postfix) with ESMTPSA id 0C62834309F; Mon, 10 Feb 2025 19:09:21 +0000 (UTC) From: =?UTF-8?q?Ulrich=20M=C3=BCller?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Ulrich=20M=C3=BCller?= Subject: [gentoo-dev] [PATCH] eapi9-ver.eclass: New eclass Date: Mon, 10 Feb 2025 20:08:59 +0100 Message-ID: <20250210190909.23180-1-ulm@gentoo.org> X-Mailer: git-send-email 2.48.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 9a0d2cda-efa6-4a2a-991e-81735a2a9886 X-Archives-Hash: ffc587bb39b9030647916c091f5537f7 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 --- 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 +# @AUTHOR: +# Ulrich Müller +# @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: +# @RETURN: 0 if any element of REPLACING_VERSIONS qualifies, 1 otherwise +# @DESCRIPTION: +# Compare each element of REPLACING_VERSIONS with version +# using ver_test(). Return 0 (true) if any element fulfills +# "ver_test ", 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 " + + local v + for v in ${REPLACING_VERSIONS}; do + ver_test "${v}" "$@" && return 0 + done + return 1 +} -- 2.48.1