# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=guacamole-dotool
pkgver=0.2.0
pkgrel=1
pkgdesc="Guacamole CLI client for scripting"
url="https://github.com/jirutka/guacamole-dotool"
# riscv64,s390x: memory access out of bounds in @rollup/wasm-node
# x86: textrels
arch="all !riscv64 !s390x !x86"
# NOTE: This includes licenses of bundled npm packages.
license="MIT AND Apache-2.0 AND ISC AND BSD-3-Clause AND BSD-2-Clause"
depends="nodejs"
makedepends="
	giflib-dev
	npm
	pango-dev
	pixman-dev
	"
subpackages="$pkgname-dbg"
source="https://github.com/jirutka/guacamole-dotool/archive/v$pkgver/guacamole-dotool-$pkgver.tar.gz"
options="net"

build() {
	npm clean-install --build-from-source
	npm run bundle
}

check() {
	rm -rf node_modules package.json
	./dist/$pkgname.mjs --help
}

package() {
	mkdir -p "$pkgdir"/usr/lib/$pkgname
	cp -r dist/* "$pkgdir"/usr/lib/$pkgname/

	cd "$pkgdir"

	strip usr/lib/$pkgname/libs/*.node

	mkdir -p usr/bin
	ln -s ../lib/$pkgname/$pkgname.mjs usr/bin/$pkgname
}

dbg() {
	depends="$pkgname=$pkgver-r$pkgrel"
	default_dbg

	amove usr/lib/$pkgname/*.map
}

sha512sums="
3d052a9ae325464a54af14f0f26c6d7e6134130df902deabdfef8f474f873ebe654f2bde660551550f1e983190be425c3ab39b7624561241d9669b6d448f7a24  guacamole-dotool-0.2.0.tar.gz
"
