Results 1 to 3 of 3

Thread: Issue with 0%{?suse_version} in %if statement

  1. #1

    Question Issue with 0%{?suse_version} in %if statement

    Hi all,

    I've having trouble getting the OBS to recognise an if statement using the %suse_version variable in a spec file.
    The if statements that are giving me trouble begin on line 14 and 88 in the spec file.

    As far as I can tell, %suse_version for OpenSUSE 13.2 and Leap 42.1 are 1320 and 1315, respectively, so I have no clue as to why the if statements are not running correctly. Would anyone know what I've done wrong here?

    Spec file location: https://build.opensuse.org/package/v....spec?expand=1
    Build log: https://build.opensuse.org/package/l...ap_42.1/x86_64

  2. #2

    Default Re: Issue with 0%{?suse_version} in %if statement

    Quote Originally Posted by breed808 View Post
    As far as I can tell, %suse_version for OpenSUSE 13.2 and Leap 42.1 are 1320 and 1315, respectively, so I have no clue as to why the if statements are not running correctly. Would anyone know what I've done wrong here?
    This:
    Code:
    %elseif 0%{?suse_version} == 1315
    There is no %elseif, this will silently be ignored.

    Replace it with %else %if (and a second %endif), although you could also omit the %else altogether.
    I.e. like this:
    Code:
    %if 0%{?suse_version} == 1320
    BuildRequires:  gcc49
    BuildRequires:  gcc49-c++
    %else
    %if 0%{?suse_version} == 1315
    BuildRequires:  gcc5
    BuildRequires:  gcc5-c++
    %endif
    %endif
    or, this should also work as only one %if applies in any case:
    Code:
    %if 0%{?suse_version} == 1320
    BuildRequires:  gcc49
    BuildRequires:  gcc49-c++
    %endif
    %if 0%{?suse_version} == 1315
    BuildRequires:  gcc5
    BuildRequires:  gcc5-c++
    %endif
    Last edited by wolfi323; 14-Nov-2015 at 04:16. Reason: forgot one %endif

  3. #3

    Default Re: Issue with 0%{?suse_version} in %if statement

    Ah, my mistake. I had assumed that since spec files support %if and %else, %elseif would also be supported.
    Many thanks for pointing that out, I would never have solved that on my own.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •