RPM spec to require specific RHEL release
The redhat-release-server-6Server-6.3.0.3.el6.x86_64 (on my system) seems to be a good candidate as a prerequisite. See http://rhn.redhat.com/errata/RHEA-2012-0971.html . What is not obvious for a novice looking at the package name is that "6Server" is actually the package version. "rpm -q --info" make this clear, though:
$ rpm -q redhat-release-server-6Server --info
Name : redhat-release-server Relocations: (not relocatable)
Version : 6Server Vendor: Red Hat, Inc.
Release : 6.3.0.3.el6 Build Date: Wed 30 May 2012 11:19:03 AM PDT
Install Date: Tue 02 Oct 2012 09:48:26 AM PDT Build Host: x86-003.build.bos.redhat.com
Group : System Environment/Base Source RPM: redhat-release-server-6Server-6.3.0.3.el6.src.rpm
Size : 38585 License: GPLv2
Signature : RSA/8, Wed 30 May 2012 12:19:55 PM PDT, Key ID 199e2f91fd431d51
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary : Red Hat Enterprise Linux Server release file
Description :
Red Hat Enterprise Linux Server release files
So the correct directive is:
Requires: redhat-release-server >= 6Server-6.3
rpmbuild requires depending on the OS version where the rpm will be installed
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.
How to author a .spec file that requires either sl-release or centos-release or redhat-release?
... turns out that aside from the conditionals pointed out in "https://serverfault.com/q/283330/71790", there is something like a symbolic/alias name for the above. Guessing a little, a web search turned up centos-release
and of course redhat-release
as the package names used on the other two related distros.
Since it took me some time to come up with the solution and sharing is caring, I decided to write down what I found for the next internaut doing a web search.
So, next I ran yum install redhat-release
in order to install it, hoping it would be available. It was:
$ sudo yum install redhat-release
Setting up Install Process
Package sl-release-6.1-2.x86_64 already installed and latest version
Nothing to do
Apparently the name redhat-release
somehow magically translates to sl-release
. I.e. it's an alias.
Conclusion
You can use the generic name redhat-release
, even on the two derived distros CentOS and Scientific Linux to refer to the respective distribution-specific packages centos-release
and sl-release
. So:
Require: redhat-release >= 6.1
does the job on all of them.
On a related note, I knew that all of them have a file /etc/redhat-release
and yum whatprovides /etc/redhat-release
gave me:
$ yum whatprovides /etc/redhat-release
sl-release-6.1-2.x86_64 : Scientific Linux release file
Repo : local
Matched from:
Filename : /etc/redhat-release
sl-release-6.1-2.x86_64 : Scientific Linux release file
Repo : installed
Matched from:
Other : Provides-match: /etc/redhat-release
rpm: specify version in BuildRequires or Requires directives in spec file
It's as you would expect:
Requires: python >= 3.5
How to check for RedHat (RHEL) minor version in rpm spec file?
There is a mechanism to specify weak dependency i.e. optional dependency in rpm spec file. This way if the package is available it’ll be installed else dependency will be ignored.
https://rpm.org/user_doc/dependencies.html
“Recommends” directive appears valid on Fedora but not available on RHEL
https://bugzilla.redhat.com/show_bug.cgi?id=1427674
After much thought I don't think it's possible to differentiate dependencies based on RHEL minor version without shipping different el7 packages for RHEL 7.2/7.3 v/s RHEL 7.4+ which is not an option...
Creating an RPM package consisting only of required packages
Just touch an empty file, or even use a virtual provides. Pretty sure no sources is valid, just say something like Provides: our_required_software = %{version}
.
Specified Provides version in rpm spec file
I'm putting aside that multilib is still supported by RPM (and I'm puzzled why are you doing that). But when i focus on that spec problem.
You have it nearly correct. Just omit that percent sign. Correct is:
Provides: xxx = 16.0
Note that the "16.0" should be just version. While it technically can be version-release, this will make you trouble some time later.
And if you want to provide really clean upgrade path, you should put there Obsolete too. See https://docs.fedoraproject.org/en-US/packaging-guidelines/#renaming-or-replacing-existing-packages
rpm conditional dependency requirements
if you build one rpm for all platforms
You can depend on semanage
itself:
Requires: /usr/sbin/semanage
yum
, dnf
or rpm
should be smart enough to work that out.
if you build each rpm on the corresponding target:
you can use the %rhel_version
macros, see https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto :
%if 0%{?rhel_version} < 800
Requires: policycoreutils-python
%else
Requires: policycoreutils-python-utils
%endif
RPM Spec file conditional Requires per distribution AFTER build
rpm-4.13 will solve my issue: http://www.rpm.org/wiki/PackagerDocs/BooleanDependencies
or - requires one of the operands to be fulfilled
Requires: (pkgA >= 3.2 or pkgB)
Related Topics
Gitlab-Ci Alpine Image: Host Key Verification Failed
Can't Load Mod_Wsgi Compiled for Python 3
In Shellscript Assign Variable Based on Curl Output
How to Decide How Much Stack I Can Use After a Call to Pthread_Attr_Setstacksize
Linux Grep/Sed Certain Lines - Space Removal
Format and Filter File to CSV Table
Auto-Start Program at Login in Angstrom on Beagleboard
How to Create a File of Size More Than 2Gb in Linux/Unix
Giving Linux User Git Access But Not Shell Access
Run Hydra (Mpiexec) Locally Gives Strange Ssh Error
Inconsistent Systemd Startup of Freeswitch
Run Script on Startup with Raspbian Jessi Wheezy and Raspberry Pi2B
Why a Static Library Can Depend on a Shared a Library
How to Simulate a Usb Printer to Lpt on Linux
Complete Password Field Scp Command on Linux
What's The Relation Between 32/64-Bit Application, Os and Processor