Reputation: 416
Currently, writing a *.spec file for an RPM. How can I dynamically define variables so that they utilize the parameterized macro?
Per the rpm documentation I've come up with following:
1 %define postgresql_macro() (?%1?%2?%3?%4?%5)
2 %define postgresql_ver %postgresql_macro 9 . 4 . 15
3 %define postgresql_ver_short %postgresql_macro 9 . 4 .
4 %define postgresql_ver_major 9 4
Line 1 is the macro that accepts parameters.
Line 2 should define postgresql_ver
as 9.4.15
.
LIne 3 should define postgresql_ver_short
as 9.4
.
Line 4 should define postgresql_ver_major
as 94
.
How can I test this? Is this correct?
Upvotes: 1
Views: 256
Reputation: 5417
First, you have it wrong. it should be:
%define postgresql_macro() %1%2%3%4%5
%define postgresql_ver %postgresql_macro 9 . 4 . 15
%define postgresql_ver_short %postgresql_macro 9 . 4 .
%define postgresql_ver_major 9 4
You can test this way. Put in your SPEC file:
%prep
%define postgresql_macro() %1%2%3%4%5
%define postgresql_ver %postgresql_macro 9 . 4 . 15
%define postgresql_ver_short %postgresql_macro 9 . 4 .
%define postgresql_ver_major 9 4
echo %{postgresql_ver}
And now run rpmbuild -bp your.spec
. This should print: 9.4.15
Upvotes: 2