Re: Variable for version/release?

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

 



Great! It all works, that one has been vexing me for months. -- IV

On Sat, Oct 17, 2009 at 11:44 AM, Jos Vos <jos@xxxxxx> wrote:
> On Sat, Oct 17, 2009 at 11:16:40AM -0500, Ignacio Valdes wrote:
>
>> Thanks! Say I get the following message: /var/tmp/rpm-tmp.42695: line
>> 6: [: %{arch_switch}: integer expression expected
>>  with the following code but I do not know why this does not work?
>>
>> %ifarch x86_64
>> $define arch_switch 1
>> %endif
>>
>> if [ %{arch_switch} -eq 1 ]; then
>>  actual_gtm_path="/opt/lsb-gtm/V5.3-004A_x86_64"
>> else
>>  actual_gtm_path="/opt/lsb-gtm/V5.3-004A_i686"
>> fi
>
> This does not work because %{arch_switch} is not always defined.
> In case it isn't, rpm gives an error (although you describe a
> shell/test error -- I'd think rpm would also given an error).
> There are multiple ways to solve this:
>
> (1)
>
> Make sure %{arch_switch} is always defined:
>
> %ifarch x86_64
> $define arch_switch 1
> %else
> $define arch_switch 0
> %endif
>
> OR:
>
> (2)
>
> Change the evaluation so that this always succeeds:
>
> if [ 0%{?arch_switch} -eq 1 ]; then
>  actual_gtm_path="/opt/lsb-gtm/V5.3-004A_x86_64"
> else
>  actual_gtm_path="/opt/lsb-gtm/V5.3-004A_i686"
> fi
>
> Here, %{?arch_switch} evaluates to its value ("1" in your case) when
> it is defined, or to the empty string otherwise (because of the "?"
> there will be no rpm evaluation error).  Because teh concatenation
> of "0" with your value, this will be "0" or "01", which is always
> an integer.
>
> --
> --    Jos Vos <jos@xxxxxx>
> --    X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
> --    Amsterdam, The Netherlands        |     Fax: +31 20 6948204
> _______________________________________________
> Rpm-list mailing list
> Rpm-list@xxxxxxxxxxxxx
> http://lists.rpm.org/mailman/listinfo/rpm-list
>
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list


[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux