File fetchmail.spec of Package fetchmail.21479

#
# spec file for package fetchmail
#
# Copyright (c) 2021 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/
#


Name:           fetchmail
BuildRequires:  automake
BuildRequires:  krb5-devel
BuildRequires:  openssl-devel
BuildRequires:  opie
BuildRequires:  postfix
BuildRequires:  procmail
BuildRequires:  pwdutils
BuildRequires:  python-devel
%if 0%{?suse_version} > 1220
BuildRequires:  gpg-offline
%endif
Version:        6.3.26
Release:        0
Summary:        Full-Featured POP and IMAP Mail Retrieval Daemon
License:        GPL-2.0-or-later
Group:          Productivity/Networking/Email/Utilities
URL:            http://fetchmail.berlios.de/
# The fetchmail-{EN,SA}-*.txt security advisories
# were relicensed to CC BY-ND 3.0, so there's no need
# to repack the tarball without them anymore (bnc#713698)
Source:         http://sourceforge.net/projects/fetchmail/files/branch_6.3/%{name}-%{version}.tar.xz
Source1:        %{name}.init
Source2:        %{name}.logrotate
Source3:        sysconfig.%{name}
Source4:        http://sourceforge.net/projects/fetchmail/files/branch_6.3/%{name}-%{version}.tar.xz.asc
Source5:        %{name}.keyring
Source6:        %{name}.service
Source7:        %{name}.tmpfiles
Source8:        %{name}.exec
Patch0:         fetchmail-6.3.8-smtp_errors.patch
# PATCH-FIX-UPSTREAM bsc#1182807 TLS: set hostname for SNI.
Patch1:         fetchmail-SNI-hostname-support.patch
# PATCH-FIX-UPSTREAM bsc#1188034 Change PASSWORDLEN from 64 to 256
Patch2:         fetchmail-PASSWORDLEN-256.patch
# PATCH-FIX-UPSTREAM bsc#1188875 CVE-2021-36386 DoS or information disclosure in some configs
Patch3:         fetchmail-CVE-2021-36386.patch
# PATCH-FIX-UPSTREAM bsc#1190069 CVE-2021-39272 STARTTLS session encryption bypassing
Patch4:         fetchmail-CVE-2021-39272.patch
%if 0%{?suse_version} >=1230
BuildRequires:  pkgconfig(systemd)
%{?systemd_requires}
%else
Requires(pre):  %insserv_prereq
%endif
Requires(pre):  %fillup_prereq
Requires(pre):  coreutils
Requires(pre):  pwdutils
BuildRequires:  xz
Requires:       logrotate
Suggests:       smtp_daemon
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Icon:	        fetchmail.xpm

%description
Fetchmail is a robust and well-documented remote mail retrieval and
forwarding utility intended to be used over on-demand TCP/IP links
(such as SLIP or PPP connections).

Fetchmail retrieves mail from remote mail servers and forwards it to
your local machine's delivery system, so it can be read by normal mail
user agents, such as mutt, elm, pine, (x)emacs/gnus, or mailx.

fetchmailconf, an interactive GUI configurator suitable for end-users,
is included in the fetchmailconf package.

%package -n fetchmailconf
Summary:        Fetchmail Configuration Utility
Group:          Productivity/Networking/Email/Utilities
Requires:       %{name} = %{version}
Requires:       python-tk

%description -n fetchmailconf
A GUI configuration utility for generating fetchmail configuration
files (.fetchmailrc).

%prep
%if 0%{?gpg_verify:1}
%gpg_verify %{S:4}
%endif
%setup -q -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1

cp -a %{SOURCE1} %{SOURCE2} %{SOURCE3} .

%build
%if 0%{?suse_version} > 1010
ACLOCAL="aclocal -I m4 -I m4-local" autoreconf -f -i
%endif
if [ -f /usr/%{_lib}/libkrb5.so ] ; then
   GSS="--with-gssapi"
else
   GSS=""
fi
%configure\
	--enable-POP2\
	--enable-RPA\
	--enable-NTLM\
	--enable-SDPS\
	--enable-opie\
