diff --git a/macros.perl b/macros.perl index 6aaecaf3c9bf24e720267d46d5e5bcdf95d1ab3a..035d0162522a550b20f0774167a8e36862b836e3 100644 --- a/macros.perl +++ b/macros.perl @@ -159,3 +159,18 @@ This package provides the test suite for package %{name}.\ # shortcut sugar %perl_default_subpackage_tests %perl_subpackage_tests t/ +# convert numeric version to tuple version +# +# Example: +# %perl_convert_version(3.1) => 3.100.0 +# %perl_convert_version(4.00208) => 4.2.80 +%perl_convert_version() %(perl -Mversion -le ' + $x = "%{1}"; + $y = $x; + $x =~ s/[[:alpha:]]*$//; + $y =~ s/^$x//; + $x =~ s/\D*$//; + $v = version->new($x)->normal; + $v =~ s/^v//; + print "$v$y"; +') diff --git a/macros.semver b/macros.semver new file mode 100644 index 0000000000000000000000000000000000000000..000be34ce4e3285349ea7f5291d6d91c922a7ec2 --- /dev/null +++ b/macros.semver @@ -0,0 +1,32 @@ +# This file contains macros manipulating package versions +# +# Several parts of version +%version_major %(echo %{version} | cut -d . -f1) +%version_minor %(echo %{version} | cut -d . -f2) +%version_major_minor %(echo %{version} | cut -d . -f1,2) +%version_patch %(echo %{version} | cut -d . -f3 | cut -d - -f1 | cut -d + -f1) +%version_pre_release %(echo %{version} | cut -d . -f3 | cut -d - -f2 | cut -d + -f1) +%version_build %(echo %{version} | cut -d . -f3 | cut -d - -f2 | cut -d + -f2) + +# Get version of specific rpm installed at build time +# Default only output %{?epoch:%{epoch}:}%{version} +# -r output release also +# -p query Provides besides name +# (-r is useless when combined with -p, because +# using -p means querying via Provides tag) +# output 0 if package not installed +# +# Usage example: +# Requires: openssl-libs >= %{installed_version_of openssl-libs} +# Requires: libX11 >= %{installed_version_of -r libX11} +# Requires: bcfversion = %{installed_version_of -p bcfversion} +# will produce following requires on built rpms: +# openssl-libs >= 1:3.0.7 +# libX11 >= 1.1.14-2.oe1 +# bcfversion = 3.9 +# +%installed_version_of(rp) %(\ +rpm -q %{-p:--whatprovides} %1 > /dev/null && \ +%{-p: rpm -q --provides $(rpm -q --whatprovides %1) | grep '%1 =' | awk -F' = ' '{print $2}' } \ +%{!-p: rpm -q --queryformat="%%|EPOCH?{%%{EPOCH}:}:{}|%%{VERSION}%{-r:-%%{RELEASE}}" %1} || echo 0 +) diff --git a/openEuler-rpm-config.spec b/openEuler-rpm-config.spec index 6304beeda34c00a19fd1f6fe2a6da026b998d878..7b8044c6d78655d5866f73537bce24c015a9991d 100644 --- a/openEuler-rpm-config.spec +++ b/openEuler-rpm-config.spec @@ -3,7 +3,7 @@ Name: %{vendor}-rpm-config Version: 31 -Release: 33 +Release: 34 License: GPL+ AND MIT Summary: specific rpm configuration files URL: https://gitee.com/src-openeuler/openEuler-rpm-config @@ -211,6 +211,10 @@ sed -i "s|@OSCPE@|$(cat /etc/system-release-cpe)|" %{buildroot}%{rpmvdir}/%{vend %{rpmvdir}/find-requires.ksyms %changelog +* Sat Aug 16 2025 Funda Wang - 31-34 +- add helper macro to deal with semver +- add helper macro to deal with numeric version of perl modules + * Thu Aug 07 2025 Funda Wang - 31-33 - do not bytecompile other directories by default https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_3