# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=pkgfile
pkgver=21
pkgrel=2
pkgdesc="A pacman .files metadata explorer"
arch=('i686' 'x86_64')
url="https://github.com/falconindy/pkgfile"
license=('MIT')
makedepends=('pcre-devel' 'libarchive-devel' 'libcurl-devel' 'meson' 'clang' 'gcc')
depends=('libarchive' 'curl' 'pcre' 'pacman')
options=('emptydirs')
source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/falconindy/${pkgname}/archive/v${pkgver}.tar.gz"
        001-cygwin-alloca.patch)
install=pkgfile.install
sha256sums=('809d75738cae785839950c85371ac087bc3b450eed497a565eca01b653f254a5'
            '9281aa0964a912c3b698eea169ff698f7e24eff8e7ae5929c235b7fc58989de7')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/001-cygwin-alloca.patch
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  meson \
    -Dsystemd_units=false \
    build-${CARCH}
  ninja -v -C build-${CARCH}
}

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

  DESTDIR="${pkgdir}" ninja -C build-${CARCH} install
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
