# 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=3
epoch=1
pkgdesc="Translate XML with PO files using W3C Internationalization Tag Set rules"
url="https://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
  0003-Fix-handling-of-untranslated-nodes.patch
)
b2sums=('316a27ad8c76d789e773298a656d9d2516277f65be968e583e953c886f94d0e2a2af49fedc79c0652571affac7851e5dd1b671dfb92b0db3537b9495c1a95616'
        '42e496c4d0aa3c5561d259c970cb9f43835e50c94b273bc01b4e388d1d6d16f05dc00cfded631cd8fdf2c1bf28f6ec64c1e626b5bdc50c15abfa7020d398673a'
        'e82d08e48c4528d8339fefe3d41e19b6c3a7ad265462bacfd50eecb30ddd878e591506d72e519e755704337090553fff2c171af97e4d01fb67941847049bed16'
        '570729c714a7aff687f347b7b0cfde8aa2eb0a6c0743ec34ed0fa328fe3a63bae969393d8f22fe1afa5873329e346e0bbbe9cf433130c224ec8a4bbf280f7ab8')
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

  # Fix handling of untranslated nodes
  ## https://github.com/itstool/itstool/pull/47
  git apply -3 ../0003-Fix-handling-of-untranslated-nodes.patch

  autoreconf -fvi
}

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

check() {
  cd $pkgname
  make check
}

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

# vim:set sw=2 sts=-1 et:
