LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   [RPM Build] How to set IF-condition in the %define? (https://www.linuxquestions.org/questions/linux-software-2/%5Brpm-build%5D-how-to-set-if-condition-in-the-define-4175544238/)

thomas2004ch 06-02-2015 02:39 AM

[RPM Build] How to set IF-condition in the %define?
 
Hi,

At the beginning of a .spec file there are some define. I wonder if one can set if-condition in the define such as:

Code:

...
%define profile_name @PROFILE_NAME@
...
if  [ %{profile_name} == "test" ]
%define pkg_release @PACKAGE_RELEASE_TEST@
fi

if [[ %{profile_name} == "pbv-icf" ]]; then
%define pkg_release @PACKAGE_RELEASE_PBV-ICF@
fi

...

I've tried this but I got error message like:
Code:

      [rpm] Building the RPM based on the pbv-icf-jboss-eap-6.2.1.spec file
      [rpm] error: line 18: Unknown tag: if  [ pbv-icf == "test" ]

This means the code "if [ %{profile_name} == "test" ]" is wrong.

Later I change this code as follow:

Code:

...
%if  [ %{profile_name} == "test" ]
%define pkg_release @PACKAGE_RELEASE_TEST@
%endif
...

But I got another error:
Code:

...
      [rpm] error: parse error in expression
      [rpm] error: pbv-icf-jboss-eap-6.2.1.spec:18: parseExpressionBoolean returns -1
...

What could be the correct format for IF-condition?

thomas2004ch 06-02-2015 03:13 AM

My problem is solved by myself. I use the following code:

Code:

...
if "%{profile_name}" == "test"
%define pkg_release @PACKAGE_RELEASE_TEST@
%endif
...


cengrs 08-28-2017 04:26 PM

Typo on the solution. Updated as follows:

%if "%{profile_name}" == "test"
%define pkg_release @PACKAGE_RELEASE_TEST@
%endif


All times are GMT -5. The time now is 09:11 PM.