bloggf

[ Home | RSS 2.0 | ATOM 1.0 ]

Wed, 04 Feb 2009

RPM Macros

I've been working with RPM macros quite a bit lately, and I've noticed some interesting properties. Though mostly obvious after the fact, they are surpisingly underdocumented.

Macros don't seem to deal with floating point values. This works:

%define five 5

%if 0%{?five} <= 5
  %define string A
%else
  %define string B
%endif
While this causes a parse error:
%define five 5.3

%if 0%{?five} <= 5
  %define string A
%else
  %define string B
%endif

Quoting integers makes comparisons lexical. This will evaluate to false:

%define five 5

%if "0%{?five}" == "5"

Perhaps the most frustrating one for me was that commented out macros are expanded. This has surprising results if your macro expands to multiple lines. Say my spec file includes the following:

%description
#%foo                                                                           
blah
And foo happens to expand to multiple lines:
%define foo one\
two\
three
My description will end up being:
Description :

two
three
blah

posted at: 16:05 | path: /tech | permanent link to this entry

Powered by PyBlosxom