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

_realname=XML-Parser
pkgname=perl-${_realname}
pkgver=2.47
pkgrel=3
pkgdesc="Expat-based XML parser module for perl"
arch=('i686' 'x86_64')
license=('GPL' 'PerlArtistic')
url="https://metacpan.org/dist/XML-Parser"
msys2_references=(
  "purl: pkg:cpan/TODDR/XML-Parser"
)
groups=('perl-modules')
depends=('perl' 'libexpat')
makedepends=('libexpat-devel' 'perl-devel' 'make' 'gcc')
replaces=('perlxml')
provides=("perlxml=${pkgver}")
options=('!emptydirs')
source=("https://www.cpan.org/authors/id/T/TO/TODDR/${_realname}-${pkgver}.tar.gz")
sha256sums=('ad4aae643ec784f489b956abe952432871a622d4e2b5c619e8855accbfc4d1d8')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # install module in vendor directories.
  perl Makefile.PL INSTALLDIRS=vendor
  make
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make test
}

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

  # remove perllocal.pod and .packlist.
  find "${pkgdir}" -name perllocal.pod -delete
  find "${pkgdir}" -name .packlist -delete

  # fix permissions
  find ${pkgdir}/usr -type f -name *.dll | xargs chmod 0755
}
