view sm-archive.spec.in @ 23:37793d4c90a0

changes for rhel7 systemd and /var/run on tmpfs
author Carl Byington <carl@five-ten-sg.com>
date Mon, 06 Feb 2017 10:45:07 -0800
parents 09564d4acd9e
children 7d599c9b7d65
line wrap: on
line source

%define localstatedir   /var/lib

Summary:            @PACKAGE@ Sendmail Milter
Name:               @PACKAGE@
Version:            @VERSION@
Release:            1%{?dist}
License:            GPLv3+
Group:              System Environment/Daemons
Source:             http://www.five-ten-sg.com/%{name}/packages/%{name}-%{version}.tar.gz
BuildRoot:          %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
URL:                http://www.five-ten-sg.com/%{name}/

Requires(pre):          /usr/sbin/useradd
Requires(pre):          /usr/bin/getent
Requires(postun):       /usr/sbin/userdel
Requires(post,preun):   /sbin/chkconfig
Requires(post,preun):   /sbin/service
BuildRequires:          sendmail-devel >= 8.12.1
Requires:               sendmail >= 8.12.1
Requires:               sendmail-cf
%if "%{?dist}" == ".el7"
Requires(pre):  systemd-sysv, shadow-utils
Requires(post): systemd-units
Requires(preun):  systemd-units
Requires(postun): systemd-units
Requires:       coreutils
Requires:       systemd-units
BuildRequires:  systemd-units
%endif

%description
This milter adds recipient addresses to messages passing thru it, based
on a configuration file.

The sm-archive milter reads a text configuration file
(sm-archive.conf) on startup, and whenever the config file (or any of
the referenced include files) is changed. The entire configuration
file is case insensitive.


%prep
%setup -q


%build
%configure
make %{?_smp_mflags}

%install
rm -rf %{buildroot}
make DESTDIR=%{buildroot} install
%if "%{?dist}" == ".el7"
install -m 644 -D %{buildroot}%{_sysconfdir}/%{name}/%{name}.service \
    %{buildroot}%{_unitdir}/%{name}.service
install -m 755 -d %{buildroot}%{_prefix}/lib/tmpfiles.d
install -m 644    %{buildroot}%{_sysconfdir}/%{name}/%{name}-tmpfs.conf \
    %{buildroot}%{_prefix}/lib/tmpfiles.d/%{name}.conf
%else
install -m 755 -D %{buildroot}%{_sysconfdir}/%{name}/%{name} \
    %{buildroot}%{_initrddir}/%{name}
%endif
mkdir -p %{buildroot}/var/run/%{name}
rm -f  %{buildroot}%{_sysconfdir}/%{name}/%{name}
rm -f  %{buildroot}%{_sysconfdir}/%{name}/%{name}.service
rm -f  %{buildroot}%{_sysconfdir}/%{name}/%{name}-tmpfs.conf


%pre
/usr/bin/getent passwd sm-archive >/dev/null || useradd -r -d /etc/sm-archive -M -c "sm-archive pseudo-user" -s /sbin/nologin sm-archive >/dev/null


%post
if [ $1 = 1 ]; then
    # initial install
%if "%{?dist}" == ".el7"
    /bin/systemctl daemon-reload &>/dev/null || :
%else
    /sbin/chkconfig --add %{name}
    echo Remember to edit %{_sysconfdir}/%{name}/%{name}.conf and add the following line to your sendmail.mc:
    echo "INPUT_MAIL_FILTER(\`sm-archive', \`S=local:/var/run/sm-archive/sm-archive.sock, F=T, T=C:30s;S:5m;R:5m;E:5m')"
    echo
%endif
fi


%preun
if [ $1 = 0 ]; then
    # package removal, not upgrade
%if "%{?dist}" == ".el7"
    /bin/systemctl --no-reload disable %{name}.service &>/dev/null || :
    /bin/systemctl stop %{name}.service &>/dev/null || :
%else
    /sbin/service %{name} stop || :
    /sbin/chkconfig --del %{name}
%endif
userdel %{name} || :
fi


%postun
if [ $1 -ge 1 ]; then
    # package upgrade, not uninstall
%if "%{?dist}" == ".el7"
    /bin/systemctl try-restart %{name}.service &>/dev/null || :
%else
    /sbin/service %{name} restart || :
%endif
fi


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%{_sbindir}/*
%{_mandir}/man1/*
%{_mandir}/man5/*
%docdir %{_datadir}/doc/%{name}-%{version}
%{_datadir}/doc/%{name}-%{version}
%config(noreplace) %attr(0750,%{name},root) %{_sysconfdir}/%{name}
%if "%{?dist}" == ".el7"
%{_prefix}/lib/tmpfiles.d/%{name}.conf
%{_unitdir}/%{name}.service
%else
%{_initrddir}/%{name}
%endif
%dir %attr(0750,%{name},root) /var/run/%{name}


%changelog
* Mon Feb 06 2017 Carl Byington <carl@five-ten-sg.com> - 1.9-1
- enable rhel7 systemd and /var/run is on tmpfs

* Fri Dec 24 2010 Carl Byington <carl@five-ten-sg.com> - 1.8-1
- patches from Marco d'Itri for postfix

* Thu Jun 12 2008 Carl Byington <carl@five-ten-sg.com> - 1.7-1
- Fedora 9 compile and const correctness.

* Fri Mar 21 2008 Carl Byington <carl@five-ten-sg.com> - 1.6-1
- changes for Fedora packaging guidelines

* Fri Mar 10 2006 Carl Byington <carl@five-ten-sg.com> -1.0
- use autoconf and http://www.fedora.us/docs/rpm-packaging-guidelines.html