From 74b8dd05bbc696e24d469d9c7e5e4f938cf6d028 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: May 10 2018 17:11:47 +0000 Subject: [PATCH 1/3] do not use modification time of tarball for computing %dist Using the modification time of the snapshot tarball for computing dist is a bad idea, since it's different on different machines. For example, the computed date during the `buildSRPMfromSCM` koji task is likely different from the local date when the package was prepared, and so package builds (especially EVRs and changelog entries) are not reproducible. With this change, the snapshot date is not calculated magically, but the packager has to set "%global date YYYYMMDD" manually. I also adapted the documentation for the macro to reflect that change. This is related to the following FPC issue: https://pagure.io/packaging-committee/issue/719 --- diff --git a/macros.forge b/macros.forge index 1bec610..17efa3f 100644 --- a/macros.forge +++ b/macros.forge @@ -8,6 +8,7 @@ # Version if applicable, set it with Version: # tag if applicable # commit if applicable +# date if applicable # # The macro will attempt to compute and set the following variables if they are # not already set by the packager: @@ -255,7 +256,7 @@ if (distprefix == "") then distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7) end if (distprefix ~= "") then - local dist = ".%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") + local dist = ".%{date}.%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") explicitset("dist", dist) end -- Final spec variable summary if the macro was called with -i @@ -271,7 +272,7 @@ if informative then rpm.expand("%{echo: scm: %{?scm}\\n}") rpm.expand("%{echo: tag: %{?tag}\\n}") rpm.expand("%{echo: commit: %{?commit}\\n}") - rpm.expand("%{echo: dist: %{?dist} (snapshot date is computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)\\n}") + rpm.expand("%{echo: dist: %{?dist}\\n}") end } @@ -279,4 +280,4 @@ end %forgesetup(a:b:cDn:Tq) %setup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-q} # Convenience macro to relay computed arguments to %autosetup -%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} +%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} \ No newline at end of file From 22833277e67bd7f5a58300492e03059edbe03076 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: May 26 2018 09:59:04 +0000 Subject: [PATCH 2/3] supplying %date for %forge macros optional (backwards compatible) --- diff --git a/macros.forge b/macros.forge index 17efa3f..fd703a1 100644 --- a/macros.forge +++ b/macros.forge @@ -8,7 +8,7 @@ # Version if applicable, set it with Version: # tag if applicable # commit if applicable -# date if applicable +# date if applicable (to override the mtime of the Source archive) # # The macro will attempt to compute and set the following variables if they are # not already set by the packager: @@ -256,7 +256,7 @@ if (distprefix == "") then distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7) end if (distprefix ~= "") then - local dist = ".%{date}.%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") + local dist = ".%{?date}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}.%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") explicitset("dist", dist) end -- Final spec variable summary if the macro was called with -i @@ -272,7 +272,7 @@ if informative then rpm.expand("%{echo: scm: %{?scm}\\n}") rpm.expand("%{echo: tag: %{?tag}\\n}") rpm.expand("%{echo: commit: %{?commit}\\n}") - rpm.expand("%{echo: dist: %{?dist}\\n}") + rpm.expand("%{echo: dist: %{?dist} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)\\n}") end } @@ -280,4 +280,4 @@ end %forgesetup(a:b:cDn:Tq) %setup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-q} # Convenience macro to relay computed arguments to %autosetup -%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} \ No newline at end of file +%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} From 30ef72bedf46d2d32156c5d8b6669af3487d713d Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Jun 14 2018 16:25:25 +0000 Subject: [PATCH 3/3] macros.forge: drop additional dot to match current Guidelines --- diff --git a/macros.forge b/macros.forge index fd703a1..18e9dba 100644 --- a/macros.forge +++ b/macros.forge @@ -256,7 +256,7 @@ if (distprefix == "") then distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7) end if (distprefix ~= "") then - local dist = ".%{?date}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}.%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") + local dist = ".%{?date}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") explicitset("dist", dist) end -- Final spec variable summary if the macro was called with -i