# Maintainer: Mark Wagie <mark dot wagie at proton dot me>
pkgname=packet
pkgver=0.6.1
pkgrel=3
pkgdesc="A Quick Share client for Linux"
arch=('x86_64')
url="https://github.com/nozwock/packet"
license=('GPL-3.0-or-later')
depends=(
	'libadwaita'
	'nautilus-python'
	'python-dbus'
	hicolor-icon-theme
	pango
	python-gobject
	python
	gtk4
	dbus
	gcc-libs
	glib2
	glibc
	dconf
)
makedepends=(
  'blueprint-compiler'
  'cargo'
  'git'
  'meson'
  'protobuf'
)

source=("git+https://github.com/nozwock/packet.git#tag=$pkgver")
sha256sums=('35dae9b816bc34d0ed09c6092855e7af70ba3fa324c92fba7136f8f501de458d')

prepare() {
  cd "$pkgname"
  export RUSTUP_TOOLCHAIN=stable
  cargo fetch --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
  export RUSTUP_TOOLCHAIN=stable
  arch-meson "$pkgname" build
  meson compile -C build
}

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

package() {
  meson install -C build --no-rebuild --destdir "$pkgdir"

  # Symlink Nautilus extension to exension directory
  install -d "$pkgdir/usr/share/nautilus-python/extensions"
  ln -s "/usr/share/$pkgname/plugins/packet_nautilus.py" \
    "$pkgdir/usr/share/nautilus-python/extensions/"
}
