# Template file for 'open-vm-tools'
pkgname=open-vm-tools
version=12.1.5
revision=1
archs="x86_64* i686* aarch64*"
build_wrksrc="open-vm-tools"
build_style=gnu-configure
configure_args="--sbindir=/usr/bin --with-udev-rules-dir=/usr/lib/udev/rules.d
 --without-xmlsecurity --without-kernel-modules --disable-containerinfo
 $(vopt_with x11 x) $(vopt_with pam)"
hostmakedepends="automake libtool pkg-config glib-devel rpcsvc-proto"
makedepends="fuse-devel glib-devel libmspack-devel openssl-devel libtirpc-devel
 libxerces-c-devel procps-ng-devel $(vopt_if pam 'pam-devel')
 $(vopt_if x11 'gdk-pixbuf-xlib-devel gtkmm-devel libXtst-devel xmlsec1-devel')"
short_desc="Open source implementation of VMware Tools"
maintainer="Piraty <mail@piraty.dev>"
license="GPL-2.0-only, LGPL-2.1-only"
homepage="https://github.com/vmware/open-vm-tools"
changelog="https://raw.githubusercontent.com/vmware/open-vm-tools/master/ReleaseNotes.md"
distfiles="https://github.com/vmware/open-vm-tools/archive/stable-${version}.tar.gz"
checksum=678d08b46fba15f2b4c39245b5bc4deec30284d6f13ee279c233bc3d3627ec8a

build_options="pam x11"
build_options_default="pam x11"

if [ "$XBPS_TARGET_LIBC" != "glibc" ]; then
	configure_args+=" --disable-glibc-check"
fi

pre_configure() {
	autoreconf -vfi
}

post_install() {
	if [ "$build_option_x11" ]; then
		vmkdir /etc/xdg/autostart
		vinstall vmware-user-suid-wrapper/vmware-user.desktop 0644 /etc/xdg/autostart/
		vbin scripts/common/vmware-xdg-detect-de
		chmod 4755 "${DESTDIR}/usr/bin/vmware-user-suid-wrapper"
	fi

	if [ ! "$build_option_pam" ]; then
		rm -rf "${DESTDIR}/etc/pam.d/vmtoolsd"
	fi

	vsv vmtoolsd
	vsv vmware-vmblock-fuse
}
