I am building an rpm with rpmbuild. That already build rpm will be installed on rhel6, rhel7 or rhel8 machines. On rhel8, some dependencies are needed that are not needed in the other distribution versions (rhel6 and rhel7). Using a condition (as follow) on the name of the packages is then not an option.
Requires: (pkgA >= 3.2 or pkgB)
What I want to do in the spec file is something like :
%if %{VERSIONMAJOS} < 8
Requires: sssd >= 1.15 , sudo >= 1.8.6p3
%else
Requires: sssd >= 1.15 , sudo , oddjob , oddjob-mkhomedir
%endif
How can I define the variable VERSIONMAJOS?
I can not use the macro %{rhel} (as shown here https://unix.stackexchange.com/questions/9296/how-can-i-specify-os-conditional-build-requirements-in-an-rpm-spec-file) as that variable is defined during the build of the rpm (if I understand correctly the DistTag page https://fedoraproject.org/wiki/Packaging:DistTag).
What I need is the library requirement to be different when I use the command yum -y nameOfRmp.rpm
on an rhel6, rhel7 or rhel8.