# Maintainer: sunrisepeak <speakshen@163.com>
pkgname=xlings
pkgver=0.4.14
pkgrel=1
pkgdesc="A Developer's Toolkit for Programming Learning, Development, and Tutorial Creation"
arch=('x86_64')
url="https://github.com/openxlings/xlings"
license=('Apache-2.0')
depends=()
source=(
    "https://github.com/openxlings/xlings/releases/download/v${pkgver}/xlings-${pkgver}-linux-x86_64.tar.gz"
    "xlings-remove.hook"
)
sha256sums=(
    '4d5ba18fb5f8b32ec899c43c64719302445fe13eec952629f28cce9d8c400b71'
    'SKIP'
)

package() {
  cd "$srcdir/$pkgname-$pkgver-linux-x86_64"

  # Install binary
  install -Dm755 bin/xlings "$pkgdir/usr/bin/xlings"

  # Install all files to /usr/share/xlings
  install -d "$pkgdir/usr/share/$pkgname"
  cp -r . "$pkgdir/usr/share/$pkgname"

  chmod 766 "$pkgdir/usr/share/$pkgname/.xlings.json"

  # Set permissions for files
  # find "$pkgdir/usr/share/$pkgname" -type f -exec chmod 644 {} +
  # find "$pkgdir/usr/share/$pkgname" -type d -exec chmod 755 {} +

  # Add hooks
  install -Dm644 ../xlings-remove.hook "$pkgdir/usr/share/libalpm/hooks/xlings-remove.hook"
}
