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

_realname=XML-LibXML
pkgname=perl-${_realname}
pkgver=2.0210
pkgrel=4
pkgdesc="Interface to the libxml library"
arch=('i686' 'x86_64')
license=('GPL' 'PerlArtistic')
url="https://metacpan.org/dist/XML-LibXML"
msys2_references=(
  "cpe: cpe:/a:xml-libxml_project:xml-libxml"
  "purl: pkg:cpan/SHLOMIF/XML-LibXML"
)
groups=('perl-modules')
depends=('perl' 'perl-Alien-Libxml2' 'perl-XML-SAX' 'perl-XML-NamespaceSupport')
#checkdepends=('perl-Test-Pod' 'perl-Test-LeakTrace' 'perl-CPAN-Changes' 'perl-URI')
makedepends=('perl-devel' 'libxml2-devel' 'perl-Path-Tiny' 'make' 'gcc')
#replaces=('perlxml')
#provides=("perlxml=${pkgver}")
install=perl-xml-libxml.install
options=('!emptydirs')
source=("https://cpan.metacpan.org/authors/id/S/SH/SHLOMIF/${_realname}-${pkgver}.tar.gz")
sha256sums=('a29bf3f00ab9c9ee04218154e0afc8f799bf23674eb99c1a9ed4de1f4059a48d')

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
}
