LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-02-2015, 02:39 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 537

Rep: Reputation: 33
[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?

Last edited by thomas2004ch; 06-02-2015 at 03:05 AM.
 
Old 06-02-2015, 03:13 AM   #2
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 537

Original Poster
Rep: Reputation: 33
My problem is solved by myself. I use the following code:

Code:
...
if "%{profile_name}" == "test"
%define pkg_release @PACKAGE_RELEASE_TEST@
%endif
...
 
Old 08-28-2017, 04:26 PM   #3
cengrs
LQ Newbie
 
Registered: Feb 2010
Posts: 1

Rep: Reputation: 0
Typo on the solution. Updated as follows:

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to set condition for found result? thomas2004ch Linux - Software 1 10-28-2013 03:48 AM
error package rpm-build which installing rpm-build from RHN Satellite Server. johnabraham Linux - Server 1 10-05-2013 06:51 PM
build an RPM that requires JAVA_HOME to be set before insall? dsollen Linux - Software 2 11-07-2009 04:02 PM
kdevelop, debugging - how to set a valid condition for a watchpoint? onufry Programming 4 07-17-2009 01:32 PM
Situation/condition in spec file for RPM Ameii83 Linux - Software 2 04-12-2007 12:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration