diff --git a/macros.perl b/macros.perl index 035d0162522a550b20f0774167a8e36862b836e3..77cc30cce8eff5268d331317de2168be0768b9b4 100644 --- a/macros.perl +++ b/macros.perl @@ -174,3 +174,60 @@ This package provides the test suite for package %{name}.\ $v =~ s/^v//; print "$v$y"; ') + +# Macro to replace overly complicated references to CPAN source files. +# Expands to the cpanhosted URL for a package +# Accepts zero to three arguments: +# 1: The CPAN project name, defaulting to %%srcname if it is defined, then +# %%cpan_name if it is defined, then just %%name with "perl-" prefix +# removed. +# 2: The MetaCPAN project version, defaulting to %%version. +# 3: The file extension, defaulting to "tar.gz". (A period will be added +# automatically.) +# Requires %%__cpan_url and %%__cpan_default_extension to be defined. +# +# Ussage example: +# Name: perl-File-Find-Rule +# Version: 0.35 +# Source: %{cpan_source} +# - or - +# Source: %{cpan_source File-Find-Rule 0.35} +%__cpan_url https://www.cpan.org/modules/by-module/ +%__cpan_default_extension tar.gz + +%cpan_source() %{lua: + local src = rpm.expand('%1') + local ver = rpm.expand('%2') + local ext = rpm.expand('%3') + local url = rpm.expand('%__cpan_url') +\ + -- If no first argument, try %srcname, then %cpan_name, then %name + -- Note that rpm leaves macros unchanged if they are not defined. + if src == '%1' then + src = rpm.expand('%srcname') + end + if src == '%srcname' then + src = rpm.expand('%cpan_name') + end + if src == '%cpan_name' then + src = rpm.expand('%name'):gsub('^perl%-','') + end + local prefix + if string.match(src, '^(.+)%-') then + prefix = string.match(src, '^(.+)%-') + else + prefix = src + end +\ + -- If no second argument, use %version + if ver == '%2' then + ver = rpm.expand('%version') + end +\ + -- If no third argument, use the preset default extension + if ext == '%3' then + ext = rpm.expand('%__cpan_default_extension') + end +\ + print(url .. prefix .. '/' .. src .. '-' .. ver .. '.' .. ext) +} diff --git a/openEuler-rpm-config.spec b/openEuler-rpm-config.spec index ef9fef1674b767f66f05cfb2d8de75e20b0dd833..47d829a80293bf9c8827858fff8352589e4e1801 100644 --- a/openEuler-rpm-config.spec +++ b/openEuler-rpm-config.spec @@ -3,7 +3,7 @@ Name: %{vendor}-rpm-config Version: 31 -Release: 35 +Release: 36 License: GPL+ AND MIT Summary: specific rpm configuration files URL: https://gitee.com/src-openeuler/openEuler-rpm-config @@ -211,6 +211,9 @@ sed -i "s|@OSCPE@|$(cat /etc/system-release-cpe)|" %{buildroot}%{rpmvdir}/%{vend %{rpmvdir}/find-requires.ksyms %changelog +* Thu Sep 04 2025 Funda Wang - 31-36 +- add helper macro for cpan projects source + * Fri Aug 29 2025 lingsheng - 31-35 - macros.build-constraints add docker support