Skip to content

Commit

Permalink
selinux: switch to conditional dependency
Browse files Browse the repository at this point in the history
This ensures that the pcp-selinux package and all it's dependencies are
not pulled into containers and other systems that do not use SELinux.
https://fedoraproject.org/wiki/SELinux/IndependentPolicy#Adding_dependency_to_the_spec_file_of_corresponding_package

This rpm syntax is called "boolean dependencies" and is supported since rpm 4.13 (>= RHEL 8).
https://rpm-software-management.github.io/rpm/manual/boolean_dependencies.html

Co-authored-by: Vit Mojzis <vmojzis@redhat.com>
Resolves: rhbz#2050838
  • Loading branch information
2 people authored and natoscott committed Mar 16, 2022
1 parent de7801f commit d42ec30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions build/rpm/pcp.spec.in
Expand Up @@ -220,9 +220,18 @@ fi
}

%if "@enable_selinux@" == "true"

# rpm boolean dependencies are supported since RHEL 8
%if 0%{?fedora} >= 35 || 0%{?rhel} >= 8
# This ensures that the pcp-selinux package and all it's dependencies are not pulled
# into containers and other systems that do not use SELinux
Requires: (pcp-selinux = @package_version@ if selinux-policy-targeted)
%else
Requires: pcp-selinux = @package_version@
%endif

%endif

Requires: pcp-libs = @package_version@

%description
Expand Down
9 changes: 9 additions & 0 deletions build/rpm/redhat.spec
Expand Up @@ -286,9 +286,18 @@ BuildRequires: qt5-qtsvg-devel
Requires: bash xz gawk sed grep findutils which %{_hostname_executable}
Requires: pcp-libs = %{version}-%{release}
%if !%{disable_selinux}

# rpm boolean dependencies are supported since RHEL 8
%if 0%{?fedora} >= 35 || 0%{?rhel} >= 8
# This ensures that the pcp-selinux package and all it's dependencies are not pulled
# into containers and other systems that do not use SELinux
Requires: (pcp-selinux = %{version}-%{release} if selinux-policy-targeted)
%else
Requires: pcp-selinux = %{version}-%{release}
%endif

%endif

%global _confdir %{_sysconfdir}/pcp
%global _logsdir %{_localstatedir}/log/pcp
%global _pmnsdir %{_localstatedir}/lib/pcp/pmns
Expand Down

0 comments on commit d42ec30

Please sign in to comment.