File opendmarc.spec of Package opendmarc
#
# spec file for package opendmarc
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define upname OpenDMARC
%define libname libopendmarc
%define solibname libopendmarc2
%define support_version 20220318
%define patch_version 2021051301
%define mailgroup mail
%define relname rel-opendmarc-1-4-2
%define tarname OpenDMARC-%{relname}
%if "0%{?_fillupdir}" == "0"
%define _fillupdir %{_localstatedir}/adm/fillup-templates/
%endif
Summary: Domain-based Message Authentication, Reporting & Conformance (DMARC) milter
License: BSD-3-Clause AND Sendmail
Group: System/Daemons
Name: opendmarc
Version: 1.4.2
Release: 0
URL: http://www.trusteddomain.org/%{name}.html
Source0: https://github.com/trusteddomainproject/OpenDMARC/archive/refs/tags/%{relname}.tar.gz#/%{tarname}.tar.gz
Source1: dmarcts-report-parser-%{support_version}.tar.bz2
Source2: dmarcts-report-viewer-%{support_version}.tar.bz2
Source3: opendmarc-dashboard-%{support_version}.tar.bz2
Source4: patches-%{patch_version}.tar.gz
# Script to update support software
Source5: update.sh
Requires(pre): shadow
Requires(pre): group(mail)
Requires: %{solibname} = %{version}
Requires: perl(DBD::mysql)
Requires: perl(DBI)
Requires: perl(Domain::PublicSuffix)
Requires: perl(File::Basename)
Requires: perl(File::Temp)
Requires: perl(Getopt::Long)
Requires: perl(IO::Compress::Zip)
Requires: perl(IO::Handle)
Requires: perl(MIME::Base64)
Requires: perl(Net::Domain)
Requires: perl(Net::SMTP)
Requires: perl(Switch)
Requires: perl(Time::Local)
BuildRequires: autoconf
BuildRequires: libbsd-devel
BuildRequires: libspf2-devel
BuildRequires: libtool
BuildRequires: mysql-devel
BuildRequires: openssl-devel
BuildRequires: pkgconfig
BuildRequires: sendmail-devel
BuildRequires: systemd
%if 0%{?suse_version} > 1600
Provides: group(%{name})
Provides: user(%{name})
%endif
%{?systemd_requires}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
%{upname} (Domain-based Message Authentication, Reporting & Conformance)
provides an open source library that implements the DMARC verification
service plus a milter-based filter application that can plug in to any
milter-aware MTA, including sendmail, Postfix, or any other MTA that supports
the milter protocol.
%package -n %{solibname}
Summary: An open source DMARC library
Group: System/Libraries
%description -n %{solibname}
This package contains the library files required for running services built
using %{libname}.
%package -n %{libname}-devel
Summary: Development files for %{libname}
Group: Development/Libraries/C and C++
Requires: %{solibname} = %{version}-%{release}
%description -n %{libname}-devel
This package contains the static libraries, headers, and other support files
required for developing applications against %{libname}.
%package support
Summary: DMARC support stuff from TechSneeze
Group: System/Monitoring
URL: https://github.com/techsneeze
Version: %{support_version}
Release: 0
Requires: perl(DBD::mysql)
Requires: perl(DBI)
Requires: perl(Getopt::Long)
Requires: perl(IO::Compress::Gzip)
Requires: perl(MIME::Base64)
Requires: perl(MIME::Parser)
Requires: perl(MIME::Parser::Filer)
Requires: perl(MIME::Words)
Requires: perl(Mail::IMAPClient)
Requires: perl(Mail::Mbox::MessageParser)
Requires: perl(PerlIO::gzip)
Requires: perl(Socket)
Requires: perl(Socket6)
Requires: perl(XML::Simple)
%description support
Additional support stuff from TechSneeze.com and John Bieling
dmarcts-report-parser : A Perl based tool to parse DMARC reports,
based on John Levine's rddmarc
dmarcts-report-viewer : A PHP viewer for DMARC records
opendmarc-dashboard : A PHP dashboard to view the opendmarc database information
%prep
%setup -q -n %{tarname} -b1 -b2 -b3 -b4
for patch in ../patches-%{patch_version}/*.patch; do echo $patch; patch -sp1 < $patch; done
# aclocal
# autoconf
autoreconf -vi
sed -i 's/\r//' ../opendmarc-dashboard-%{support_version}/default.css
sed -i 's/\r//' ../dmarcts-report-viewer-%{support_version}/default.css
echo %_fillupdir
%build
# Always use system libtool instead of package-provided one to
# properly handle 32 versus 64 bit detection and settings
%define LIBTOOL LIBTOOL=`which libtool`
%if 0%{?rhel} && 0%{?rhel} == 5
%configure --with-sql-backend --with-spf
%else
%configure --with-sql-backend --with-spf -with-spf2-include=%{_prefix}/include/spf2 --with-spf2-lib=%{_libdir}/libspf2.so --with-sql-backend
%endif
# Remove rpath
%{__sed} -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
%{__sed} -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
%{__make} %{?_smp_mflags} %{LIBTOOL}
%install
%{__make} DESTDIR=%{buildroot} install %{?_smp_mflags} %{LIBTOOL}
%{__mkdir} -p %{buildroot}%{_sysconfdir}
%{__install} -d %{buildroot}%{_fillupdir}
%{__mkdir} -p -m 0755 %{buildroot}%{_sysconfdir}/%{name}
ln -s service %{buildroot}/%{_sbindir}/rc%{name}
%{__cat} > %{buildroot}%{_fillupdir}/sysconfig.%{name} << 'EOF'
# Set the necessary startup options
OPTIONS="-c %{_sysconfdir}/%{name}.conf -P %{_rundir}/%{name}/%{name}.pid"
EOF
%{__install} -d -m 0755 %{buildroot}%{_unitdir}
%{__cat} > %{buildroot}%{_unitdir}/%{name}.service << 'EOF'
[Unit]
Description=Domain-based Message Authentication, Reporting & Conformance (DMARC) Milter
Documentation=man:%{name}(8) man:%{name}.conf(5) man:%{name}-import(8) man:%{name}-reports(8) http://www.trusteddomain.org/%{name}/
After=network.target nss-lookup.target syslog.target
[Service]
Type=forking
PIDFile=%{_rundir}/%{name}/%{name}.pid
EnvironmentFile=-/etc/sysconfig/%{name}
ExecStart=/usr/sbin/%{name} $OPTIONS
ExecReload=/bin/kill -USR1 $MAINPID
RuntimeDirectory=%{name}
RuntimeDirectoryMode=0750
User=%{name}
Group=%{mailgroup}
[Install]
WantedBy=multi-user.target
EOF
# Install and set some basic settings in the default config file
%{__install} -m 0644 %{name}/%{name}.conf.sample %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|^# AuthservID name |AuthservID HOSTNAME |' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|^# HistoryFile /.*|# HistoryFile %{_localstatedir}/spool/%{name}/%{name}.dat|' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|^# Socket |Socket |' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|^# SoftwareHeader false|SoftwareHeader true|' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|^# SPFIgnoreResults false|SPFIgnoreResults true|' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|^# SPFSelfValidate false|SPFSelfValidate true|' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|^# Syslog false|Syslog true|' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|^# UMask 077|UMask 007|' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|^# UserID %{name}|UserID %{name}:%{mailgroup}|' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i 's|/usr/local||' %{buildroot}%{_sysconfdir}/%{name}.conf
%{__rm} -rf %{buildroot}%{_prefix}/share/doc/%{name}
%{__rm} %{buildroot}%{_libdir}/*.{la,a}
%{__mkdir} -p %{buildroot}%{_includedir}/%{name}
%{__install} -m 0644 lib%{name}/dmarc.h %{buildroot}%{_includedir}/%{name}/
%{__mkdir} -p %{buildroot}%{_localstatedir}/spool/%{name}
%{__mkdir} -p %{buildroot}%{_docdir}/%{name}/rddmarc
%{__install} -m 0644 contrib/rddmarc/README.rddmarc %{buildroot}%{_docdir}/%{name}/rddmarc/
%{__install} -m 0644 contrib/rddmarc/mkdmarc %{buildroot}%{_docdir}/%{name}/rddmarc/
%{__install} -m 0755 contrib/rddmarc/rddmarc %{buildroot}%{_docdir}/%{name}/rddmarc/
sed -i s_/usr/local/bin/python_/usr/bin/python_ contrib/rddmarc/dmarcfail.py
%{__install} -m 0755 contrib/rddmarc/dmarcfail.py %{buildroot}%{_docdir}/%{name}/rddmarc/
for i in dmarcts-report-parser dmarcts-report-viewer opendmarc-dashboard
do
%{__mkdir} -p %{buildroot}%{_docdir}/%{name}-support/$i
cp -r ../$i-%{support_version}/* %{buildroot}%{_docdir}/%{name}-support/$i
done
%pre
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || \
useradd -r -g %{name} -G %{mailgroup} -d %{_localstatedir}/spool/%{name} -s /sbin/nologin \
-c "%{upname} Milter" %{name}
%service_add_pre %{name}.service
exit 0
%post
%service_add_post %{name}.service
%{fillup_only opendmarc}
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
%post -n %{solibname} -p /sbin/ldconfig
%postun -n %{solibname} -p /sbin/ldconfig
%clean
%{__rm} -rf %{buildroot}
%files
%doc LICENSE LICENSE.Sendmail
%doc README RELEASE_NOTES
%doc db/README.schema db/schema.mysql
%doc db/README.update-db-schema.mysql db/update-db-schema.mysql
%doc SECURITY
%{_docdir}/%{name}/rddmarc
%config(noreplace) %{_sysconfdir}/%{name}.conf
%dir %{_fillupdir}
%{_fillupdir}/sysconfig.%{name}
%{_sbindir}/*
%{_mandir}/*/*
%dir %attr(-,%{name},%{name}) %{_localstatedir}/spool/%{name}
%ghost %{_localstatedir}/spool/%{name}/%{name}.dat
%dir %attr(-,%{name},%{name}) %{_sysconfdir}/%{name}
%attr(0644,root,root) %{_unitdir}/%{name}.service
%files -n %{solibname}
%{_libdir}/lib%{name}.so.*
%files -n %{libname}-devel
%doc lib%{name}/docs/*.html
%{_includedir}/%{name}
%{_libdir}/*.so
%files support
%dir %{_docdir}/%{name}-support
%{_docdir}/%{name}-support/dmarcts*
%{_docdir}/%{name}-support/opendmarc-dashboard
%changelog