File pure-ftpd.spec of Package pure-ftpd

#
# spec file for package pure-ftpd
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


Name:           pure-ftpd
Version:        1.0.42
Release:        0
Summary:        A Lightweight, Fast, and Secure FTP Server
License:        BSD-3-Clause
Group:          Productivity/Networking/Ftp/Servers
Url:            http://www.pureftpd.org
Source0:        ftp://ftp.pureftpd.org/pub/%{name}/releases/%{name}-%{version}.tar.gz
Source1:        ftp://ftp.pureftpd.org/pub/%{name}/releases/%{name}-%{version}.tar.gz.sig
Source2:        %{name}.keyring
Source3:        %{name}.init
Source4:        %{name}.pamd
Source5:        %{name}.xinetd
Source6:        %{name}.xml
Source7:        %{name}.firewall
Source8:        %{name}.service
# PATCH-FEATURE-OPENSUSE %{name}-1.0.20_config.patch -- Custom service configs.
Patch0:         %{name}-1.0.20_config.patch
# PATCH-FEATURE-OPENSUSE %{name}-1.0.20_doc.patch -- Adjust command paths on documentation.
Patch1:         %{name}-1.0.20_doc.patch
# PATCH-FEATURE-OPENSUSE %{name}-1.0.20_virtualhosts.patch -- Custom VHOST_PATH on openSUSE.
Patch2:         %{name}-1.0.20_virtualhosts.patch
Patch5:         %{name}-1.0.20_ftpwho_path.patch
# PATCH-FIX-UPSTREAM %{name}-1.0.32-default_tcp_sedrcv_buffer_size.patch
Patch7:         %{name}-1.0.32-default_tcp_sedrcv_buffer_size.patch
# PATCH-FEATURE-OPENSUSE %{name}-1.0.32-portrange.patch -- Add PassivePortRange to "%numpairc_switch_for".
Patch8:         %{name}-1.0.32-portrange.patch
# PATCH-FIX-OPENSUSE: bnc#789833
# won't be upstreamed, can be dropped when systemd will be only one init system and kernel get AUDIT_LOGINUID_IMMUTABLE
Patch9:         pure-ftpd-1.0.36-cap-audit-control.patch
BuildRequires:  libcap-devel
BuildRequires:  mysql-devel
BuildRequires:  openldap2-devel
BuildRequires:  pam-devel
BuildRequires:  postgresql-devel
Requires(pre):  coreutils
Provides:       ftp-server
Provides:       pureftpd = %{version}-%{release}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} > 1140
BuildRequires:  pkgconfig(systemd)
%{?systemd_requires}
%else
Requires(pre):  %insserv_prereq
%endif

%description
Pure-FTPd is a fast, production-quality, and standard-conforming FTP
server, based-on Troll-FTPd. Unlike other popular FTP servers, it has
no known security flaws, is trivial to set up, and is especially
designed for modern Linux kernels (setfsuid and sendfile capabilities)
. Features include: PAM support, IPv6, chroot()ed home directories,
virtual domains, built-in LS, anti-warez system, bandwidth throttling,
FXP, bounded ports for passive downloads, upload and download ratios,
Apache log files, and more.

%prep
%setup -q
%patch0
%patch1
%patch2
%patch5
%patch7
%patch8
%patch9 -p1

%build
CFLAGS="%{optflags} -DLDAP_DEPRECATED -fstack-protector -fvisibility=hidden"
%configure \
	--with-rfc2640 \
	--sysconfdir=%{_sysconfdir}/%{name} \
	--with-ldap \
	--with-paranoidmsg \
	--with-altlog \
	--with-virtualhosts \
	--with-ftpwho \
	--with-mysql \
	--with-nonalnum \
	--with-pgsql \
	--with-cookie \
	--with-throttling \
	--with-ratios \
	--with-uploadscript \
	--with-diraliases \
	--with-pam \
	--with-puredb \
	--with-sysquotas \
	--with-quotas \
	--with-inetd \
	--with-tls \
	--with-boring \
	--with-peruserlimits \
	--with-largefile %{_target_cpu}-suse-linux \
	--with-virtualchroot
make %{?_smp_mflags}
cat configuration-file/pure-config.pl |grep -v "^print" | grep -v "^exec" > configuration-file/pure-config-args
echo "print join(\" \", @flg);" >> configuration-file/pure-config-args

%install
make DESTDIR=%{buildroot} install %{?_smp_mflags}

install -dD -m 0755 \
    %{buildroot}%{_sysconfdir}/{%{name},%{name}/vhosts,pam.d,xinetd.d,openldap/schema}
install -m 0755 \
        configuration-file/pure-config.pl \
        configuration-file/pure-config-args \
    %{buildroot}%{_sbindir}
install -m 0644 configuration-file/pure-ftpd.conf \
               %{buildroot}%{_sysconfdir}/%{name}

install -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/pam.d/pure-ftpd
install -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/xinetd.d/pure-ftpd
install -m 0644 pureftpd.schema %{buildroot}%{_sysconfdir}/openldap/schema/
install -d %{buildroot}%{_datadir}/omc/svcinfo.d/
install -m 0644 %{SOURCE6} %{buildroot}%{_datadir}/omc/svcinfo.d/

install -d %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/
install -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}

%if 0%{?suse_version} > 1140
install -D -m0644 %{SOURCE8} %{buildroot}%{_unitdir}/%{name}.service
ln -sf service %{buildroot}%{_sbindir}/rc%{name}
%else
install -D -m 0755 %{SOURCE3} %{buildroot}%{_initddir}/%{name}
mkdir -p %{buildroot}%{_sbindir}
ln -sf %{_initddir}/%{name} %{buildroot}%{_sbindir}/rc%{name}
%endif

%pre
%if 0%{?suse_version} > 1140
%service_add_pre %{name}.service
%endif

%preun
%if 0%{?suse_version} > 1140
%service_del_preun %{name}.service
%else
%stop_on_removal %{name}
%endif

%post
if [ -f etc/pure-ftpd.conf ]; then
        mv etc/pure-ftpd.conf etc/pure-ftpd/pure-ftpd.conf
fi
%if 0%{?suse_version} > 1140
%service_add_post %{name}.service
%else
%fillup_and_insserv %{name}
%endif

%postun
%if 0%{?suse_version} > 1140
%service_del_postun %{name}.service
%else
%restart_on_update %{name}
%insserv_cleanup
%endif

%files
%defattr(-, root, root)
%{_datadir}/omc/svcinfo.d/%{name}.xml
%doc AUTHORS CONTACT COPYING NEWS THANKS README README.Contrib
%doc README.Configuration-File HISTORY README.Virtual-Users
%doc README.LDAP pureftpd-ldap.conf README.MySQL README.PGSQL README.TLS
%{_mandir}/man8/*
%{_bindir}/*
%{_sbindir}/*
%dir %{_sysconfdir}/openldap
%dir %{_sysconfdir}/openldap/schema
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/vhosts
%config %{_sysconfdir}/openldap/schema/pureftpd.schema
%config %{_sysconfdir}/pam.d/pure-ftpd
%config(noreplace) %{_sysconfdir}/%{name}/pure-ftpd.conf
%config(noreplace) %{_sysconfdir}/xinetd.d/pure-ftpd
%config(noreplace) %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%if 0%{?suse_version} > 1140
%{_unitdir}/%{name}.service
%else
%{_initddir}/%{name}
%endif

%changelog
openSUSE Build Service is sponsored by