2

Can I use current timestamp ( or day, or else uniq param ) as release in spec rpm file ?

For example, something like this:

Release: 100%{?dist}.test.%{timestamp}
Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
Bdfy
  • 23,141
  • 55
  • 131
  • 179

1 Answers1

6

What you can do is define a variable before your preamble, then use it on the Release line. The following example will set the release number to (assuming September 12, 2013) 20130912.

%define build_timestamp %(date +"%Y%m%d")

...
Release: %{build_timestamp}
Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
  • However, this approach could result in the SRPM and RPM having different release values since they're generated one after the other, and the spec file is interpreted separately for each. – Nejuf Apr 03 '19 at 22:36
  • Also remember that for a literal percent sign, you need to escape the percent with a percent. `%define build_stamp %(date "+%%Y%%m%%d")` – bgStack15 Sep 30 '20 at 00:47
  • 1
    I encounter the problem that the %s would be expanded as a macro, here is the solution https://stackoverflow.com/questions/40396945/date-command-is-giving-erroneous-output-while-using-inside-rpm-spec-file – hsiaoairplane Oct 21 '20 at 08:48