%global debug_package %{nil} %global pgmajorversion 95 %global pginstdir /usr/pgsql-9.5 %global sname postgresql Summary: A PostgreSQL SELinux-context Name: %{sname}%{pgmajorversion}-selinux Version: 1.0 Release: 2PGDG%{?dist} Group: Applications/Databases License: PostgreSQL URL: http://www.postgresql.org Source0: %{name}-%{version}.tar.bz2 Source1: README.%{name} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root Requires: postgresql%{pgmajorversion} Requires: policycoreutils BuildRequires: postgresql%{pgmajorversion}-devel BuildRequires: postgresql%{pgmajorversion} BuildRequires: checkpolicy BuildRequires: selinux-policy-devel %description Provides a SELinux-policy to run PostgreSQL under the correct SELinux-context. %prep %setup -q -n %{name}-%{version} install -m 644 -D %{SOURCE1} README ln -s %{_datadir}/selinux/devel/Makefile . %build %{__make} %install %{__rm} -rf %{buildroot} install -p -m 644 -D %{sname}%{pgmajorversion}.pp %{buildroot}/etc/selinux/targeted/modules/active/%{sname}%{pgmajorversion}.pp %post if [ "$1" -le "1" ] ; then # First install /usr/sbin/semodule -i /etc/selinux/targeted/modules/active/%{sname}%{pgmajorversion}.pp &> /dev/null || : /usr/sbin/restorecon -FR %{pginstdir} fi %preun if [ "$1" -lt "1" ] ; then # Final removal /usr/sbin/semodule -r %{sname}%{pgmajorversion} 2>/dev/null || : /usr/sbin/restorecon -FR %{pginstdir} fi %postun if [ "$1" -ge "1" ] ; then # Upgrade /usr/sbin/semodule -i /etc/selinux/targeted/modules/active/%{sname}%{pgmajorversion}.pp &> /dev/null || : /usr/sbin/restorecon -FR %{pginstdir} fi %clean %{__rm} -rf %{buildroot} %files %defattr(-,root,root,-) %doc README /etc/selinux/targeted/modules/active/%{sname}%{pgmajorversion}.pp %changelog * Sat Jun 04 2016 Andreas Dijkman 1.0-2 - Included README * Fri Jun 03 2016 Andreas Dijkman 1.0-1 - Initial RPM