[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Macros get expanded in comments..
- From: Jeff Johnson <jbj JBJ ORG>
- To: rpm-list redhat com
- Subject: Re: Macros get expanded in comments..
- Date: Mon, 25 Sep 2000 10:53:35 -0400
On Sun, Sep 24, 2000 at 06:04:20PM -0400, Jim Knoble wrote:
>
> There's an incredibly obtuse syntax for doing if/else definition of
The "incredibly obtuse" syntax is an existence test on a name like
%{?foo: ... }
If foo exists, then ... is expanded recursively. You can also test for
non-existence of foo
%{!?foo: ... }
The more tortured syntax is how to create a name for the existince test.
Say you want to use macros to test if the value of %_os is "linux". That
can be done by with an eval-like construct
%{expand: %%define i_am_%{_os} whatever}
which ends up defining the macro %_i_am_linux if the value of %_os is "linux",
and can be used in existence tests to conditionally expand as above.
While the pure macro syntax is tortured, there are any number of other ways
to conditionalize spec files. For example
if [ "%{_os}" = "linux" ]; then
... this is linux ...
else
... this is not linux ...
fi
is rather straight-forward shell code, and works in all scriptlet sections of
a spec file that use /bin/sh. In addition, a shell environment can
be introduced during parsing anywhere you wish by using %(...).
I still see very little utility in using pure macro expansions to
conditionalize spec files. Macros were designed to provide a unified
and open-ended representation of information from a spec file, from
rpm configuration, from rpm CLI invocation, from (eventually) package
meta-data (headers), and from (possibly) package payloads. Otherwise,
macros are nearly useless as a reasonable programming language, and,
like many macro languages, are little more than a fancy strdup.
> macros based on some criterion. It's not documented anywhere in
> /usr/doc/rpm-3.0.5/, and the only place i've ever seen it mentioned is
> here on the rpm-list mailing list.
>
Yikes, you're right. I had thought this was documented already in
/usr/doc/rpm-*/macros, but I'm wrong. Will fix.
...
>
> http://www.geocrawler.com/archives/3/87/1999/10/0/2739078/
>
(This appears to be what I described above Yet Again.)
> (Sigh.) This whole RPM secret-society thing is beginning to bother me.
> I must be getting grumpy again....
<grin>
Serioulsly, I'd like to fix the "secret society" (presumably you mean the
difficulty of finding rpm documentation), but much of the problem is outside
my immediate control. In a nuitshell, I will get rpm documented, I just
don't know when.
73 de Jeff
--
Jeff Johnson ARS N3NPQ
jbj@jbj.org (jbj@redhat.com)
Chapel Hill, NC
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]