#24 allow overriding the computed date in forge's %{?dist} macro
Merged 11 months ago by tibbs. Opened a year ago by decathorpe.

file modified
+3 -2

@@ -8,6 +8,7 @@

  #   Version   if applicable, set it with Version: <version>

  #   tag       if applicable

  #   commit    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:

@@ -255,7 +256,7 @@

    distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7)


  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}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}")

    explicitset("dist", dist)


  -- Final spec variable summary if the macro was called with -i

@@ -271,7 +272,7 @@

    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} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)\\n}")




This change allows packagers to specify the date part of the Release tag manually, if they desire to do so (for better reproducibility of package builds).

If %date is not defined when %forgemeta or %gometa is called, it falls back to the current behavior (reading the mtime of %{SOURCE0} and returning it in YYYYMMDD format).

With the second and third commit, this is now completely backwards compatible with the current implementation.

I tested this change locally with a modified system macros.forge file, and it works as advertised. The diff is straightforward enough, I think - I basically just "wrapped" the current calculation in conditional macros to allow for the override. I also updated the related documentation comments.

I would like to have review from @nim. Otherwise it looks good.

1 new commit added

  • macros.forge: drop additional dot to match current Guidelines
a year ago

@nim, please comment if you are able. I would like to get this merged relatively soon so we can move forward with updating the packaging guidelines.

Commit 4d49f07 fixes this pull-request

Pull-Request has been merged by tibbs

11 months ago

Pull-Request has been merged by tibbs

11 months ago