Blob Blame History Raw
%global systemd (0%{?fedora} >= 18) || (0%{?rhel} >= 7)
%global tmpfiles (0%{?fedora} >= 15) || (0%{?rhel} >= 7)

%global pre_rel Beta0

Summary: An open source library and milter for providing ARC service
Name: openarc
#Version: 0.1.0
Version: 1.0.0
Release: %{?pre_rel:0.}1%{?pre_rel:.%pre_rel}%{?dist}
License: BSD and Sendmail
URL: https://github.com/trusteddomainproject/OpenARC

Source0: https://github.com/trusteddomainproject/OpenARC/archive/v%{version}%{?pre_rel:.%pre_rel}/%{name}-%{version}%{?pre_rel:.%pre_rel}.tar.gz
# https://github.com/trusteddomainproject/OpenARC/pull/104
Patch0: 0001-openarc-header-leading-space.patch
# replace obsolete AC_PROC_LIBTOOL with LT_INIT
Patch1: replace-obsolete-ac-proc-libtool.patch

BuildRequires: libtool gcc
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(libbsd)

# sendmail-devel renamed for F25+
%if 0%{?fedora} > 25
BuildRequires: sendmail-milter-devel
%else
BuildRequires: sendmail-devel
%endif

BuildRequires: autoconf
BuildRequires: automake

Requires: lib%{name}%{?_isa} = %{version}-%{release}
Requires: libopenarc = %{version}-%{release}
Requires(pre): shadow-utils
%if %systemd
# Required for systemd
%{?systemd_requires}
BuildRequires: systemd
%else
# Required for SysV
Requires(post): chkconfig
Requires(preun): chkconfig, initscripts
Requires(postun): initscripts
%endif


%description
The Trusted Domain Project is a community effort to develop and maintain a
C library for producing ARC-aware applications and an open source milter for
providing ARC service through milter-enabled MTAs.

%package -n libopenarc
Summary: An open source ARC library

%description -n libopenarc
This package contains the library files required for running services built
using libopenarc.

%package -n libopenarc-devel
Summary: Development files for libopenarc
Requires: lib%{name}%{?_isa} = %{version}-%{release}

%description -n libopenarc-devel
This package contains the static libraries, headers, and other support files
required for developing applications against libopenarc.

%prep
%autosetup -n OpenARC-%{version}%{?pre_rel:.%pre_rel} -p1

%build
autoreconf --install
%configure --disable-static
%make_build

%install
%make_install
mkdir -p %{buildroot}%{_sysconfdir}
mkdir -p -m 0700 %{buildroot}%{_localstatedir}/run/%{name}
rm -r %{buildroot}%{_prefix}/share/doc/openarc
rm %{buildroot}/%{_libdir}/*.la


cat > %{buildroot}%{_sysconfdir}/openarc.conf <<EOF
## See openarc.conf(5) or %{_docdir}/%{name}-%{version}/openarc.conf.sample for more
PidFile %{_localstatedir}/run/openarc/openarc.pid
Syslog  yes
#Umask   002
UserID  openarc:openarc
Socket  inet:8894@localhost

## After setting Mode to "sv", running
## opendkim-genkey -D %{_sysconfdir}/openarc -s key -d `hostname --domain`
## and putting %{_sysconfdir}/openarc
#Canonicalization        relaxed/simple
#Domain                  example.com # change to domain
#Selector                key
#KeyFile                 %{_sysconfdir}/openarc/key.private
#SignatureAlgorithm rsa-sha256
EOF


%if %systemd
install -d -m 0755 %{buildroot}%{_unitdir}
cat > %{buildroot}%{_unitdir}/%{name}.service << 'EOF'
[Unit]
Description=Authenticated Receive Chain (ARC) Milter
Documentation=man:%{name}(8) man:%{name}.conf(5) http://www.trusteddomain.org/%{name}/
After=network.target nss-lookup.target syslog.target

[Service]
Type=forking
PIDFile=%{_localstatedir}/run/%{name}/%{name}.pid
EnvironmentFile=-%{_sysconfdir}/sysconfig/%{name}
ExecStart=/usr/sbin/%{name} $OPTIONS
ExecReload=/bin/kill -USR1 $MAINPID
User=%{name}
Group=%{name}

[Install]
WantedBy=multi-user.target
EOF
%else
mkdir -p %{buildroot}%{_initrddir}
install -m 0755 contrib/init/redhat/%{name} %{buildroot}%{_initrddir}/%{name}
%endif

%if %{tmpfiles}
install -p -d %{buildroot}%{_tmpfilesdir}
cat > %{buildroot}%{_tmpfilesdir}/%{name}.conf <<EOF
D %{_localstatedir}/run/%{name} 0700 %{name} %{name} -
EOF
%endif

%pre
if ! getent passwd openarc >/dev/null 2>&1; then
    %{_sbindir}/useradd -M -d %{_localstatedir}/lib -r -s /bin/false openarc
    if ! getent group openarc >/dev/null; then
        %{_sbindir}/groupadd openarc
        %{_sbindir}/usermod -g openarc openarc
    fi
    if getent group mail >/dev/null; then
        %{_sbindir}/usermod -G mail openarc
    fi
fi
exit 0


%post

%if %systemd
%systemd_post %{name}.service
%else
/sbin/chkconfig --add %{name} || :
%endif


%preun
%if %systemd
%systemd_preun %{name}.service
%else
if [ $1 -eq 0 ]; then
    service %{name} stop >/dev/null || :
    /sbin/chkconfig --del %{name} || :
fi
exit 0
%endif

%ldconfig_scriptlets -n libopenarc

%files
%license LICENSE LICENSE.Sendmail
%doc README RELEASE_NOTES
%config(noreplace) %{_sysconfdir}/openarc.conf

%if %{tmpfiles}
%{_tmpfilesdir}/%{name}.conf
%else
%dir %attr(-,%{name},%{name}) %{_localstatedir}/run/%{name}
%endif

%if %{systemd}
%{_unitdir}/%{name}.service
%else
%{_initrddir}/%{name}
%endif
%{_mandir}/*/*
%{_sbindir}/*


%files -n libopenarc
%license LICENSE LICENSE.Sendmail
%{_libdir}/*.so.0
%{_libdir}/*.so.0.0.0

%files -n libopenarc-devel
%{_includedir}/*
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc

%changelog
* Wed Jul 11 2018 Xavier Bachelot <xavier@bachelot.org> 1.0.0-0.1.Beta0
- Specfile clean up.
- Update to 1.0.0 beta 0.

* Sun Jul 23 2017  Matt Domsch <matt@domsch.com> 0.1.0-1
- update to Fedora Packaging Guidelines