# Maintainer: Valeria Fadeeva <valeria@fadeeva.me>

_gitname="$(basename $(pwd))"
pkgname=("$_gitname")
pkgver=1.4
pkgrel=1
pkgdesc="$(head -n 2 README.md | tail -n 1)"
arch=('any')
url="https://git.melawy.ru/Updater/$_gitname"
license=('AGPL')
depends=("melawy-arch-linux-updater")
optdepends=()
makedepends=("git")
backup=()
provides=("${pkgname}")
conflicts=("${pkgname}")
source=("git+$url.git")
sha256sums=("SKIP")
validpgpkeys=('BC8B600E8DDA1F4CB77B10D2BA803A261A5EE6B8')

# pkgver() {
#       cd "$srcdir/$_gitname"
#       printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
# }

pkgver() {
        cd "$srcdir/$_gitname"
        printf "1.%s" "$(git rev-list --count HEAD)"
}

build() {
  cd "$_gitname"
  cargo build --release
}

package() {
  install -dm755 "${pkgdir}/usr/bin/"
  install -m755 "${srcdir}/$_gitname/target/release/melawy-arch-linux-updater-tray-icon" "${pkgdir}/usr/bin/"

  install -d "$pkgdir/usr/share/applications/"
  install -Dm644 "${srcdir}/$_gitname/melawy-arch-linux-updater-tray-icon.desktop" "$pkgdir/usr/share/applications/"

  install -d "$pkgdir/etc/skel/.config/autostart/"
  install -Dm644 "${srcdir}/$_gitname/melawy-arch-linux-updater-tray-icon.desktop" "$pkgdir/etc/skel/.config/autostart/"

  install -d "$pkgdir/usr/share/skel/.config/autostart/"
  install -Dm644 "${srcdir}/$_gitname/melawy-arch-linux-updater-tray-icon.desktop" "$pkgdir/usr/share/skel/.config/autostart/"
}
