commit: 7b00b5aa8c68942cdb9e751a9eeaa8b7795387f0
Author: Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 22 07:59:14 2022 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Feb 17 09:12:03 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7b00b5aa
Revert "bin/install-qa-check.d: drop QA_PKGCONFIG_VERSION checks from
60pkgconfig"
This reverts commit 772fdceea5f148d9bb5fd6c87ffd48f87ca93bab.
Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/install-qa-check.d/60pkgconfig | 60 ++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/bin/install-qa-check.d/60pkgconfig
b/bin/install-qa-check.d/60pkgconfig
index c982dbdf4..6ecbcabfd 100644
--- a/bin/install-qa-check.d/60pkgconfig
+++ b/bin/install-qa-check.d/60pkgconfig
@@ -88,6 +88,66 @@ pkgconfig_check() {
eqawarn "(contains reference to either lib or lib64 in wrong
directory)"
eqatag -v pkgconfig.bad-libdir "${bad_libdir[@]}"
fi
+
+ # Check for mismatched Version field vs ${PV}
+ # To be safe, let's make sure _all_ installed .pcs have a bad Version
+ # before warning, as this should catch the general cases we're worried
+ # about, while avoiding any pathological cases e.g. multiple libraries
+ # with different versioning within one package.
+ # Example bugs: bug #833895, bug #833887.
+
+ # Default to PV if QA_PKGCONFIG_VERSION is unset.
+ if [[ -z ${QA_PKGCONFIG_VERSION+set} ]]; then
+ local QA_PKGCONFIG_VERSION=${PV}
+ fi
+
+ # Skip the check if QA_PKGCONFIG_VERSION is set to empty string.
+ if [[ -n ${QA_PKGCONFIG_VERSION} ]]; then
+ 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 -t ver_test) == function ]] || inherit
eapi7-ver
+ is_pms_ver=true
+ fi
+
+ for f in "${files[@]}" ; do
+ local file_version=$(pkg-config --modversion "${f}")
+ 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 [[ ${#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
+ for bad_file in "${!bad_files[@]}"; do
+ local
bad_file_version="${bad_files[${bad_file}]}"
+ eqawarn "- ${bad_file}: ${bad_file_version}"
+ done
+ eqawarn "Please check all .pc files installed by this
package."
+ eqawarn "You can use QA_PKGCONFIG_VERSION to set the
expected version,"
+ eqawarn "or set to the empty string to disable this QA
check."
+ eqatag pkgconfig.unexpected-version ${!bad_files[@]}
+ fi
+ fi
}
pkgconfig_check