From 7c1824e99a7fe38e7d618ecb9ef7a8476ea2c9d8 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Thu, 9 Mar 2023 20:58:43 -0600 Subject: [PATCH] Backport rpmautospec fallback macros rpmautospec koji plugin bakes in the result of %autorelease and %autochangelog into the SRPM. When used on a Fedora or EL 9 machine with rpmautospec installed, fedpkg does the same. However, it's currently impossible to rebuild specfiles that use rpmautospec on EL 8 itself due to the unexpanded %autorelease and %autochangelog macros failing the SRPM build. This adds the same fallback %autorelease and %autochangelog macro definitions that are available in the Fedora and EPEL 9 buildroots. This allows locally rebuilding packages that use rpmautospec with plain rpmbuild or fedpkg on an EL 8 system or with `mock --spec`. --- epel-rpm-macros.spec | 11 ++++++++++- macros.rpmautospec | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 macros.rpmautospec diff --git a/epel-rpm-macros.spec b/epel-rpm-macros.spec index 80273c9..32ed50c 100644 --- a/epel-rpm-macros.spec +++ b/epel-rpm-macros.spec @@ -1,6 +1,6 @@ Name: epel-rpm-macros Version: 8 -Release: 37 +Release: 38 Summary: Extra Packages for Enterprise Linux RPM macros License: GPLv2 @@ -23,6 +23,9 @@ Source24: sysusers.generate-pre.sh # misc macros Source150: macros.build-constraints Source151: https://src.fedoraproject.org/rpms/redhat-rpm-config/raw/rawhide/f/macros.shell-completions +# autochangelog and autorelease fallback macros +%global rpmautospec_commit 52f3c2017e10c5ab5a183fed772e9fe8a86a20fb +Source152: https://pagure.io/fedora-infra/rpmautospec/raw/%{rpmautospec_commit}/f/rpm/macros.d/macros.rpmautospec BuildArch: noarch Requires: redhat-release >= %{version} @@ -99,10 +102,13 @@ install -Dpm 644 %{SOURCE150} \ %{buildroot}%{_rpmmacrodir}/macros.build-constraints install -Dpm 644 %{SOURCE151} \ %{buildroot}%{_rpmmacrodir}/macros.shell-completions +install -Dpm 644 %{SOURCE152} \ + %{buildroot}%{_rpmmacrodir}/macros.rpmautospec %files %license GPL %{_rpmmacrodir}/macros.epel-rpm-macros +%{_rpmmacrodir}/macros.rpmautospec %{_sysconfdir}/rpm/macros.zzz-epel-override %{_fileattrsdir}/pythondist.attr @@ -119,6 +125,9 @@ install -Dpm 644 %{SOURCE151} \ %changelog +* Fri Mar 10 2023 Maxwell G - 8-38 +- Backport rpmautospec fallback macros + * Wed Feb 08 2023 Maxwell G - 8-37 - Stop overriding macros that are now in RHEL 8.7 diff --git a/macros.rpmautospec b/macros.rpmautospec new file mode 100644 index 0000000..170e480 --- /dev/null +++ b/macros.rpmautospec @@ -0,0 +1,16 @@ +%autorelease(e:s:pb:n) %{?-p:0.}%{lua: + release_number = tonumber(rpm.expand("%{?_rpmautospec_release_number}%{!?_rpmautospec_release_number:1}")); + base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); + print(release_number + base_release_number - 1); +}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} +%autochangelog %{lua: + locale = os.setlocale(nil) + os.setlocale("C.utf8") + date = os.date("%a %b %d %Y") + os.setlocale(locale) + packager = rpm.expand("%{?packager}%{!?packager:John Doe }") + evr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}") + print("* " .. date .. " " .. packager .. " - " .. evr .. "\\n") + print("- local build") +} +