# Maintainer: noxygalaxy <noxycraftyt@gmail.com>
pkgname=bongkert-studio
pkgver=${BONGKERT_VERSION:?BONGKERT_VERSION must be set}
pkgrel=1
pkgdesc="Free and open source video editor"
arch=('x86_64' 'aarch64')
url="https://bongkert-studio.pages.dev"
license=('AGPL-3.0-or-later')
depends=('glibc' 'gtk3' 'fontconfig' 'freetype2' 'libxkbcommon' 'mesa' 'alsa-lib')
options=('!strip' '!debug')
source=()

stage=${BONGKERT_STAGE:?BONGKERT_STAGE must point at the staged folder}

package() {
  install -Dm755 "$stage/bongkert-studio" "$pkgdir/opt/bongkert-studio/bongkert-studio"
  install -d "$pkgdir/opt/bongkert-studio/lib"
  cp -a "$stage"/lib/. "$pkgdir/opt/bongkert-studio/lib/"

  install -d "$pkgdir/usr/bin"
  printf '#!/bin/sh\nexec /opt/bongkert-studio/bongkert-studio "$@"\n' > "$pkgdir/usr/bin/bongkert-studio"
  chmod 755 "$pkgdir/usr/bin/bongkert-studio"
  install -Dm644 "$stage/bongkert-studio.desktop" "$pkgdir/usr/share/applications/bongkert-studio.desktop"
  sed -i 's|^Exec=bongkert-studio|Exec=/opt/bongkert-studio/bongkert-studio %U|' "$pkgdir/usr/share/applications/bongkert-studio.desktop"
  install -Dm644 "$stage/bongkert-studio.png" "$pkgdir/usr/share/icons/hicolor/256x256/apps/bongkert-studio.png"

  install -Dm644 "$stage/LICENSE" "$pkgdir/usr/share/licenses/bongkert-studio/LICENSE"
  install -Dm644 "$stage/THIRD_PARTY_NOTICES.md" "$pkgdir/usr/share/licenses/bongkert-studio/THIRD_PARTY_NOTICES.md"
}
