1

I have a spec file in which based on the SLES version, i need to change the 'Requires: ' tag as below

#if suse is greated than SLES 11 sp4
%if %0{?suse_version} > 1140 
Requires: genisoimage
%else 
Requires: mkisofs 
%endif

I am building this rpm file on a SLES 10 machine. After generating RPM, irrespective of the OS, if i run,

rpm -qpR mypkg.rpm

I get mkisofs only as a required package. In none if the cases (even on SLES 12), I am getting genisoimage as dependent package.

What might be missing and how can this be fixed.

DTdev
  • 113
  • 4

1 Answers1

2

That's not how this works. This variable is evaluated at build-time, not at install time.

This macro expands to the version of SUSE Linux / openSUSE where the package is built. It is "1000" for SUSE Linux 10.0, "1020" for openSUSE 10.2 and so on.

emphasis mine, source

Also, as far as I understand, this variable refers only to the OpenSUSE version, not the SLES base version and SP anyway, so it wouldn't be present at all during build time on a SLES 10 machine.

Sven
  • 97,248
  • 13
  • 177
  • 225
  • Right @Sven. So is there a way, i can check that at run time ? – DTdev Jul 11 '17 at 10:26
  • 2
    The proper approach is to build different packages for different OSes. – Sven Jul 11 '17 at 10:27
  • Thanks @Sven. Although that is the right approach, for a patch work as we dont have a setup to create multiple packages, I have added a script under %pre and that script fetch for existed OS and based on the result, if it is an error, I am putting and exit 1 in the script and this is blocking the installation after displaying the error message. – DTdev Jul 13 '17 at 07:09