Use RPM's build conditionals to control which policy types to build

Instead of plain macros, use `%bcond ...` and `%{with ...}`, which will
allow controlling which policy types to build using the --with/--without
command-line arguments when calling `rpmbuild` or `mock`.

See also:
https://rpm-software-management.github.io/rpm/manual/conditionalbuilds.html

Note that the BUILD_DOC macro is removed without replacement as it's
unused. (The builds of the -doc and -devel subpackages overlap too much
for the macro to be useful, anyway.)

Signed-off-by: Ondrej Mosnáček <omosnacek@gmail.com>

Related: RHEL-54303
This commit is contained in:
Ondrej Mosnáček 2023-01-27 17:03:38 +01:00 committed by Petr Lautrbach
parent d0e15905f2
commit 3d9c5beb8f

View File

@ -1,3 +1,8 @@
# Conditionals for policy types (all built by default)
%bcond targeted 1
%bcond minimum 1
%bcond mls 1
# github repo with selinux-policy sources
%global giturl https://github.com/fedora-selinux/selinux-policy
%global commit e464c3bb967763b8bfac50769b72159d040088b9
@ -6,18 +11,7 @@
%define distro redhat
%define polyinstatiate n
%define monolithic n
%if %{?BUILD_DOC:0}%{!?BUILD_DOC:1}
%define BUILD_DOC 1
%endif
%if %{?BUILD_TARGETED:0}%{!?BUILD_TARGETED:1}
%define BUILD_TARGETED 1
%endif
%if %{?BUILD_MINIMUM:0}%{!?BUILD_MINIMUM:1}
%define BUILD_MINIMUM 1
%endif
%if %{?BUILD_MLS:0}%{!?BUILD_MLS:1}
%define BUILD_MLS 1
%endif
%define POLICYVER 33
%define POLICYCOREUTILSVER 3.4-1
%define CHECKPOLICYVER 3.2
@ -455,7 +449,7 @@ install -m 755 %{SOURCE39} %{buildroot}%{_sysconfdir}/dnf/protected.d/
# Install devel
make clean
%if %{BUILD_TARGETED}
%if %{with targeted}
# Build targeted policy
%makeCmds targeted mcs allow
%makeModulesConf targeted base contrib
@ -470,7 +464,7 @@ mv sandbox.pp %{buildroot}%{_datadir}/selinux/packages/sandbox.pp
%nonBaseModulesList targeted
%endif
%if %{BUILD_MINIMUM}
%if %{with minimum}
# Build minimum policy
%makeCmds minimum mcs allow
%makeModulesConf targeted base contrib
@ -480,7 +474,7 @@ rm -rf %{buildroot}%{_sharedstatedir}/selinux/minimum/active/modules/100/sandbox
%nonBaseModulesList minimum
%endif
%if %{BUILD_MLS}
%if %{with mls}
# Build mls policy
%makeCmds mls mls deny
%makeModulesConf mls base contrib
@ -574,7 +568,7 @@ if [ $1 = 0 ]; then
fi
exit 0
%if %{BUILD_TARGETED}
%if %{with targeted}
%package targeted
Summary: SELinux targeted policy
Provides: selinux-policy-any = %{version}-%{release}
@ -678,7 +672,7 @@ exit 0
%verify(not md5 size mtime) %{_sharedstatedir}/selinux/targeted/active/modules/100/permissivedomains
%endif
%if %{BUILD_MINIMUM}
%if %{with minimum}
%package minimum
Summary: SELinux minimum policy
Provides: selinux-policy-any = %{version}-%{release}
@ -782,7 +776,7 @@ exit 0
%fileList minimum
%endif
%if %{BUILD_MLS}
%if %{with mls}
%package mls
Summary: SELinux MLS policy
Provides: selinux-policy-any = %{version}-%{release}