%define	_sysconfdir	/etc

################################################# BASIC PACKAGE INFORMATION
Summary:       AppleTalk and AppleShare/IP services for Linux
Summary(ja):   Linux 用 AppleTalk, AppleShare/IP サービス
Name:          netatalk
Version:       2.2.1
Release:       1%{_dist_release}
License:       GPLv2+
Group:         System Environment/Daemons
Source0:       %{name}-%{version}.tar.bz2
URL:           http://netatalk.sourceforge.net/
Obsoletes:     netatalk-1.4b2+asun

# patch for default config file
Patch10:       netatalk-2.2.0-config-utf8.patch


############################################################## REQUIREMENTS
Requires(pre): chkconfig, /sbin/ldconfig, grep, textutils
Requires:      cracklib, openssl, tcp_wrappers, pam, perl
BuildRequires: openssl-devel, avahi-devel, pam-devel, db4-devel,
BuildRequires: quota, libgcrypt-devel, libacl-devel

BuildRoot:     %{_tmppath}/%{name}-%{version}-root

Vendor:        Project Vine
Distribution:  Vine Linux
Packager:      shaolin


%description
Netatalk is a freely-available Open Source AFP fileserver. It also provides a
kernel level implementation of the AppleTalk Protocol Suite. A *NIX/*BSD system
running Netatalk is capable of serving many Macintosh clients simultaneously
as an AppleShare file server (AFP), AppleTalk router, *NIX/*BSD print server,
and for accessing AppleTalk printers via Printer Access Protocol (PAP).
Included are a number of minor printing and debugging utilities.

%description -l ja
このパッケージを使うことで, Linux 上で AppleTalk プロトコルを
扱うことができ, Macintosh と通信が可能になります.
Linux 上で AppleTalk や AFP over TCP の Mac 向けファイルサーバを
稼働させることができるデーモンプログラムが収められています.


%package devel
Group:         Development/Libraries
Summary:       Headers for AppleTalk development
Summary(ja):   AppleTalk 開発用ヘッダファイル

%description devel
This package contains the header files for building AppleTalk networking
programs.


%prep
%setup -q

%patch10 -p1 -b .cjk-config


%build
touch AUTHORS
ln -s NEWS ChangeLog
rm -f README.cjk4.cjk

libtoolize --force
aclocal -I macros
automake --add-missing
autoconf
autoheader
CFLAGS="${RPM_OPT_FLAGS} -fomit-frame-pointer -fsigned-char" \
./configure \
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--libexecdir=%{_libdir}/netatalk \
	--sysconfdir=%{_sysconfdir} \
	--mandir=%{_mandir} \
	--localstatedir=%{_var} \
	--enable-shared \
	--enable-zeroconf \
	--disable-srvloc \
	--disable-ddp \
	--with-cnid-dbd-backend \
	--with-cnid-cdb-backend \
	--with-cnid-default-backend=dbd \
	--with-uams-path=%{_libdir}/netatalk \
	--enable-redhat-sysv \
	--with-cracklib \
	--with-pam \
	--with-shadow \
	--enable-tcp-wrappers \
	--with-acls \
	--enable-pgp-uam

make all


%install
### INSTALL (USING "make install") ###
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}{%{_prefix},%{_sysconfdir}/netatalk/msg}
make DESTDIR=$RPM_BUILD_ROOT install

## netatalk/at.h is now provided by glibc
rm -f $RPM_BUILD_ROOT%{_prefix}/include/netatalk/at.h

## for Bonjour (requires nss-mdns)
#install -d -m 755 ${RPM_BUILD_ROOT}%{_sysconfdir}/avahi/services
#install -m 644 %{SOURCE10} ${RPM_BUILD_ROOT}%{_sysconfdir}/avahi/services/


%pre
### COPY OLD PREFERENCE FILES ###

if [ -d /etc/atalk ] ; then
    mkdir -p /etc/netatalk/
    cp -a /etc/atalk /etc/netatalk/00_OLD_VERSION_PREFS
fi
exit 0


%post

### RUN CHKCONFIG ###
/sbin/chkconfig --add netatalk

/sbin/ldconfig

if test -r /var/lock/atalkd ; then
	/etc/rc.d/init.d/netatalk restart >&2
fi


%preun

### RUN CHKCONFIG ###
/sbin/chkconfig --del netatalk


%triggerpostun -- netatalk <= 1.4b2+asun2.1.3-7vl6
/sbin/chkconfig --add netatalk


%clean
rm -rf ${RPM_BUILD_ROOT}


%files
%defattr(-,root,root)
%doc AUTHORS CONTRIBUTORS COPYING COPYRIGHT
%doc ChangeLog NEWS
%doc doc/[A-L,N-Z]*
%config(noreplace) /etc/netatalk/Apple*
%config(noreplace) /etc/netatalk/*.conf
%config /etc/pam.d/netatalk
%config /etc/rc.d/init.d/netatalk
%dir %{_sysconfdir}/netatalk
%dir %{_sysconfdir}/netatalk/msg
#%{_sysconfdir}/avahi/services/afpd.service
%{_bindir}/*
%{_sbindir}/*
%{_libdir}/netatalk/*
%exclude %{_libdir}/netatalk/*.a
%exclude %{_libdir}/netatalk/*.la
%{_mandir}/*/*


