[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Appreciate advice on %if %foo || %bar syntax
- From: Patrick <rpm-list puzzled xs4all nl>
- To: RPM Package Manager <rpm-list redhat com>
- Subject: Re: Appreciate advice on %if %foo || %bar syntax
- Date: Thu, 30 Aug 2007 12:28:02 +0200
On Thu, 2007-08-30 at 08:12 +0200, Tony Earnshaw wrote:
> Michael Jennings skrev, on 29-08-2007 23:48:
>
> >> I have a spec file which tests for various distro's:
> >>
> >> %define is_fc45 %(test -f /etc/fedora-release && cat /etc/fedora-release | egrep -q '4|5' && echo 1 || echo 0)
> >> %define is_fc6 %(test -f /etc/fedora-release && grep -c Zod /etc/fedora-release || echo 0)
> >> %define is_f7 %(test -f /etc/fedora-release && grep -c Moonshine /etc/fedora-release || echo 0)
> >> %define is_rhel4 %(test -f /etc/redhat-release && cat /etc/redhat-release | egrep -q 'release 4' && echo 1 || echo 0)
> >> %define is_rhel5 %(test -f /etc/redhat-release && cat /etc/redhat-release | egrep -q 'release 5' && echo 1 || echo 0)
> >>
> >> Now I would like to use something like this:
> >>
> >> %if %is_fc6 || %is_f7 || %is_rhel5
> >> ..do something
> >> %endif
> >
> > %if %{is_fc6}%{is_f7}%{is_rhel5}
> >
> > will expand to
> >
> > %if 010
> >
> > and will do exactly what you want.
>
> Thanks from somebody else :)
>
> Quite another thing is, that a more rational test would be something like:
>
> "test -f /etc/redhat-release && grep 'release 5' /etc/redhat-release &&
> echo 1 || echo 0"
>
> Redundant use of "cat|grep" and egrep ...
Thanks Tony, I see what you mean. Iirc I copied it a long time ago from
another spec file. It just works so I never bothered to look at it in
more detail.
Regards,
Patrick
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]