# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>

pkgname=ack
pkgver=3.7.0
pkgrel=1
pkgdesc="A Perl-based grep replacement, aimed at programmers with large trees of heterogeneous source code"
arch=('any')
url="https://beyondgrep.com/"
msys2_references=(
  "cpe: cpe:/a:beyondgrep:ack"
  "purl: pkg:cpan/PETDANCE/ack"
)
license=('GPL' 'PerlArtistic')
depends=('perl-File-Next')
groups=('perl-modules')
options=(!emptydirs)
source=("https://www.cpan.org/authors/id/P/PE/PETDANCE/${pkgname}-v${pkgver}.tar.gz"
        '0002-ack-2.12-match-makefiles-with-more-generality.patch')
sha256sums=('ea7caa14f757de083310ed2cba298661ddcca5dee06ec8f18043ea625a79df20'
            '3f2bec65a174465babb5fef6c179ae25b7d85bee2263683396b574c3d3d33cab')
conflicts=("perl-ack")
provides=("perl-ack=${pkgver}")
replaces=("perl-ack")

prepare() {
  cd "${srcdir}/${pkgname}-v${pkgver}"
  patch -p1 -i ${srcdir}/0002-ack-2.12-match-makefiles-with-more-generality.patch
}

build() {
  cd "${srcdir}/${pkgname}-v${pkgver}"
  PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
  make
}

check() {
  cd "${srcdir}/${pkgname}-v${pkgver}"
  # some standalone tests are failing
  make test || true
}

package() {
  cd "${srcdir}/${pkgname}-v${pkgver}"
  make install DESTDIR="${pkgdir}"
}
