%global with_selinux 1 %global modulename postfix-sasl-xoauth2 %global selinuxtype targeted Name: sasl-xoauth2 Version: 0.19 Release: 1%{?dist} Summary: The xoauth2 plugin for cyrus-sasl License: ASL 2.0 URL: https://github.com/tarickb/%{name} Source0: https://github.com/tarickb/%{name}/archive/refs/tags/release-%{version}.tar.gz Source1: %{modulename}.te Source2: %{modulename}.if Source3: %{modulename}.fc BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: libcurl-devel %if 0%{?rhel} < 8 BuildRequires: cmake3 %else BuildRequires: cmake %endif BuildRequires: cyrus-sasl-devel BuildRequires: jsoncpp-devel BuildRequires: sqlite-devel Requires: cyrus-sasl-lib %if 0%{?with_selinux} # This ensures that the *-selinux package and all its dependencies are not pulled # into containers and other systems that do not use SELinux Requires: (%{name}-selinux if selinux-policy-%{selinuxtype}) %endif %description sasl-xoauth2 is a SASL plugin that enables client-side use of OAuth 2.0. Among other things it enables the use of Gmail or Outlook/Office 365 SMTP relays from Postfix. %if 0%{?with_selinux} # SELinux subpackage %package selinux Summary: The sasl-xoauth2 SELinux policy BuildArch: noarch Requires: selinux-policy-%{selinuxtype} Requires(post): selinux-policy-%{selinuxtype} BuildRequires: selinux-policy-devel %{?selinux_requires} %description selinux Custom SELinux policy module %endif %prep %setup -q -n %{name}-release-%{version} %build %if 0%{?rhel} < 8 %cmake3 -DCMAKE_INSTALL_SYSCONFDIR=%{_sysconfdir} %cmake3_build %else %cmake -DCMAKE_INSTALL_SYSCONFDIR=%{_sysconfdir} %cmake_build %endif %if 0%{?with_selinux} # SELinux policy (originally from selinux-policy-contrib) # this policy module will override the production module mkdir selinux cp -p %{SOURCE1} selinux/ cp -p %{SOURCE2} selinux/ cp -p %{SOURCE3} selinux/ make -f %{_datadir}/selinux/devel/Makefile %{modulename}.pp bzip2 -9 %{modulename}.pp %endif %install %if 0%{?rhel} < 8 %cmake3_install %else %cmake_install %endif %if 0%{?with_selinux} install -D -m 0644 %{modulename}.pp.bz2 %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}/%{modulename}.pp.bz2 install -D -p -m 0644 selinux/%{modulename}.if %{buildroot}%{_datadir}/selinux/devel/include/distributed/%{modulename}.if %endif %if 0%{?with_selinux} # SELinux contexts are saved so that only affected files can be # relabeled after the policy module installation %pre selinux %selinux_relabel_pre -s %{selinuxtype} %post selinux %selinux_modules_install -s %{selinuxtype} %{_datadir}/selinux/packages/%{selinuxtype}/%{modulename}.pp.bz2 %postun selinux if [ $1 -eq 0 ]; then %selinux_modules_uninstall -s %{selinuxtype} %{modulename} fi %posttrans selinux %selinux_relabel_post -s %{selinuxtype} # if with_selinux %endif %files %doc README.md %license COPYING %{_libdir}/sasl-xoauth2/test-config %{_libdir}/sasl2/libsasl-xoauth2.so %{_bindir}/sasl-xoauth2-tool %config(noreplace) %{_sysconfdir}/sasl-xoauth2.conf %if 0%{?with_selinux} %files selinux %{_datadir}/selinux/packages/%{selinuxtype}/%{modulename}.pp.* %{_datadir}/selinux/devel/include/distributed/%{modulename}.if %ghost %verify(not md5 size mode mtime) %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{modulename} %endif %changelog * Mon Apr 17 2023 Jakub Jelen - 0.19-1 - First package in Fedora