File netatalk.spec of Package netatalk

#
# spec file for package netatalk
#
# Copyright (c) 2015 SUSE LINUX Products 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/
#


%define with_afpstats  0
%define with_tracker_spotlight 0
%define libmaj  16
Name:           netatalk
Version:        3.1.7
Release:        0
Summary:        AFP Fileserver for Macintosh Clients
License:        GPL-2.0+
Group:          Productivity/Networking/System
Url:            http://netatalk.sourceforge.net/
Source:         http://downloads.sourceforge.net/project/netatalk/netatalk/%{version}/netatalk-%{version}.tar.bz2
Source1:        netatalk-latinize.pl
Source3:        netatalk-upgrade_netatalk_AppleDB.sh
Source4:        netatalk-rpmlintrc
# see bnc#849598 and http://sourceforge.net/p/netatalk/bugs/538/
Patch0:         %{name}-wrong-error-message.patch
Patch2:         netatalk-libc-xattr.patch
Patch3:         fce-afpd-fix-fce_event_names-array-overflow.patch
BuildRequires:  automake
BuildRequires:  db-devel
BuildRequires:  fdupes
BuildRequires:  krb5-devel
BuildRequires:  libacl-devel
BuildRequires:  libavahi-devel
BuildRequires:  libevent-devel
BuildRequires:  libgcrypt-devel
BuildRequires:  libtdb-devel
BuildRequires:  libtool
BuildRequires:  openldap2-devel
BuildRequires:  openssl-devel
BuildRequires:  pam-devel
BuildRequires:  pkg-config
BuildRequires:  tcpd-devel
BuildRequires:  zlib-devel
Requires:       cyrus-sasl
Requires:       db-utils
# FIXME: use proper Requires(pre/post/preun/...)
PreReq:         %insserv_prereq %fillup_prereq
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?with_afpstats}%{?with_tracker_spotlight}
BuildRequires:  dbus-1-devel
BuildRequires:  dbus-1-glib-devel
%if 0%{?with_tracker_spotlight}
BuildRequires:  tracker-devel
%endif
%endif
%if 0%{?suse_version} > 1210
BuildRequires:  systemd
%{?systemd_requires}
%endif