%if 0%{?with_krb5}
	--with-kerberos5\
	$GSS\
%endif
	--with-ssl=/usr
make %{?_smp_mflags}

%install
%make_install
ln -sf fetchmail.1.gz %{buildroot}/%{_mandir}/man1/fetchmailconf.1.gz
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
cp fetchmail.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/fetchmail
mkdir -p %{buildroot}/sbin
%if 0%{?suse_version} >=1230
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/tmpfiles.d
install -m 644 %{S:6} $RPM_BUILD_ROOT/%{_unitdir}/%{name}.service
install -m 644 %{S:7} $RPM_BUILD_ROOT/%{_libexecdir}/tmpfiles.d/%{name}.conf
install -m 755 %{S:8} $RPM_BUILD_ROOT/%{_libexecdir}/%{name}-systemd-exec
%else
mkdir -p %{buildroot}%{_sysconfdir}/init.d
cp fetchmail.init %{buildroot}%{_initddir}/fetchmail
chmod +x %{buildroot}%{_initddir}/fetchmail
ln -s ../etc/init.d/fetchmail %{buildroot}/sbin/rcfetchmail
%endif
touch %{buildroot}%{_sysconfdir}/fetchmailrc
mkdir -p %{buildroot}%{_localstatedir}/adm/fillup-templates
cp sysconfig.%{name} %{buildroot}%{_localstatedir}/adm/fillup-templates
mkdir -p %{buildroot}%{_localstatedir}/log
touch %{buildroot}%{_localstatedir}/log/fetchmail
mkdir -p %{buildroot}%{_localstatedir}/lib/fetchmail
# we don't need this, it's aimed at fetchmail developers
# and rpmlint is complaining that we have a binary in /usr/share
rm -r contrib/gai*
%find_lang %{name}

%pre
usr/sbin/useradd -r -g daemon -s /bin/false \
  -c "mail retrieval daemon" -d /var/lib/fetchmail fetchmail 2>/dev/null || :
%if 0%{?suse_version} >=1230
  %service_add_pre %{name}.service
%endif

%post
%if 0%{?suse_version} >=1230
%{fillup_only}
%service_add_post %{name}.service
%else
%{fillup_and_insserv}
%endif
# Ensure that all files are readable by fetchmail with non-root UID.
touch var/log/fetchmail
chown fetchmail var/log/fetchmail
chmod 0600 var/log/fetchmail

%preun
%if 0%{?suse_version} >=1230
  %service_del_preun %{name}.service
%endif

%postun
%if 0%{?suse_version} >=1230
%service_del_postun %{name}.service
%else
%{insserv_cleanup}
%endif
if [ $1 == 0 ]; then
    rm -rf var/lib/fetchmail
fi

%files -f %{name}.lang
%defattr(-, root, root)
%{_bindir}/fetchmail
%dir %attr(0700, fetchmail, root) %{_localstatedir}/lib/fetchmail
%ghost %attr(0600, fetchmail, root) %{_localstatedir}/log/fetchmail
%doc %{_mandir}/man1/fetchmail.1.gz
%license COPYING
%doc FAQ FEATURES NEWS NOTES OLDNEWS README README.NTLM README.SSL README.SSL-SERVER TODO contrib *.html *.txt *.pdf
%ghost %config(noreplace) %attr(0600, fetchmail, root) %{_sysconfdir}/fetchmailrc
%config(noreplace) %{_sysconfdir}/logrotate.d/fetchmail
%if 0%{?suse_version} >=1230
%{_unitdir}/%{name}.service
%{_libexecdir}/%{name}-systemd-exec
%{_libexecdir}/tmpfiles.d/%{name}.conf
%else
%{_sysconfdir}/init.d/fetchmail
/sbin/rcfetchmail
%endif
%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}

%files -n fetchmailconf
%defattr(-, root, root)
%{_bindir}/fetchmailconf
%doc %{_mandir}/man1/fetchmailconf.1.gz
%{python_sitelib}/fetchmailconf.*

%changelog
openSUSE Build Service is sponsored by