Issue
Let's say I have a spec file that looks something like this:
Name: mypackage
Version: 1.0.0
BuildRequires: cmake
%if 0%{?rhel} >= 7 || 0%{?fedora} >=17
Requires: python3
%else
Requires: python
%endif
I'm aware of yum-builddep
for install my build dependencies based on the spec, I would really like a yum-installdep
. Is anyone aware of a simple way to accomplish what I want given that there is some logic in the spec file?
EDIT:
I'm also aware that I can build the RPM, then install it, then uninstall it, but I'm doing this in the context of a continuous testing environment, so I'd really like to just install the dependencies to save the build time of the RPM itself.
Solution
Simple answer, no. rpmbuild
builds a spec and when you have a Requires
, it only checks it during runtime and not during the build. Only BuildRequires
get checked during build time. You can build an rpm in a single mock environment for one or more runtime
environments, just as your spec
suggests.
If you want to test your built .rpm
for python
and/or python3
in a continuous test environment, then you can simply run the rpm
installation in a test
mode and check the result. You have to use rpm
as yum
doesn't provide a dry-run
mode.
$ rpm -Uvh --test mypackage.rpm
or
$ rpm -qp --requires mypackage.rpm
Above would tell you what packages mypackage.rpm
would need in a given environment. Based on your spec
file, if you run the above command in a Fedora 17+/RHEL7
mock test environment, it would tell you that it requires python3
, else python2
$ rpm -q --requires python3-setuptools | grep python
/usr/bin/python3
python(abi) = 3.6
$ rpm -q --requires python2-setuptools | grep python
/usr/bin/python2
python(abi) = 2.7
Answered By - iamauser Answer Checked By - Robin (WPSolving Admin)