%description
Netatalk is a freely-available Open Source AFP fileserver. A *NIX/*BSD
system running Netatalk is capable of serving many Macintosh clients
simultaneously as an AppleShare file server (AFP).

%package -n libatalk%{libmaj}
Summary:        Netatalk AFP Fileserver for Macintosh Clients
Group:          Development/Libraries/C and C++

%description -n libatalk%{libmaj}
Netatalk is a freely-available Open Source AFP fileserver. A *NIX/*BSD
system running Netatalk is capable of serving many Macintosh clients
simultaneously as an AppleShare file server (AFP).

%package devel
Summary:        Netatalk AFP Fileserver for Macintosh Clients
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}
Requires:       glibc-devel

%description devel
Netatalk is a freely-available Open Source AFP fileserver. A *NIX/*BSD
system running Netatalk is capable of serving many Macintosh clients
simultaneously as an AppleShare file server (AFP).

%prep
%setup -q -n netatalk-%{version}
%patch0
%patch2 -p1
%patch3 -p1
cp -avL %{SOURCE1} .

%build
autoreconf -fiv
LDFLAGS="-lpthread" \
CFLAGS="%{optflags} -Wall -g -pie -fpie" \
%if 0%{?with_tracker_spotlight}
tracker_ver=$(rpm -q --queryformat="%{VERSION}" tracker-devel|cut -d . -f 1-2)
%endif
%configure --bindir=%{_bindir} \
	--disable-static \
	--with-pic \
	--with-shadow \
	--with-pam \
	--with-ldap \
        --with-acls \
	--enable-pgp-uam \
        --enable-krbV-uam \
	--enable-overwrite \
	--enable-quota \
	--with-libevent=no \
	--with-tdb=no \
	--libexecdir=%{_libdir}/netatalk \
        --localstatedir=%{_localstatedir}/lib \
        --with-pkgconfdir=%{_sysconfdir}/netatalk \
%if %{with_afpstats} == 1
        --with-afpstats \
%endif
%if 0%{?with_tracker_spotlight}
	--with-tracker-pkgconfig-version=${tracker_ver} \
%endif
        --with-init-style=suse-systemd
make %{?_smp_mflags}
mkdir examples
cp netatalk-latinize.pl examples
sed -i '/\/var\/lock\/subsys/d' distrib/initscripts/rc.suse

%install
make DESTDIR=%{buildroot} install %{?_smp_mflags}
%if 0%{?suse_version} > 1140
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%else
mkdir -p %{buildroot}%{_sysconfdir}/init.d/
install -m 755 distrib/initscripts/rc.suse %{buildroot}%{_sysconfdir}/init.d/netatalk
ln -sf ../..%{_initddir}/netatalk %{buildroot}%{_sbindir}/rc%{name}
%endif
install -m 755 %{SOURCE3} %{buildroot}%{_sbindir}/upgrade_netatalk_AppleDB.sh
#
# Conflicts with yudit
rm %{buildroot}%{_mandir}/man1/uniconv.1*
#
find %{buildroot} -type f -name "*.la" -delete -print
%fdupes -s %{buildroot}%{_mandir}

%pre
test -f etc/atalk/afpd.conf && {
echo
echo "netatalk config files have been moved to %{_sysconfdir}/afp.conf"
echo "a backup can be found in %{_sysconfdir}/atalk"
echo "please compare them before restarting the netatalk server"
}
test -f etc/netatalk/afpd.conf && {
echo
echo "netatalk config files have been moved to %{_sysconfdir}/afp.conf"
echo "a backup can be found in %{_sysconfdir}/netatalk"
echo "please compare them before restarting the netatalk server"
}
%if 0%{?suse_version} > 1210
%service_add_pre netatalk.service
%endif
exit 0

%preun
%stop_on_removal netatalk
%if 0%{?suse_version} > 1210
%service_del_preun netatalk.service
%endif

%post
%restart_on_update netatalk
%if 0%{?suse_version} > 1210
%service_add_post netatalk.service
%{fillup_only netatalk}
%else
%{fillup_and_insserv netatalk}
%endif

%postun
%if 0%{?suse_version} > 1210
%service_del_postun netatalk.service
%else
%insserv_cleanup
%endif

%post -n libatalk%{libmaj} -p /sbin/ldconfig

%postun -n libatalk%{libmaj} -p /sbin/ldconfig

%files
%defattr (-,root,root)
%attr(755,root,root) %{_bindir}/*
%attr(755,root,root) %{_sbindir}/*
%dir %{_libdir}/netatalk
%{_libdir}/netatalk/*
%{_mandir}/man?/*
%doc AUTHORS CONTRIBUTORS COPYING COPYRIGHT NEWS VERSION examples
#
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/afp.conf
%config(noreplace) %{_sysconfdir}/%{name}/extmap.conf
%config(noreplace) %{_sysconfdir}/%{name}/dbus-session.conf
%if 0%{?with_afpstats}%{?with_tracker_spotlight}
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/netatalk-dbus.conf
%endif
%dir %{_sysconfdir}/pam.d
%config %{_sysconfdir}/pam.d/*
#
%if 0%{?suse_version} > 1210
%{_libexecdir}/systemd/system/netatalk.service
%else
%attr(755,root,root) %{_sysconfdir}/init.d/netatalk
%endif
%{_localstatedir}/lib/%{name}

%files -n libatalk%{libmaj}
%defattr (-,root,root)
%{_libdir}/libatalk.so.*
%doc COPYING COPYRIGHT

%files devel
%defattr (-,root,root)
%dir %{_datadir}/aclocal
%dir %{_includedir}/atalk
%{_libdir}/libatalk.so
%{_datadir}/aclocal/*
%{_includedir}/atalk/*

%changelog
openSUSE Build Service is sponsored by