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

_gitname="$(basename $(pwd))"
pkgname=("melawy-$_gitname")
pkgver=1.10
pkgrel=1
pkgdesc="$(head -n 2 README.md | tail -n 1)"
url="https://github.com/Melawy/$_gitname"
arch=("any")
license=("AGPL3")
depends=("refind")
optdepends=()
makedepends=("git")
backup=()
provides=("${pkgname}")
conflicts=("${pkgname}")
source=("git+$url.git")
sha256sums=("SKIP")
validpgpkeys=('95F48000540A4DB146583A47C49B5E77FD80302D')

# 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)"
}

package() {
  install -Dm644 "${srcdir}/$_gitname/10-refind-menu-pre-install.hook" "${pkgdir}/usr/share/libalpm/hooks/10-refind-menu-pre-install.hook"
  install -Dm644 "${srcdir}/$_gitname/60-refind-menu-remove.hook"      "${pkgdir}/usr/share/libalpm/hooks/60-refind-menu-remove.hook"
  install -Dm644 "${srcdir}/$_gitname/90-refind-menu-install.hook"     "${pkgdir}/usr/share/libalpm/hooks/90-refind-menu-install.hook"
  install -dm755 "${pkgdir}/etc/refind-menu-generator"
  install -Dm644 "${srcdir}/$_gitname/menu-end.txt"                    "${pkgdir}/etc/refind-menu-generator/menu-end.txt"
  install -Dm644 "${srcdir}/$_gitname/menu-template.txt"               "${pkgdir}/etc/refind-menu-generator/menu-template.txt"
  install -Dm644 "${srcdir}/$_gitname/menu-template.txt"               "${pkgdir}/etc/refind-menu-generator/menu-template-vmlinuz-first.txt"
  install -Dm755 "${srcdir}/$_gitname/refind-menu-generator"           "${pkgdir}/usr/bin/refind-menu-generator"
}
