Knowledge Base

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

Rpm spec macros and variables

A nice place to read about the macros in rpm specs is https://fedoraproject.org/wiki/Packaging:RPMMacros. You can also run a command similar to rpm -E '%{dist}' to see a variable's definition. To use your own variable in a spec, you can use a %define.

%define myvar 3.1415926

To get even fancier, you can do shell commands in a definition.

%define version_num "%( echo %version | tr -d '\.' )"

This takes %{version} which could be 4.51 and sets a variable to "451" for which I had a use.

Comments