Passing conditional parameters into a rpm build

Michael Schwendt ms-nospam-0306 at arcor.de
Sun Jan 25 17:41:47 UTC 2004


On Sun, 25 Jan 2004 15:44:31 +0000, Keith G. Robertson-Turner wrote:

> I need to read up on this more, but I can't seem to locate any advanced
> docs on things like conditional opts ... maybe I need to start looking on
> Amazon :)

Maybe. If the "Red Hat RPM Guide" (much more recent than "Maximum RPM"!)
doesn't cover it,

  http://www.amazon.com/exec/obidos/tg/detail/-/0764549650/

there's still rpm-list:

  http://www.redhat.com/mailman/listinfo/rpm-list
 
> To what extent can bash constructs be used in this context?:
> 
> %if [%{?_X:1} -o %{?_Y:1}]
> foobar
> %endif

I don't think the native boolean expression support more than comparison
(==, >=, <=) and NOT (!).  But you can use shell constructs in %(...),
like:

  %if %(test "%{?_X}" = 1 -o "%{_Y}" = 1 && echo 1 || echo 0) 
    // something
  %endif

> Or even:
> 
> %{%{?_X:1}:%{?_Y:1}:foobar}
> 
> That would be ideal if it worked :)

Depends on what values _X and _Y have. If you work with boolean values
like above and make sure both X and Y are member of {0,1}, you can use
native expressions like

  %if %{?_X}%{?_Y} 
  // something
  %endif

for a logical OR.

 _X=0, _Y=0 => expr = 00 (false)
 _X=0, _Y=1 => expr = 01 != 0 (true)
 _X=1, _Y=0 => expr = 10 != 0 (true)
 _X=1, _Y=1 => expr = 11 != 0 (true)

and of course

  %if %{?_X}
    %if %{?_Y}
      // something
    %endif
  %endif

for a logical AND (or a shell construct as above).

Note that the "--with foo/--without foo" switches assign "--with foo" or
"--without foo" to _with_foo or _without_foo, respectively.

-- 





More information about the fedora-devel-list mailing list