# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Michael Pusterhofer <pusterhofer(at)student(dot)tugraz(dot)at>

pkgname=itstool
pkgver=2.0.7
pkgrel=2.1
epoch=1
pkgdesc="XML to PO and back again"
url="http://itstool.org/"
arch=(any)
license=(GPL-3.0-only)
depends=(
  docbook-xml
  libxml2
  python
)
makedepends=(git)
source=(
  "git+https://github.com/itstool/itstool?signed#tag=$pkgver"
  0001-Fix-the-crash-from-912099.patch
  0002-Fix-insufficiently-quoted-regular-expressions.patch
)
b2sums=('316a27ad8c76d789e773298a656d9d2516277f65be968e583e953c886f94d0e2a2af49fedc79c0652571affac7851e5dd1b671dfb92b0db3537b9495c1a95616'
        '42e496c4d0aa3c5561d259c970cb9f43835e50c94b273bc01b4e388d1d6d16f05dc00cfded631cd8fdf2c1bf28f6ec64c1e626b5bdc50c15abfa7020d398673a'
        'da79a18dee20e10c9b9e49824a09a00cab4b22abab83f3cb00d0d899216d0cf8b9d56b79f46714360312e87ec04501f6fedb3e2b8e2dcabca18c8777361f6490')
validpgpkeys=(
  4E03CB89E1C8ED8E049367ABE5D9AD24CC3ADF80 # Shaun McCance <shaunm@redhat.com>
)

prepare() {
  cd $pkgname

  # https://src.fedoraproject.org/rpms/itstool/blob/rawhide/f/itstool-2.0.5-fix-crash-wrong-encoding.patch
  git apply -3 ../0001-Fix-the-crash-from-912099.patch

  # Fix insufficiently quoted regular expressions / Python 3.12
  ## https://github.com/itstool/itstool/pull/51
  git apply -3 ../0002-Fix-insufficiently-quoted-regular-expressions.patch

  autoreconf -fvi
}

build() {
  cd $pkgname
  ./configure --prefix=/usr
  make
}

check() {
  cd $pkgname
  make check
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
}
