From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1427300-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 2A74F158094
	for <garchives@archives.gentoo.org>; Sat, 13 Aug 2022 17:30:33 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 20AE3E07A9;
	Sat, 13 Aug 2022 17:30:32 +0000 (UTC)
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 pigeon.gentoo.org (Postfix) with ESMTPS id E5F6EE07A9
	for <gentoo-commits@lists.gentoo.org>; Sat, 13 Aug 2022 17:30:31 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(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 smtp.gentoo.org (Postfix) with ESMTPS id D243E3413DD
	for <gentoo-commits@lists.gentoo.org>; Sat, 13 Aug 2022 17:30:30 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 56C8255B
	for <gentoo-commits@lists.gentoo.org>; Sat, 13 Aug 2022 17:30:29 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1660411825.f46b89282ff58974bedb6ed29c83cfeab1e5ad4f.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/install-qa-check.d/60pkgconfig
X-VCS-Directories: bin/install-qa-check.d/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: f46b89282ff58974bedb6ed29c83cfeab1e5ad4f
X-VCS-Branch: master
Date: Sat, 13 Aug 2022 17:30:29 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 9e6f73a4-364e-47d3-930f-f9a7864704de
X-Archives-Hash: bba2a893355b219d863befa96c64e9d2

commit:     f46b89282ff58974bedb6ed29c83cfeab1e5ad4f
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  1 07:54:22 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 13 17:30:25 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=f46b8928

install-qa-check.d/60pkgconfig: use ver_test to compare versions

Motivied by Matthew's question if the version comparision could be
improved so that, e.g., 25.0 and 25.0.0 are treated as equal.

Note that using ver_test requires that we check the arguments passed
to ver_test conform to PMS version strings. If this is not the case,
then we fall back to the previous behavior and perform a string
comparision.

Thanks-to: Matthew Smith <matthew <AT> gentoo.org>
Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/882
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/install-qa-check.d/60pkgconfig | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/bin/install-qa-check.d/60pkgconfig b/bin/install-qa-check.d/60pkgconfig
index a8e0aa5db..e275e1ee2 100644
--- a/bin/install-qa-check.d/60pkgconfig
+++ b/bin/install-qa-check.d/60pkgconfig
@@ -103,26 +103,38 @@ pkgconfig_check() {
 
 	# Skip the check if QA_PKGCONFIG_VERSION is set to empty string.
 	if [[ -n ${QA_PKGCONFIG_VERSION} ]]; then
-		local all_bad=yes
+		local pms_ver_re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$"
 		local -A bad_files
+
+		local is_pms_ver=false
+		if [[ ${QA_PKGCONFIG_VERSION} =~ ${pms_ver_re} ]] ; then
+			# Ensure that ver_test is available.
+			[[ $(type -f ver_test) == function ]] || inherit eapi7-ver
+			is_pms_ver=true
+		fi
+
 		for f in "${files[@]}" ; do
 			local file_version=$(pkg-config --modversion "${f}")
-			if [[ ${QA_PKGCONFIG_VERSION} == ${file_version} ]] ; then
-				all_bad=no
-				break
-			fi
-
-			# Record a special value if the .pc file has no version set at all.
-			if [[ -z ${file_version} ]] ; then
+			if [[ -n ${file_version} ]] ; then
+				if ${is_pms_ver} && [[ ${file_version} =~ ${pms_ver_re} ]]; then
+					# If both versions comply to PMS, then we can use ver_test to compare them.
+					ver_test ${QA_PKGCONFIG_VERSION} -eq ${file_version} && continue
+				else
+					# Otherwise, we resort to string comparision.
+					[[ ${QA_PKGCONFIG_VERSION} == ${file_version} ]] && continue
+				fi
+			else
+				# Record a special value if the .pc file has no version set at all.
 				file_version="<no-set>"
 			fi
+
 			bad_files["${f//${D}}"]="${file_version}"
 		done
 
 		# Skip result reporting if *_p* because for both _pN and _preN, we
 		# don't generally expect the versions to be exactly accurate, and
 		# we want to avoid false positives.
-		if [[ ${all_bad} == "yes" && ${PV} != *_p* ]] && ! has live ${PROPERTIES} ; then
+		if [[ ${#bad_files[@]} -gt 0 && ${PV} != *_p* ]] && ! has live ${PROPERTIES} ; then
 			eqawarn "QA Notice: pkg-config files with mismatched Version found!"
 			eqawarn "The Version field of the following files does not match ${PV}"
 			local bad_file