Name:           davfs2
Version:        1.5.2
Release:        1%{?_dist_release}
Summary:        A filesystem driver for WebDAV
Summary(ja):    WebDAV 用のファイルシステムドライバ
Group:          System Environment/Base
License:        GPLv2+
URL:            http://savannah.nongnu.org/projects/davfs2
Source0:        http://download.savannah.gnu.org/releases/davfs2/davfs2-%{version}.tar.gz 
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root

BuildRequires:  gettext
BuildRequires:  neon-devel
BuildRequires:  krb5-devel
Requires(pre):  shadow-utils

%define cachedir /var/cache/davfs2
%define piddir /var/run/mount.davfs
%define username davfs2
%define groupname %{username}

%description
davfs2 is a Linux file system driver that allows you to mount a WebDAV server
as a disk drive.

%prep
%setup -q

%build
# ad-hoc fix for building with neon 0.30.0
#sed -i -e 's/27 28 29/27 28 29 30/g' configure

%configure
make


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%find_lang %{name}
# Create directories used by mount.davfs
install -d $RPM_BUILD_ROOT%{cachedir} $RPM_BUILD_ROOT%{piddir}
# Fix symlinks
ln -sf ../usr/sbin/mount.davfs $RPM_BUILD_ROOT/sbin/mount.davfs
ln -sf ../usr/sbin/umount.davfs $RPM_BUILD_ROOT/sbin/umount.davfs
# Don't need this - we'll do our own doc install, thanks
rm -rf $RPM_BUILD_ROOT/usr/share/doc/davfs2
# Remove duplicate files. (Why is it installing these in the first place?)
rm -rf $RPM_BUILD_ROOT/usr/share/davfs2 # same files in /etc/davfs2
# Remove suid bit, to work around a problem with brp-strip on suid binaries
chmod 0755 $RPM_BUILD_ROOT/%{_sbindir}/mount.davfs
# UTF8ify translated man pages
find $RPM_BUILD_ROOT/%{_mandir}/{de,es} -name "*.[58].gz" | while read m; do 
  gzip -dc $m | iconv -f "ISO8859-15" -t "UTF-8" - -o - | gzip -c9 > $m.utf8
  mv -f $m.utf8 $m
done


%clean
rm -rf $RPM_BUILD_ROOT

%pre
getent group  %{groupname} >/dev/null || groupadd -r %{groupname}
getent passwd %{username} >/dev/null || \
  useradd -r -g %{groupname} -d %{cachedir} -s /sbin/nologin \
          -c "User account for %{name}" %{username}
exit 0


%files -f %{name}.lang
%defattr(-,root,root,-)
# Docs
%doc AUTHORS BUGS COPYING ChangeLog FAQ INSTALL NEWS README README.translators THANKS TODO
%{_mandir}/man5/*.gz
%{_mandir}/man8/*.gz
# localized man pages
%{_mandir}/*/man5/*.gz
%{_mandir}/*/man8/*.gz

# Configfiles etc.
%config(noreplace) %{_sysconfdir}/davfs2/davfs2.conf
%config(noreplace) %{_sysconfdir}/davfs2/secrets
%dir %{_sysconfdir}/davfs2/certs/private/
%dir %{_sysconfdir}/davfs2/certs/
%dir %{_sysconfdir}/davfs2/

# Binaries
%{_sbindir}/umount.davfs
# re-apply suid bit to mount.davfs
%attr (4755,root,root) %{_sbindir}/mount.davfs
# symlinks to files in %{_sbindir}
/sbin/mount.davfs
/sbin/umount.davfs

# Extra dirs needed by mount.davfs
%dir %attr(00775,root,%{groupname}) %{cachedir}
%dir %attr(01775,root,%{groupname}) %{piddir}

%changelog
* Wed Dec 30 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.5.2-1
- new upstream release.
- built with gnutls-3.4.x.
- removed patch0 (no longer needed).

* Fri Dec 26 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 1.4.5-3
- rebuilt on current VineSeed
- fixed spec to built with neon 0.30

* Sun Apr 03 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.5-2
- rebuild with krb5-1.8.2
- add BR: krb5-devel

* Wed Jan 19 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.5-1
- initial build for Vine Linux

* Mon Feb 15 2010 Will Woods <wwoods@redhat.com> - 1.4.5-2
- Add davfs2-1.4.5-sys_stat_h.patch to fix building on F13

* Wed Jan 13 2010 Will Woods <wwoods@redhat.com> - 1.4.5-1
- New upstream release (fixes rebuild failure, see bug 538913)
- NOTE: 1.4.x has different config file syntax. Read the NEWS file!

* Thu Sep 17 2009 Peter Lemenkov <lemenkov@gmail.com> - 1.3.3-5
- bump

* Thu Sep 17 2009 Peter Lemenkov <lemenkov@gmail.com> - 1.3.3-4
- Rebuilt with new fuse

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Wed Mar 11 2009 Will Woods <wwoods@redhat.com> - 1.3.3-2
- Passed package review (#488858)
- Ensure that package owns /etc/davfs2 and /etc/davfs2/certs

* Mon Mar 02 2009 Will Woods <wwoods@redhat.com> - 1.3.3-1
- Initial packaging
- Fix open() with O_CREAT and no mode
