[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: RH9/rpm-4.2.0-69: %expand:%() misbehaves on %if statements

> On Thu, 2003-12-11 at 23:27, bishop wrote:
>> In that file, I have a common construct:
>> > %if "%(rpm -qf /etc/issue --qf %%{name})" == "redhat-release"
>> > %define apacheName              %(rpm -q --qf "%%{name}"
>> --whatprovides webserver)
>> > %else
>> > %define apacheName              apache
>> > %endif
>>  > %define apacheDevelName         %{apacheName}-devel
>> This is probably something EVERYONE's seen, unfortunately, or at least
>> anyone who builds package for RH7 and RH9 and which depends on the web
>> server being present (Joe, can ya toss a provides:webserver-devel in
>> there?).
>> The problem is, when %expand picks up the output of the %(), it runs
>> BOTH parts of the %if.  It leads me to believe that %expand only deals
>> with things line-by-line.  True?  If so, how does one do an %if/else
>> like the above on a single line?
> Have you tried:
> %{expand: %%define apacheName %%(rpm -q --qf "%%{name}" --whatprovides
> webserver)}
> (I'm not sure whether "%%{name}" will expand correctly, though ...)
> and:
> %{expand: %%define apacheName apache}

Unfortunately, both those examples seem to gratuitously use %expand.  I
may not be understanding your example, but it seems like the same will
work, without the %expand:

      %define apachename apache

The wrinkle is, this data's essentially Generated, and the %expand is used
only to parse the macros generated by extracting this file from the
tarball. If I didn't *need* it, I wouldn't use it.. unfortunately, %()
outside of a build stanza in the spec file (safely) does not process
macros but includes them as-is - thus the %expand, which normally
activates all the macros in there.  It's a pretty workable solution, right
up to the point where we need to now have this %if-else thing.

I'm really starting to think that %expand doesn't have any state-saving
stuff from line to line, but I'm reluctant to bug Mr Johnson on it.

Anyone have an example of an %expanded macro set from generated content
like that, where the %if-else works?  Proof of the concept would remove
any doubts as to its workability.

Now, if we could get rid of the 8k limit on %expand too....  8-)

 - bish

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]