# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>

pkgname=ebook-tools
pkgver=0.2.2
pkgrel=9
pkgdesc='Tools for accessing and converting various ebook file formats'
arch=(x86_64 aarch64)
url='https://sourceforge.net/projects/ebook-tools/'
license=(MIT)
depends=(convertlit
         glibc
         libxml2
         libzip
         sh)
makedepends=(cmake)
source=(https://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
        crash-fix.patch)
sha256sums=('cbc35996e911144fa62925366ad6a6212d6af2588f1e39075954973bbee627ae'
            'ad556ce08909727a6022c9f1632086ccb8623a81a4f39cd34722e22116e14527')

prepare() {
  cd $pkgname-$pkgver
  patch -p2 -i ../crash-fix.patch # https://sourceforge.net/p/ebook-tools/bugs/8/
}

build() {
  cmake -B build -S $pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  install -Dm644 $pkgname-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}
