Help!

Append string to a macro


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> PRM - Partner Relationship Management RSS
Next:  crossgrading RPM packages  
Author Message
Tomasz Ostrowski
External


Since: Jun 27, 2006
Posts: 2



PostPosted: Tue Jun 27, 2006 2:15 pm    Post subject: Append string to a macro
Archived from groups: linux>redhat>rpm (more info?)

How to append a string to a macro in spec file? For example I have
defined a macro:
%define release 234
I want to append a string, for example "beta", to this macro somewhere
below this definition. I don't want to do it like this:
%define release 234beta
because I'd like to make a patch that I'd be able to apply to different
versions of spec file.

I tried:
%define release %{release}beta
%define release %(echo %{release}beta)
%{expand: %%define release %{release}beta}
%{expand: %%define release %%{release}beta}
and I got an infinite recursion every time.

--
Regards ...although Eating Honey was a very good thing to do,
Tometzky there was a moment just before you began to eat it
which was better than when you were...
Winnie the Pooh
Back to top
Scott Lurndal
External


Since: Oct 20, 2004
Posts: 82



PostPosted: Tue Jun 27, 2006 9:12 pm    Post subject: Re: Append string to a macro [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Tomasz Ostrowski <tometzky.nospam.RemoveThis@prhn.dnsalias.org> writes:
>How to append a string to a macro in spec file? For example I have
>defined a macro:
> %define release 234
>I want to append a string, for example "beta", to this macro somewhere
>below this definition. I don't want to do it like this:
> %define release 234beta
>because I'd like to make a patch that I'd be able to apply to different
>versions of spec file.
>
>I tried:
> %define release %{release}beta
> %define release %(echo %{release}beta)
> %{expand: %%define release %{release}beta}
> %{expand: %%define release %%{release}beta}
>and I got an infinite recursion every time.
>

Of course you did.

Use two macros:

%define baserelease 234
%define release ${baserelease}beta

scott
Back to top
Tomasz Ostrowski
External


Since: Jun 27, 2006
Posts: 2



PostPosted: Wed Jun 28, 2006 11:33 am    Post subject: Re: Append string to a macro [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Tue, 27 Jun 2006 21:12:53 GMT, Scott Lurndal wrote:

>>How to append a string to a macro in spec file?
>
> Use two macros:
>
> %define baserelease 234
> %define release ${baserelease}beta

I can not change a line:
%define release 234
so above won't work for me.

I was able to work around this problem changing:
Release: %{release}
to:
Release: %{release}beta
which changes %{release} automatically but I still don't know how to
append to a macro.

--
Regards ...although Eating Honey was a very good thing to do,
Tometzky there was a moment just before you began to eat it
which was better than when you were...
Winnie the Pooh
Back to top
Michal Jaegermann
External


Since: Jun 06, 2004
Posts: 62



PostPosted: Wed Jun 28, 2006 10:22 pm    Post subject: Re: Append string to a macro [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Tomasz Ostrowski <tometzky.nospam.DeleteThis@prhn.dnsalias.org> wrote:
>
> I was able to work around this problem changing:
> Release: %{release}
> to:
> Release: %{release}beta
> which changes %{release} automatically

Probably it is better to use

Release: %{release}%{?beta}

If macro %beta is not defined then %{?beta} will evaluate to
empty; otherwise it will be replaced by a definiton of %beta.
Then you can provide a definition of beta even outside of a spec
file (say in ~/.rpmmacros) or comment/uncomment one line in spec.

> but I still don't know how to
> append to a macro.

I do not think that you can. The last definition will be used
and you will bump into recursion.

Michal
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> PRM - Partner Relationship Management All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum