On Mon Dec 10, 2001 at 11:59:28PM +0100, Alexander Skwar wrote: > I'm writing a spec and am somehow stuck. > > I'd like to set the value of a %define to a value I set in a shell var. > So, I'd like to do: > > var="some great text" > %define def $var > > However, when I do this, %def ends up being empty.
Why do you need to make it a %define? Can't you just use $var?
> But, what I'd actually like to do, is to append the value to itself
> inside a loop. Just like:
>
> for i in 1 2 3; do
> var="$var $i"
> done
>
> If I translate this directly into defines, I get a recursion error
> (Recursion depth(17) greater than max(16)). I did:
>
> for i in 1 2 3; do
> %define def %def $i
> done
I don't think you can do this. Your best would be to do something
like:
for i in 1 2 3; do
var="$var $i"
done
%define def $var
For instance, I do this in my qmail package so I can have proper
output to README.RPM:
%if %{build_72}
RPMOPTIONS="$RPMOPTIONS build_72"
%else
RPMOPTIONS="$RPMOPTIONS"
%endif
%if %{build_80}
RPMOPTIONS="$RPMOPTIONS build_80"
%else
RPMOPTIONS="$RPMOPTIONS"
%endif
%setup -q
### optional patches ------------------------------------------------------
%if %{build_qmailqueue}
%patch0 -p1 -b .qmailqueue
RPMOPTIONS="$RPMOPTIONS qmailqueue"
%endif
%if %{build_tls}
%patch1 -p1 -b .tls
RPMOPTIONS="$RPMOPTIONS tls"
%endif
%if %{build_linksync}
%patch2 -p0 -b .linksync
RPMOPTIONS="$RPMOPTIONS linksync"
%endif
But I don't know how you could get something like:
%define rpmopts $RPMOPTIONS
I don't know if that would work, but I don't know why you would want
to do it. What's the difference between having $RPMOPTIONS and
%rpmopts?
Ie. if you had a 0|1 value, instead of doing
%if %{rpmopts}
...
%endif
do:
if [ $RPMOPTIONS == 1]
...
Isn't that possible in your spec?
> Could somebody please try to help me?
--
OpenPGP key available on www.keyserver.net
1024D/FE6F2AFD 88D8 0D23 8D4B 3407 5BD7 66F9 2043 D0E5 FE6F 2AFD
Current Linux kernel 2.4.8-34.1mdk uptime: 21 days 0 hours 50 minutes.
msg00054/pgp00000.pgp
Description: PGP signature
