File netatalk.spec of Package netatalk.26996

#
# spec file for package netatalk
#
# 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 with_afpstats  0

Name:           netatalk
URL:            http://netatalk.sourceforge.net/
Requires:       cyrus-sasl
Requires:       db-utils
Version:        3.1.0
Release:        0
%define libmaj  12
Summary:        AFP Fileserver for Macintosh Clients
License:        GPL-2.0-or-later
Group:          Productivity/Networking/System
Source:         http://downloads.sourceforge.net/project/netatalk/netatalk/3.1/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
Patch1:         %{name}-return-code.patch
Patch2:         netatalk-CVE-2018-1160.patch
# CVE-2021-31439, [bsc#1197352], Multiple vulnerability
Patch3:         netatalk-CVE-2021-31439.patch
# CVE-2022-23121, [bsc#1197352], Multiple vulnerability
Patch4:         netatalk-CVE-2022-23121.patch
# CVE-2022-23123, CVE-2022-23122, CVE-2022-23124, CVE-2022-0194, [bsc#1197352], Multiple vulnerability
#Patch5:         netatalk-CVE-2022-23123,23122,23124,0194.patch
# CVE-2022-23125 [bsc#1197352], Multiple vulnerability
Patch6:         netatalk-CVE-2022-23125.patch
# CVE-2022-45188 [bsc#1205393], heap-based buffer overflow in afp_getappl()
Patch7:         netatalk-CVE-2022-45188.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  db-devel
%if %{with_afpstats} == 1
BuildRequires:  dbus-1-devel
BuildRequires:  dbus-1-glib-devel
%endif
BuildRequires:  fdupes
BuildRequires:  krb5-devel
BuildRequires:  libacl-devel
BuildRequires:  libattr-devel
BuildRequires:  libavahi-devel
BuildRequires:  libevent-devel
BuildRequires:  libgcrypt-devel
BuildRequires:  libtool
BuildRequires:  openldap2-devel
BuildRequires:  openssl-devel
BuildRequires:  pam-devel
BuildRequires:  pkg-config
BuildRequires:  tcpd-devel
BuildRequires:  zlib-devel
%if 0%{?suse_version} > 1140
BuildRequires:  systemd
##Requires:       %{?systemd_requires}
%endif
PreReq:         %fillup_prereq
PreReq:         %insserv_prereq

%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).

Authors:
--------
    Wesley Craig <netatalk@umich.edu>
    Ann Arbor <netatalk@umich.edu>
    and the netatalk team at sourceforge.net

%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).

Authors:
--------
    Wesley Craig <netatalk-devel@umich.edu>
    Ann Arbor <netatalk-devel@umich.edu>
    and the netatalk team at sourceforge.net

%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).

Authors:
--------
    Wesley Craig <netatalk-devel@umich.edu>
    Ann Arbor <netatalk-devel@umich.edu>
    and the netatalk team at sourceforge.net

%prep
%setup -q -n netatalk-%{version}
%patch0
%patch1
%patch2 -p1
%patch3 -p1
%patch4 -p1
#%patch5 -p1
%patch6 -p1
%patch7 -p1
cp -avL %{SOURCE1} .

%build
LDFLAGS="-lpthread" \
CFLAGS="$RPM_OPT_FLAGS -Wall -g -pie -fpie" \
%configure --bindir=/usr/bin \
        --disable-silent-rules \
	--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 \
	--libexecdir=%{_libdir}/netatalk \
        --localstatedir=/var/lib \
        --with-pkgconfdir=/etc/netatalk \
%if %{with_afpstats} == 1
        --with-afpstats \
%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 install DESTDIR="%buildroot"
mkdir -p %{buildroot}%{_sysconfdir}/init.d/
install -m 755 distrib/initscripts/rc.suse %{buildroot}%{_sysconfdir}/init.d/netatalk
ln -sf ../../etc/init.d/netatalk %{buildroot}%{_sbindir}/rcnetatalk
install -m 755 %{SOURCE3} %{buildroot}%{_sbindir}/upgrade_netatalk_AppleDB.sh
#
# Conflicts with yudit
rm %{buildroot}%{_bindir}/uniconv
rm %{buildroot}%{_mandir}/man1/uniconv.1*
#
find %{buildroot} -type f -name "*.la" | xargs rm -vf
%fdupes -s %{buildroot}%{_mandir}

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

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

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

%postun
%insserv_cleanup
%if 0%{?suse_version} > 1140
%service_del_postun netatalk.service
%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 %{with_afpstats} == 1
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/netatalk-dbus.conf
%endif
%dir %{_sysconfdir}/pam.d
%config %{_sysconfdir}/pam.d/*
#
%attr(755,root,root) %{_sysconfdir}/init.d/netatalk
%{_prefix}/lib/systemd/system/netatalk.service
/var/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