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

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

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

  patch -p1 -i ${srcdir}/XML-Parser-2.41.patch
}

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
}