%files devel
%defattr(-,root,root)
%{_libdir}/*.a
%{_libdir}/*.la
%{_libdir}/netatalk/*.a
%{_libdir}/netatalk/*.la
%dir %{_includedir}/atalk
%{_includedir}/atalk/*.h
%dir %{_includedir}/netatalk
%{_includedir}/netatalk/*.h
%{_datadir}/aclocal/netatalk.m4


%changelog
* Sun Sep 18 2011 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.2.1-1
- new upstream release
- fix configure options; add missing BRs

* Thu Jul 28 2011 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.2.0-3
- now back from the upstream confusion (and one more or two...)
  new upstream release 2.2.0 at the official site

* Mon Jul 25 2011 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.2.0-2
- fix Patch10 to follow HAT-san's strong and confident objection
  (no need to set ATALK_NAME explicitly in netatalk.conf)

* Sat Jul 23 2011 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.2.0-1
- new upstream release (at http://www003.upp.so-net.ne.jp/hat/netatalk/)
- add Source100 to add one missing header file in the tarball
- revise Patch10
- explicitly specify --disable-ddp for the first time

* Wed May 04 2011 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.1.5-1
- new upstream release

* Sun Feb 06 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 2.1.3-3
- rebuild with openssl-1.0.0c

* Sun Jul 25 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.1.3-2
- fix Patch10 & update description - upon HAT-san's suggestions

* Sun Jul 25 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.1.3-1
- new upstream release
- update Vine patch

* Thu Feb 11 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.0.5-1
- new upstream release

* Sun May 31 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.0.4-1
- new upstream release

* Sun Mar  8 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.0.3-7
- rebuilt both for VineSeed / VinePlus-4.0

* Fri Jul 25 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0.3-6
- updated to the cjk-6 patch
- Patch11/12 updated - VineSeed is now set with ja_JP.UTF-8 locale
- Patch14 updated for db46

* Sun Apr 20 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0.3-5
- remove openslp dependency

* Tue Apr 15 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0.3-4
- add Patch11 for Vine's default setting (volcharset:EUC-JP, etc.)
- TODO: remember to revise this fix after VineSeed changes default locale
        from ja_JP.eucJP (current) to ja_JP.UTF-8 (near future)

* Tue Apr 15 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0.3-3
- revise description (thanks HAT-san for pointing this out)
- run libtoolize/aclocal/auto{make,conf,header} before doing configure
  (without this, uams_* modules won't get .so suffix)

* Mon Apr 14 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0.3-2
- Patch10 updated; dropped Patch11, Patch12, Source10 and Source11
  (Patch10 now includes all the modifications and more fixes)

* Fri Apr 11 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 2.0.3-1
- add patch13 and patch14 for db-4.3.
- move files in %%_libexecdir to %%libdir.

* Sat Oct 21 2006 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0.3-0vl1
- updated to 2.0.3 release w/ cjk patches (see the above Patch section)

* Tue Oct 19 2004 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0-0vl4
- security fix: added Patch10 (CAN-2004-0974)

* Tue Oct 19 2004 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0-0vl3
- configure --with-cnid-default-backend=dbd (cdb seems to be unstable)

* Wed Oct 13 2004 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0-0vl1
- updated to 2.0 with cjk patch
  (see the above Patch section for details)

* Tue May 28 2002 Masaki Shinomiya <shino@pos.to> 1.5.3.1-0vl4
- merge the patch repairing bug for System 7.5.5
- (patch6 netatalk-1.5.3.oldsys.patch)
- made by Akihiro Okamaoto <med012@art.osaka-med.ac.jp>
- patch6 addupted no matter noeuc is, license GPL, URL in comment

* Sat Apr 27 2002 Masaki Shinomiya <shino@pos.to> 1.5.3.1-0vl3
- euc and kana patch originally by
- Akihiro Okamoto <med012@art.osaka-med.ac.jp> against netatalk-1.4b2+asun2.1.3
- applied to netatalk-1.5.2 by me 
- README.vine
- omit VERSION from doc, omit perl from require

* Wed Apr 24 2002 Masaki Shinomiya <shino@pos.to> 1.5.3.1-0vl2
- this package is removed because the release number duplicated

* Mon Apr 01 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.5.3.1-0vl2
- move acleandir.rc to the doc directory, remove executable flag.

* Sun Mar 31 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.5.3.1-0vl1
- updated to new upstream release

* Fri Mar 01 2002 Toru Sagami <sagami@vinelinux.org> 1.5.2-0vl3
- added Japanese Summary for devel and corrected Group

* Thu Feb 28 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.5.2-0vl2
- Oops, check /var/lock/atalkd instead of /var/run/atd.pid
  (say atd.pid doesn't have anything to do with netatalk!!)

* Tue Feb 26 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.5.2-0vl1
- updated to new upstream release

* Thu Feb 07 2002 Toru Sagami <sagami@vinelinux.org> 1.5.1.1-0vl3
- install man pages into %%{_mandir}
- PreReq: /sbin/chkconfig /sbin/ldconfig grep textutils
- let pre script exit 0

* Thu Feb 07 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.5.1.1-0vl2
- spec cleanup
- backup old prefs directory (/etc/atalk -> /etc/netatalk/00OLD_VERSION_PREFS)
- restart atalk daemons in the %%post section

* Sun Feb 3 2002  k hanai <hanai@koto.kpu-m.ac.jp>
 - v1.5.1.1-0vl1

* Fri Jan 25 2002 k hanai <hanai@koto.kpu-m.ac.jp>
  - v1.5.0-0vl1
  - release 1.5.0 for sourceforge

* Thu Apr 12 2001 rufus t firefly <rufus.t.firefly@linux-mandrake.com>
  - v1.5pre6-1rh7
  - pre-release 6 for sourceforge

* Wed Mar 07 2001 rufus t firefly <rufus.t.firefly@linux-mandrake.com>
  - v1.5pre5-1
  - pre-release 5 for sourceforge

* Fri Feb 23 2001 rufus t firefly <rufus.t.firefly@linux-mandrake.com>
  - v1.5pre5-0
  - pre-release 5 for sourceforge (prebuild)

* Tue Feb 20 2001 rufus t firefly <rufus.t.firefly@linux-mandrake.com>
  - v1.5pre4-1
  - pre-release 4 for sourceforge
  - modified/split mandrake spec for redhat 7 build

* Mon Dec 18 2000 rufus t firefly <rufus.t.firefly@linux-mandrake.com>
  - v1.5pre3-1mdk
  - pre-release 3 for sourceforge
  - moved away from 1.4.99 ... 

* Wed Nov 08 2000 rufus t firefly <rufus.t.firefly@linux-mandrake.com>
  - v1.4.99-0.20001108mdk
  - pre-release 2 for sourceforge

* Wed Sep 27 2000 rufus t firefly <rufus.t.firefly@linux-mandrake.com>
  - v1.4.99-0.20000927mdk
  - pre-release 1 for sourceforge
