# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: team/gnome <ablocorrea@hotmail.com>
pkgname=gvfs
pkgver=1.52.1
pkgrel=0
pkgdesc="Backends for the gio framework in GLib"
url="https://wiki.gnome.org/Projects/gvfs"
arch="all"
license="LGPL-2.0-or-later"
depends="gsettings-desktop-schemas dbus:org.freedesktop.Secrets"
makedepends="
	avahi-dev
	docbook-xsl
	expat-dev
	fuse3-dev
	gcr-dev
	gnome-online-accounts-dev
	gsettings-desktop-schemas-dev
	libarchive-dev
	libbluray-dev
	libcap-dev
	libcdio-paranoia-dev
	libgcrypt-dev
	libgdata-dev
	libgphoto2-dev
	libgudev-dev
	libimobiledevice-dev
	libmtp-dev
	libnfs-dev
	libsecret-dev
	libsoup3-dev
	libusb-dev
	libxml2-dev
	libxslt-dev
	meson
	openssh-client
	samba-dev
	udisks2-dev
	"
triggers="$pkgname.trigger=/usr/libexec/gvfs"
subpackages="
	$pkgname-dbg
	$pkgname-dev
	$pkgname-lang
	$pkgname-afc
	$pkgname-afp
	$pkgname-archive
	$pkgname-avahi
	$pkgname-cdda
	$pkgname-dav
	$pkgname-fuse
	$pkgname-gphoto2
	$pkgname-goa
	$pkgname-mtp
	$pkgname-nfs
	$pkgname-smb
	"
source="https://download.gnome.org/sources/gvfs/${pkgver%.*}/gvfs-$pkgver.tar.xz"

# secfixes:
#   1.40.2-r0:
#     - CVE-2019-12795
#     - CVE-2019-12449
#     - CVE-2019-12447
#     - CVE-2019-12448

build() {
	abuild-meson \
		-Db_lto=true \
		--libexecdir=/usr/libexec/gvfs \
		-Dsystemduserunitdir=no \
		-Dtmpfilesdir=no \
		-Dlogind=false \
		. output

	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

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

fuse() {
	pkgdesc="FUSE support for gvfs"
	amove usr/libexec/gvfs/gvfsd-fuse
}

smb() {
	pkgdesc="Windows fileshare support for gvfs"
	amove \
		usr/libexec/gvfs/gvfsd-smb* \
		usr/share/gvfs/mounts/smb* \
		usr/share/glib-*/schemas/org.gnome.system.smb.gschema.xml \
		usr/share/GConf/gsettings/gvfs-smb.convert
}

mtp() {
	pkgdesc="MTP support for gvfs"
	amove usr/libexec/gvfs/gvfsd-mtp
}

archive() {
	pkgdesc="Archiving support for gvfs"
	amove \
		usr/libexec/gvfs/gvfsd-archive* \
		usr/share/gvfs/mounts/archive*
}

obexftp() {
	pkgdesc="ObexFTP support for gvfs"
	amove \
		usr/libexec/gvfs/gvfsd-obex* \
		usr/share/gvfs/mounts/obex*
}

gphoto2() {
	pkgdesc="gphoto2 support for gvfs"
	amove \
		usr/libexec/gvfs/gvfs*gphoto* \
		usr/share/gvfs/*/gphoto* \
		usr/share/dbus*/services/*GPhoto*
}

afp() {
	pkgdesc="AFP support for gvfs"
	amove \
		usr/libexec/gvfs/gvfs*afp* \
		usr/share/gvfs/*/afp*
}

avahi() {
	pkgdesc="DNS-SD support for gvfs"
	amove \
		usr/libexec/gvfs/gvfs*dns* \
		usr/share/gvfs/mounts/dns-sd.mount \
		usr/share/glib-*/schemas/org.gnome.system.dns_sd.gschema.xml \
		usr/share/GConf/gsettings/gvfs-dns-sd.convert
}

cdda() {
	pkgdesc="CDDA support for gvfs"
	amove \
		usr/share/gvfs/mounts/cdda.mount \
		usr/libexec/gvfs/gvfsd-cdda
}

dav() {
	pkgdesc="WebDAV support for gvfs"
	amove \
		usr/share/gvfs/mounts/dav.mount \
		usr/share/gvfs/mounts/dav+sd.mount \
		usr/libexec/gvfs/gvfsd-dav
}

nfs() {
	pkgdesc="NFS support for gvfs"
	amove \
		usr/share/gvfs/mounts/nfs.mount \
		usr/libexec/gvfs/gvfsd-nfs
}

goa() {
	pkgdesc="GNOME Online Accounts support for gvfs"
	amove \
		usr/libexec/gvfs/gvfs-goa-volume-monitor \
		usr/libexec/gvfs/gvfsd-google \
		usr/share/gvfs/mounts/google.mount \
		usr/share/dbus-1/services/org.gtk.vfs.GoaVolumeMonitor.service \
		usr/share/gvfs/remote-volume-monitors/goa.monitor
}

afc() {
	pkgdesc="Apple mobile devices support for gvfs"
	amove \
		usr/libexec/gvfs/gvfsd-afc \
		usr/libexec/gvfs/gvfs-afc-volume-monitor \
		usr/share/dbus-1/services/org.gtk.vfs.AfcVolumeMonitor.service \
		usr/share/gvfs/remote-volume-monitors/afc.monitor
}

sha512sums="
7d791afd505bcdbc38e811630a60e846f8980db1e80a07877aa20439177fc9a5def35f4dabd83323a4867a1cce548600e2f6c8bed586ee1ca55f514022e86064  gvfs-1.52.1.tar.xz
"
