# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=phodav
pkgver=3.0
pkgrel=3
pkgdesc="WebDAV server using libsoup"
url="https://wiki.gnome.org/phodav"
arch="all"
license="LGPL-2.0-or-later"
options="!check" # No test suite
depends="avahi"
makedepends="
	asciidoc
	attr-dev
	avahi-dev
	eudev-dev
	gtk-doc
	libsoup3-dev
	libxml2-dev
	meson
	xmlto
	"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang chezdav chezdav-doc:chezdav_doc
	spice-webdavd:spice spice-webdavd-openrc:spice_openrc"
source="https://download.gnome.org/sources/phodav/$pkgver/phodav-$pkgver.tar.xz
	spice-webdavd.initd
	"

build() {
	abuild-meson \
		-Davahi=enabled \
		. output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	rm -rf "$pkgdir"/usr/lib/systemd
}

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

chezdav_doc() {
	pkgdesc="A simple WebDAV server program (documentation)"
	mkdir -p "$subpkgdir"/usr/share
	mv "$pkgdir"/../phodav-doc/usr/share/man "$subpkgdir"/usr/share/
}

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

spice_openrc() {
	pkgdesc="Spice daemon for the DAV channel (OpenRC init scripts)"
	install_if="spice-webdavd=$pkgver-r$pkgrel openrc"
	mkdir -p "$subpkgdir"/etc/init.d
	install "$srcdir"/spice-webdavd.initd "$subpkgdir"/etc/init.d/spice-webdavd
}

sha512sums="
a4720083fd581023ea78cc09e6df4b5d2f90894f916004cf28c7fa557da61d8c7a5539fa6b50647efcd9f771afd088889fdc40579a8e860c8ea20540b25eb26a  phodav-3.0.tar.xz
1e10314f831840d9f54f38163bd518f42a378fe27b508639771b82610b4a434d4ec56c70a334dbfc7c8cd91160ba346751978f511c522577803248205dbcd211  spice-webdavd.initd
"
