Passing conditional parameters into a rpm build

Michael Schwendt ms-nospam-0306 at arcor.de
Sun Jan 25 10:02:32 UTC 2004


On Sun, 25 Jan 2004 06:37:25 +0000, Keith G. Robertson-Turner wrote:

> Just hit a small snag building a package:
> 
> %install
> .... snip ....
> # FIXME: how to combine [!?_without_gtk OR ?_with_qt] into a single test?
> %{!?_without_gtk:install -D -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/pixmaps/nvclock.xpm}
> %{?_with_qt:install -D -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/pixmaps/nvclock.xpm}
> 
> and also:
> 
> %files
> .... snip ....
> # FIXME: how to combine [!?_without_gtk OR ?_with_qt] into a single test?
> %{!?_without_gtk:%{_datadir}/pixmaps/nvclock.xpm}
> %{?_with_qt:%{_datadir}/pixmaps/nvclock.xpm}
> 
> I've read the "conditionalbuilds" rpm doc, which gives the example:
> 
> # Read: If neither macro exists, then add the default definition.
> %{!?_with_ldap: %{!?_without_ldap: %define _without_ldap --without-ldap}}
> 
> But that's the equivalent of an [X AND Y], whereas I need a [X OR Y].
> 
> Specifically, [IF either X OR Y are TRUE, THEN install the file nvclock.xpm]
> 
> How?

Do some programming. Add another variable. :) Else these conditionals get
unreadable quickly. Example:

%{?_with_qt: --define _with_pixmap 1}
%{!?_without_gtk: --define _with_pixmap 1}

%install
...
%{?_with_pixmap:install -D -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/pixmaps/nvclock.xpm}
# Or this for longer blocks:
%if %{?_with_pixmap:1}%{!?_with_pixmap:0}
  install -D -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/pixmaps/nvclock.xpm}
%endif

%files
...
%{?_with_pixmap:%{_datadir}/pixmaps/nvclock.xpm}


-- 
Disclaimer: I do not consider myself an expert on RPM, so RPM wizards
may suggest a different solution.





More information about the fedora-devel-list mailing list