Use %{?rhel}
macro. In RHEL based distros it will be equal to the major distribution version. It is typically used together with leading 0 so that when the spec file is more likely to successfully built on other distros where it's not defined.
%if 0%{?rhel} < 8
Requires: sssd >= 1.15 , sudo >= 1.8.6p3
%else
Requires: sssd >= 1.15 , sudo , oddjob , oddjob-mkhomedir
%endif
For each distribution which has different set of Requires
, you need to build a separate RPM package.
Dynamic Requires based on distribution are simply not possible. This is just not how RPM works.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…