Situation
I have an RPM that uses semanage
(SELinux policy management tool) and restorecon
(SELinux context configuration tool) in the post-installation and pre-uninstallation stages.
Unfortunately, between RHEL 6/7 and 8, the package containing these tools was renamed from policycoreutils-python
to policycoreutils-python-utils
.
A working spec file for the RHEL8 RPM contains:
Requires(post): policycoreutils-python-utils
Requires(preun): policycoreutils-python-utils
And a working spec file for the RHEL6/7 RPM contains:
Requires(post): policycoreutils-python
Requires(preun): policycoreutils-python
What I try to achieve
I could live with the two spec files/two RPMs, one for every OS type, but I'm lazy and I want one spec that serves all.
What I tried
I read about the OS conditional %{rhel}
, containing the OS version. The following should work, according to the RPM manual:
%if %{rhel} < 8
Requires(post): policycoreutils-python
Requires(preun): policycoreutils-python
%endif
%if %{rhel} == 8
Requires(post): policycoreutils-python-utils
Requires(preun): policycoreutils-python-utils
%endif
If I check the value of the %{rhel}
variable on my target systems, I get what I expect:
centos7-system» rpm --eval '%{rhel}'
7
centos8-system» rpm --eval '%{rhel}'
8
Installation of this RPM on a CentOS 6/7 instance works fine. However, upon installation of the OS-independent RPM on an CentOS 8 instance, I get:
centos8-system» dnf install my-1.26-0.x86_64.rpm
<...>
Error:
Problem: conflicting requests
- nothing provides policycoreutils-python needed by my-1.26-0.x86_64
Debug output:
centos8-system» rpm -ivvvh my-1.26-0.x86_64.rpm 2>&1 | grep Requires
D: Requires: /bin/bash YES (db files)
D: Requires: /bin/sh YES (db files)
D: Requires: /bin/sh YES (cached)
D: Requires: /bin/sh YES (cached)
D: Requires: /usr/bin/env YES (db files)
D: Requires: /usr/bin/perl YES (db files)
D: Requires: /usr/bin/php YES (db files)
D: Requires: nagios-plugins NO
D: Requires: perl(Getopt::Long) YES (db provides)
D: Requires: perl(strict) YES (db provides)
D: Requires: policycoreutils-python NO
D: Requires: policycoreutils-python NO (cached)
D: Requires: policycoreutils-python NO
D: Requires: rpmlib(CompressedFileNames) <= 3.0.4-1 YES (rpmlib provides)
D: Requires: rpmlib(FileDigests) <= 4.6.0-1 YES (rpmlib provides)
D: Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 YES (rpmlib provides)
D: Requires: rpmlib(PayloadIsXz) <= 5.2-1 YES (rpmlib provides)
It would seem that the Requires
for the CentOS 6/7 scenario are used, and not those from the CentOS 8 scenario.
What am I not seeing here? Is there anything I can do to debug this?