# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=mtools
pkgver=4.0.44
pkgrel=1
epoch=1
pkgdesc="A collection of utilities to access MS-DOS disks"
arch=(x86_64)
url="https://www.gnu.org/software/mtools/"
license=(
  GPL-3.0-or-later
)
depends=(
  bash
  glibc
)
makedepends=(
  libx11
  texinfo
)
optdepends=(
  'libx11: required by floppyd'
  'libxau: required by floppyd'
)
backup=(etc/$pkgname.conf)
source=(https://ftp.gnu.org/gnu/mtools/$pkgname-$pkgver.tar.bz2{,.sig})
sha512sums=('e86de4db71deee0a5308e3e18a31580f9a10a924c207df763743ccf4506ddd62dc312e65ef2065c98f24296fd456beebc6594e267ddb828a02f3e3ee2d5e5228'
            'SKIP')
b2sums=('768ef4582b8f7abc30bfb2eac54dfd8032ff18f8b710550bf232bff46368a6aae0300569a5bf5aab6abd2460eeeaf3200901c1dd8d70b687a513804b0f9a8ad6'
        'SKIP')

prepare() {
  # comment entry in default config
  sed -e '/^SAMPLE FILE$/s:^:# :' -i $pkgname-$pkgver/mtools.conf
}

build() {
  local configure_options=(
    --prefix=/usr
    --mandir=/usr/share/man
    --infodir=/usr/share/info
    --sysconfdir=/etc
  )

  cd $pkgname-$pkgver
  ./configure "${configure_options[@]}"
  make
}

check() {
  make -k check -C $pkgname-$pkgver
}

package() {
  make DESTDIR="$pkgdir" install -C $pkgname-$pkgver
  install -vDm 644 $pkgname-$pkgver/mtools.conf -t "$pkgdir/etc/"
  install -vDm 644 $pkgname-$pkgver/{README,NEWS} -t "$pkgdir/usr/share/doc/$pkgname"
}
