# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgname=mtools
pkgver=%version%
pkgrel=%release%
epoch=1
pkgdesc="A collection of utilities to access MS-DOS disks"
arch=(x86_64)
url="https://www.gnu.org/software/mtools/"
license=(GPL3)
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=('b70e483688124a653dd333ab127494dab12d413809680a4846dc4ae5c166a0b9938a2ab290e518c1f1a5b18ed96d2c2a29d92d61b16b772a4ab5e495379fe410'
            'SKIP')
b2sums=('d000839bbb6bc647eb5a32b08b40b1350cd0a85fd564f0705ecbfe20f8f4ef21bf2d59cd0ccd7a159c829c019c6c2f3cbdef82ff3f4a9e8828cc13d44ddabd1d'
        '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"
}
