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

_realname=Module-Build-Tiny
pkgname=perl-${_realname}
pkgver=0.052
pkgrel=1
pkgdesc="A tiny replacement for Module::Build"
arch=('any')
url="https://metacpan.org/dist/Module-Build-Tiny"
msys2_references=(
  'purl: pkg:cpan/LEONT/Module-Build-Tiny'
)
groups=('perl-modules')
license=('PerlArtistic' 'GPL')
depends=('perl' 'perl-ExtUtils-Config' 'perl-ExtUtils-Helpers' 'perl-ExtUtils-InstallPaths')
options=('!emptydirs')
source=("https://cpan.metacpan.org/authors/id/L/LE/LEONT/${_realname}-${pkgver}.tar.gz")
sha256sums=('bd10452c9f24d4b4fe594126e3ad231bab6cebf16acda40a4e8dc784907eb87f')

build() {
  ( export PERL_MM_USE_DEFAULT=1 PERL5LIB=""                 \
      PERL_AUTOINSTALL=--skipdeps                            \
      PERL_MM_OPT="INSTALLDIRS=vendor DESTDIR='$pkgdir'"     \
      PERL_MB_OPT="--installdirs vendor --destdir '$pkgdir'" \
      MODULEBUILDRC=/dev/null

    cd "${srcdir}/${_realname}-${pkgver}"
    /usr/bin/perl Build.PL
    ./Build
  )
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ( export PERL_MM_USE_DEFAULT=1 PERL5LIB=""
    ./Build test
  )
}

package() {
  cd ${_realname}-${pkgver}
  ( export PERL_AUTOINSTALL=--skipdeps                       \
      PERL_MM_OPT="INSTALLDIRS=vendor DESTDIR='$pkgdir'"     \
      PERL_MB_OPT="--installdirs vendor --destdir '$pkgdir'"
    ./Build install
  )
  find "$pkgdir" -name .packlist -o -name perllocal.pod -delete
}
