Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Using date in rpm macro

When you are building an rpm, and you want to use the date as a variable, or macro, you might already know about the percent-parenthesis syntax.

%define use_date %(date "+%F")

What took me a long time to remember is that you have to use percent percent when you want a literal percent sign.

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

Also, you cannot use dashes (2020-09-29) in a version of a package. Use the %%Y%%m%%d for the 20200929 format! Source: https://rpm.org/user_doc/macros.html

Comments