%global build_options -DGENERATE_SRS_SECRET=OFF -DUSE_SELINUX=ON -DINIT_FLAVOR=systemd %undefine __cmake_in_source_build Name: postsrsd Version: 1.12.jf1 Release: 2%{?dist} Summary: Sender Rewriting Scheme (SRS) provider License: GPLv2+ URL: https://github.com/jeredfloyd/%{name} Source0: https://github.com/jeredfloyd/%{name}/archive/%{version}/%{name}-%{version}.tar.gz BuildRequires: make %if (0%{?rhel} && 0%{?rhel} < 8) BuildRequires: cmake3 %else BuildRequires: cmake %endif BuildRequires: gcc BuildRequires: help2man BuildRequires: selinux-policy-devel %if (0%{?rhel} && 0%{?rhel} < 8) BuildRequires: sendmail-devel %else BuildRequires: sendmail-milter-devel %endif %{?systemd_requires} BuildRequires: systemd Requires: sendmail-milter Requires(post): policycoreutils Requires(preun): policycoreutils Requires(postun): policycoreutils %description PostSRSd provides the Sender Rewriting Scheme (SRS) via TCP-based lookup tables for Postfix. SRS is needed if your mail server acts as forwarder. %prep %if (0%{?rhel} && 0%{?rhel} < 8) mkdir ~/bin ln -s /usr/bin/cmake3 ~/bin/cmake %define cmake cmake %endif %autosetup -n %{name}-%{version} %build %if (0%{?rhel} && 0%{?rhel} < 8) export PATH=~/bin:$PATH mkdir -p _build cd _build && cmake .. %build_options -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-std=gnu99 $CFLAGS" -DCMAKE_INSTALL_PREFIX=%{_prefix} cd .. %else %cmake %build_options %endif %if (0%{?rhel} && 0%{?rhel} < 8) make %else %cmake_build %endif %install %if (0%{?rhel} && 0%{?rhel} < 8) export PATH=~/bin:$PATH %make_install %else %cmake_install %endif # %%ghost file requires it is present in the build root touch %{buildroot}/%{_sysconfdir}/postsrsd.secret # proper location for systemd config mkdir -p %{buildroot}/%{_unitdir} mv %{buildroot}/%{_sysconfdir}/systemd/system/postsrsd.service %{buildroot}/%{_unitdir}/postsrsd.service rm -rf %{buildroot}/%{_sysconfdir}/systemd # chroot directory # (also move default config which is in the way) sed -i 's/^CHROOT=.*/CHROOT=\/run\/postsrsd/' %{buildroot}/%{_sysconfdir}/default/%{name} sed -ri -e 's/postsrsd\/default/postsrsd.default/' \ -e "s/(\[Install\])/RuntimeDirectory=postsrsd\nRuntimeDirectoryMode=0750\n\n\1/" %{buildroot}/%{_unitdir}/postsrsd.service %files %license LICENSE %ghost %{_sysconfdir}/postsrsd.secret %config(noreplace) %{_sysconfdir}/default/%{name} %{_unitdir}/postsrsd.service %{_sbindir}/postsrsd %{_docdir}/%{name} %{_mandir}/man8/postsrsd.8.gz %{_datadir}/selinux/packages/%{name}/postsrsd.pp %{_datadir}/postsrsd/postsrsd-systemd-launcher %post if [ "$1" -le "1" ] ; then # first install semodule -i %{_datadir}/selinux/packages/%{name}/postsrsd.pp || true fixfiles -R %{name} restore || true fi [ -f %{_sysconfdir}/postsrsd.secret ] || dd if=/dev/urandom bs=18 count=1 2>/dev/null | base64 >%{_sysconfdir}/postsrsd.secret # the admin may modify / restore from a backup, so better restore SELinux permissions unconditionally restorecon %{_sysconfdir}/postsrsd.secret %systemd_post %{name}.service %preun %systemd_preun %{name}.service if [ "$1" -lt "1" ] ; then # final removal semodule -r postsrsd 2>/dev/null || true fi %postun if [ "$1" -ge "1" ] ; then # upgrade semodule -i %{_datadir}/selinux/packages/%{name}/postsrsd.pp || true fixfiles -R %{name} restore || true fi %systemd_postun_with_restart %{name}.service #if [ "$1" -eq "0" ] ; then # final removal #fi %changelog * Mon Nov 28 2022 Jered Floyd 1.12.jf1-2 - Don't blow away config file * Mon Nov 28 2022 Jered Floyd 1.12.jf1-1 - Sync with upstream 1.12 * Thu May 5 2022 Jered Floyd 1.11.jf1-1 - Personal branch incorporating milter-service patches - Fix builds on EL7 and F36+ * Fri Jan 21 2022 Fedora Release Engineering - 1.11-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild * Fri Jul 23 2021 Fedora Release Engineering - 1.11-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild * Tue Mar 23 2021 Marc Dequènes (Duck) - 1.11-1 - NUR * Fri Mar 19 2021 Alexander Boström - 1.10-0.1 - Update to 1.10 - adds postsrsd-systemd-launcher wrapper script * Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek - 1.6-3 - Rebuilt for updated systemd-rpm-macros See https://pagure.io/fesco/issue/2583. * Wed Jan 27 2021 Fedora Release Engineering - 1.6-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild * Tue Oct 06 2020 Marc Dequènes (Duck) - 1.6-1 - NUR - define INIT_FLAVOR as detection does not work in build environment - ensure build in not done in-source - add gcc to BuildRequires (removing it was a mistake) - add compat for EL7 around cmake_* macros * Thu Aug 13 2020 Marc Dequènes (Duck) - 1.4-10.20170118gita77bf99 - migrate to new cmake macros for out-of-source builds * Thu Oct 05 2017 Marc Dequènes (Duck) - 1.4-9.20170118gita77bf99 - use the %%ghost feature to ensure the secret file is owned by the package - it is then not necessary to handle its removal in %%postun * Thu Sep 28 2017 Marc Dequènes (Duck) - 1.4-8.20170118gita77bf99 - Thanks Matthias Runge Mauchin for the review - break description line too long - build dependency on gcc is not needed * Wed Sep 27 2017 Marc Dequènes (Duck) - 1.4-7.20170118gita77bf99 - make the changelog more readable - stop recreating buildroot, it is made clean already * Wed Aug 23 2017 Marc Dequènes (Duck) - 1.4-6.20170118gita77bf99 - remove unnecessary Requires on make - use _sysconfdir macro - use name macro when it makes sense - remove unnecessary %%doc as the buildsys already populates docdir * Tue Aug 22 2017 Marc Dequènes (Duck) - 1.4-5.20170118gita77bf99 - remove %%clean section, not needed in Fedora * Tue Aug 22 2017 Marc Dequènes (Duck) - 1.4-4.20170118gita77bf99 - don't remove secret file during upgrade - start service at the end of post scriptlet - improve SELinux rules handling (now requires a running SELinux) * Tue Aug 22 2017 Marc Dequènes (Duck) - 1.4-3.20170118gita77bf99 - Thanks Robert-André Mauchin for the review - snapshot is packaged to get this necessary fix: https://github.com/roehling/postsrsd/pull/65 - fixed version - fixed source URL - use macros for standard paths and build steps - add missing systemd scriptlets - specify doc and license files - remove unnecessary Requires on base64 - remove Group information unsupported in Fedora * Fri Apr 14 2017 Marc Dequènes (Duck) - 1.4-2 - create /etc/postsrsd.secret if missing - move systemd config into directory for packages - move chroot directory into /run - autocreate chroot directory * Thu Mar 30 2017 Marc Dequènes (Duck) - 1.4-1 - initial packaging