Try to fix labeling of selinux modules

related: RHEL-24924
This commit is contained in:
Andreas Schneider 2024-02-09 14:09:12 +01:00
parent 6517e1644f
commit fb2f282c08

View File

@ -1,5 +1,6 @@
%bcond_without selinux %bcond_without selinux
%global selinux_variants targeted %global selinux_variants targeted
%global selinuxtype targeted
%global selinux_package_dir %{_datadir}/selinux/packages %global selinux_package_dir %{_datadir}/selinux/packages
%global logdir %{_localstatedir}/log/%{name} %global logdir %{_localstatedir}/log/%{name}
@ -7,7 +8,7 @@
Name: cepces Name: cepces
Version: 0.3.8 Version: 0.3.8
Release: 3%{?dist} Release: 4%{?dist}
Summary: Certificate Enrollment through CEP/CES Summary: Certificate Enrollment through CEP/CES
License: GPL-3.0-or-later License: GPL-3.0-or-later
@ -20,12 +21,12 @@ BuildArch: noarch
Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release} Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release}
%if %{with selinux} %if %{with selinux}
Requires: (%{name}-selinux%{?_isa} if selinux-policy-%{selinuxtype}) Requires: (%{name}-selinux if selinux-policy-%{selinuxtype})
%endif %endif
Recommends: logrotate Recommends: logrotate
Supplements: %{name}-certmonger%{?_isa} = %{version}-%{release} Supplements: %{name}-certmonger = %{version}-%{release}
%description %description
cepces is an application for enrolling certificates through CEP and CES. cepces is an application for enrolling certificates through CEP and CES.
@ -70,8 +71,8 @@ Summary: SELinux support for %{name}
BuildRequires: selinux-policy-devel BuildRequires: selinux-policy-devel
Requires: %{name} = %{version}-%{release} Requires: %{name} = %{version}-%{release}
Requires: selinux-policy Requires: selinux-policy-%{selinuxtype}
Requires(post): selinux-policy-targeted Requires(post): selinux-policy-%{selinuxtype}
%description selinux %description selinux
SELinux support for %{name} SELinux support for %{name}
@ -88,7 +89,7 @@ SELinux support for %{name}
# Build the SELinux module(s). # Build the SELinux module(s).
for SELINUXVARIANT in %{selinux_variants}; do for SELINUXVARIANT in %{selinux_variants}; do
make %{?_smp_mflags} -C selinux clean all make %{?_smp_mflags} -C selinux clean all
mv -v selinux/%{name}.pp selinux/%{name}-${SELINUXVARIANT}.pp mv -v selinux/%{modulename}.pp selinux/%{modulename}-${SELINUXVARIANT}.pp
done done
%endif %endif
@ -103,12 +104,12 @@ rm -fv selinux-files.txt
for SELINUXVARIANT in %{selinux_variants}; do for SELINUXVARIANT in %{selinux_variants}; do
install -d -m 755 %{buildroot}%{selinux_package_dir}/${SELINUXVARIANT} install -d -m 755 %{buildroot}%{selinux_package_dir}/${SELINUXVARIANT}
bzip2 selinux/%{name}-${SELINUXVARIANT}.pp bzip2 selinux/%{modulename}-${SELINUXVARIANT}.pp
MODULE_PATH=%{selinux_package_dir}/${SELINUXVARIANT}/%{modulename}.pp.bz2 MODULE_PATH=%{selinux_package_dir}/${SELINUXVARIANT}/%{modulename}.pp.bz2
install -p -m 644 selinux/%{name}-${SELINUXVARIANT}.pp.bz2 \ install -p -m 644 selinux/%{name}-${SELINUXVARIANT}.pp.bz2 \
%{buildroot}$MODULE_PATH %{buildroot}${MODULE_PATH}
echo $MODULE_PATH >> selinux-files.txt echo ${MODULE_PATH} >> selinux-files.txt
done done
#endif with selinux #endif with selinux
%endif %endif
@ -134,30 +135,28 @@ EOF
ln -s tests/cepces_test . ln -s tests/cepces_test .
%{__python3} setup.py test %{__python3} setup.py test
%if %{with selinux}
%pre selinux %pre selinux
for SELINUXVARIANT in %{selinux_variants}; do for SELINUXVARIANT in %{selinux_variants}; do
%selinux_relabel_pre -s %{SELINUXVARIANT} %selinux_relabel_pre -s ${SELINUXVARIANT}
done done
%if %{with selinux}
%post selinux %post selinux
semodule -d %{modulename} &> /dev/null || true;
for SELINUXVARIANT in %{selinux_variants}; do for SELINUXVARIANT in %{selinux_variants}; do
MODULE_PATH=%{selinux_package_dir}/${SELINUXVARIANT}/%{modulename}.pp.bz2 MODULE_PATH=%{selinux_package_dir}/${SELINUXVARIANT}/%{modulename}.pp.bz2
%selinux_modules_install -s %{SELINUXVARIANT} ${MODULE_PATH} %selinux_modules_install -s ${SELINUXVARIANT} ${MODULE_PATH}
done done
%postun selinux %postun selinux
if [ $1 -eq 0 ]; then if [ $1 -eq 0 ]; then
for SELINUXVARIANT in %{selinux_variants}; do for SELINUXVARIANT in %{selinux_variants}; do
%selinux_modules_uninstall -s %{SELINUXVARIANT} %{modulename} %selinux_modules_uninstall -s ${SELINUXVARIANT} %{modulename}
semodule -e %{modulename} &> /dev/null || true;
done done
fi fi
%posttrans selinux %posttrans selinux
for SELINUXVARIANT in %{selinux_variants}; do for SELINUXVARIANT in %{selinux_variants}; do
%selinux_relabel_post -s %{SELINUXVARIANT} %selinux_relabel_post -s ${SELINUXVARIANT}
done done
#endif with selinux #endif with selinux
%endif %endif
@ -197,7 +196,7 @@ fi
%endif %endif
%changelog %changelog
* Fri Feb 09 2024 Andreas Schneider <asn@redhat.com> - 0.3.8-3 * Fri Feb 09 2024 Andreas Schneider <asn@redhat.com> - 0.3.8-4
- resolves: RHEL-24924 - Fix requirement on cepces-selinux - resolves: RHEL-24924 - Fix requirement on cepces-selinux
* Tue Jan 30 2024 Andreas Schneider <asn@redhat.com> - 0.3.8-1 * Tue Jan 30 2024 Andreas Schneider <asn@redhat.com> - 0.3.8-1