# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=mtools
pkgver=4.0.46
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=('53f70ae5baece113dc27eadd226a75e236c99dee46afddbd80ad219ba9105549cf0e2fa35df4db5aff81ccfff71b4327f67d37cd0daf4ee5a96383a3352ed446'
            'SKIP')
b2sums=('c37f2df4cb3415fb97d7e54dc5f44c34e9c997ed4a44feaca62e2a6aff47c2eb346e43c36cbfcd1a5e0a9daa2b67dbbe759f4d7a49fbdc44c2fe3753770930ec'
        'SKIP')
validpgpkeys=('51A23D9D7C4DF41AA48FA893E99CF5537790B839') # Alain KNAFF <alain@knaff.lu>

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"
}
