# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=phodav
pkgver=2.2
pkgrel=0
pkgdesc="A WebDAV server using libsoup"
url="https://wiki.gnome.org/phodav"
arch="all"
license="LGPL-2.0-or-later"
depends=""
depends_dev=""
makedepends="$depends_dev libsoup-dev avahi-dev intltool"
install=""
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang chezdav
	spice-webdavd:spice"
source="http://download.gnome.org/sources/phodav/$pkgver/phodav-$pkgver.tar.xz
	spice-webdavd.initd"

_builddir="$srcdir"/phodav-$pkgver
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	DATADIRNAME=share ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--with-avahi \
		--with-udevdir=/lib/udev \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
	rm -rf "$pkgdir"/usr/lib/systemd
	install -Dm755 "$srcdir"/spice-webdavd.initd \
		"$pkgdir"/etc/init.d/spice-webdavd
}

chezdav() {
	pkgdesc="A simple WebDAV server program"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

spice() {
	pkgdesc="Spice daemon for the DAV channel"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/sbin "$subpkgdir"/usr/
	mv "$pkgdir"/lib "$pkgdir"/etc "$subpkgdir"/
}


sha512sums="1d16716c1bda674a6695b651e9b1bcb4b7cfefd9b60291ed3f5691f4f6f45f68a970d99fc4820bed0484cf0a43c1bf32e4d208fcc239ac0c0b7a75bf779e8913  phodav-2.2.tar.xz
9c38481ea8d59c4abee273080e7c48804c1453669804de008a98324c47e21253cbedf7b78e734afd12f4769fe3b451972f44d1dfd53012e2af02605a7fb2b916  spice-webdavd.initd"
