RFC: spec preprocessor

Michal Moskal malekith at pld-linux.org
Sat May 17 13:24:26 CEST 2003


Hello,

As everyone see bcond syntax in rpm is ugly. A solution to this (and
maybe few more) problems would be to run spec files through some kind of
preprocessor. For example:
#v+
%bcond foo default_off "foo support"
%bcond bar default_on "bar support"
%if foo
...
%else
...
%endif
%if bar
...
%endif

%{if foo: .... }
%{if !foo: ... }
%{if_else !foo: { ... } else { ... } }
#v-

Would be translated to:

#v+
# --with foo -- build with foo support
# --without bar -- build without bar support
%if %{?_with_foo:1}0
...
%else
...
%endif
%if %{!?_without_bar:1}0
...
%endif

%{?_with_foo: .... }
%{!?_with_foo: ... }
%{?_with_foo: .... }%{!?_with_foo: ... }
#v-

I'm not sure about usefulness of if_else.

Advantages:
  - simpler, shorter and more readable syntax
  - no information is lost in spec files in source rpm (one can rebuild
    source rpm with different options, even using some older rpm)
  - all this can be done using simple perl script and small patch
    against rpm

Disadvantages:
  - spec in CVS is different then in source rpm
  - one cannot use older/non-PLD rpm to build specs directly from CVS

I don't think these disadvantages are important though.

Hmm.. maybe we can even allow something like:

%if (foo && !bar) || baz

It would require a bit more perl in preprocessing but I think it's worth
it.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv
: PLD Linux ::::::::: Wroclaw University, CS Dept : {E-,w}-- {b++,e}>+++ h



More information about the pld-devel-en mailing list