# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=open-vm-tools
epoch=6
pkgver=12.5.0
pkgrel=1
pkgdesc='The Open Virtual Machine Tools (open-vm-tools) are the open source implementation of VMware Tools'
arch=('x86_64')
url='https://github.com/vmware/open-vm-tools'
license=('LGPL-2.1-only')
depends=('fuse3' 'icu' 'iproute2' 'libdnet' 'libmspack' 'libsigc++'
         'libxcrypt' 'libcrypt.so' 'libxss' 'lsb-release' 'procps-ng'
         'uriparser' 'which' 'xmlsec')
makedepends=('chrpath' 'doxygen' 'gtkmm3' 'libxtst' 'python' 'rpcsvc-proto' 'glib2-devel')
checkdepends=('cunit')
optdepends=('gtkmm3: DnD/CP plugin'
            'libxtst: DnD/CP, resolution set plugins'
            'netctl: suspend-resume network state'
            'networkmanager: suspend-resume network state')
backup=('etc/pam.d/vmtoolsd'
        'etc/vmware-tools/vgauth.conf'
        'etc/xdg/autostart/vmware-user.desktop')
options=('docs')
source=("$pkgname-$pkgver.tar.gz::https://github.com/vmware/open-vm-tools/archive/stable-${pkgver/_/-}.tar.gz"
        'vmtoolsd.pam'
        'vmtoolsd.service'
        'vmware-vmblock-fuse.service')
sha256sums=('a52182c7e6b5df41bb317625e9d8592ecdb9db814d1c2c9b7cdb91a77f8c0640'
            '9848f4b621bb1134e463fea099f03933cf3f48f1ac5e580228abef264d26137e'
            '0626cc86232f75a7286c24c52d6b44260bba55e2e96c17fa22ed36decb61a4d9'
            '99e3cc1da20a751049144cc02dec77174a55109b5b5960e1facd78709da7724f')

prepare() {
  cd "$srcdir/$pkgname-stable-${pkgver}/open-vm-tools/"

  autoreconf -vi
}

build() {
  cd "$srcdir/$pkgname-stable-${pkgver}/open-vm-tools/"

  sh ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --with-udev-rules-dir=/usr/lib/udev/rules.d \
    --without-kernel-modules
  make
}

check() {
  cd "$srcdir/$pkgname-stable-${pkgver}/open-vm-tools/"

  make check
}

package() {
  cd "$srcdir/$pkgname-stable-${pkgver}/open-vm-tools/"

  make install DESTDIR="$pkgdir"
  chmod 7755 "$pkgdir"/usr/bin/vmware-user-suid-wrapper

  # install vmware-xdg-detect-de
  install -D -m0755 scripts/common/vmware-xdg-detect-de "$pkgdir"/usr/bin/vmware-xdg-detect-de

  # install pam configuration
  install -D -m0644 "$srcdir"/vmtoolsd.pam "$pkgdir"/etc/pam.d/vmtoolsd

  # install systemd files
  install -D -m0644 "$srcdir"/vmtoolsd.service "$pkgdir"/usr/lib/systemd/system/vmtoolsd.service
  install -D -m0644 "$srcdir"/vmware-vmblock-fuse.service "$pkgdir"/usr/lib/systemd/system/vmware-vmblock-fuse.service
}
