# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=smartmontools
pkgver=7.4
pkgrel=1
pkgdesc='Control and monitor S.M.A.R.T. enabled ATA and SCSI Hard Drives'
url='http://smartmontools.sourceforge.net'
license=('GPL')
arch=('x86_64')
depends=('gcc-libs' 'libcap-ng' 'bash' 'systemd-libs')
makedepends=('systemd')
optdepends=('s-nail: to get mail alerts to work')
backup=('etc/smartd.conf'
        'etc/conf.d/smartd')
source=("https://downloads.sourceforge.net/sourceforge/${pkgname}/${pkgname}-${pkgver}.tar.gz"{,.asc}
        'smartd.conf')
sha256sums=('e9a61f641ff96ca95319edfb17948cd297d0cd3342736b2c49c99d4716fb993d'
            'SKIP'
            'c2c0f2f6b4a3f3d76da1c7706139297aef6e3f2a705eb7fdd800544812427c74')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --with-drivedbdir \
    --with-libcap-ng=yes \
    --with-libsystemd=yes \
    --with-systemdsystemunitdir=/usr/lib/systemd/system \
    --with-systemdenvfile=/etc/conf.d/smartd \
    --with-smartdscriptdir=/usr/share/smartmontools \
    --with-smartdplugindir=/usr/share/smartmontools/smartd_warning.d

  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  sed -i -e "s:sysconfig/smartmontools:conf.d/smartd:g" smartd.service
  sed -i -e "s:smartd_opts:SMARTD_ARGS:g" smartd.service

  make DESTDIR="${pkgdir}" install

  rm -rf "${pkgdir}"/etc/rc.d
  install -D -m0644 "${srcdir}"/smartd.conf "${pkgdir}/etc/conf.d/smartd"
}
