RFC: spec preprocessor

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


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:
%bcond foo default_off "foo support"
%bcond bar default_on "bar support"
%if foo
%if bar

%{if foo: .... }
%{if !foo: ... }
%{if_else !foo: { ... } else { ... } }

Would be translated to:

# --with foo -- build with foo support
# --without bar -- build without bar support
%if %{?_with_foo:1}0
%if %{!?_without_bar:1}0

%{?_with_foo: .... }
%{!?_with_foo: ... }
%{?_with_foo: .... }%{!?_with_foo: ... }

I'm not sure about usefulness of if_else.

  - 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

  - 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

: 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