# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ndctl
pkgver=84
pkgrel=1
pkgdesc='Utility library for managing the libnvdimm (non-volatile memory device) sub-system in the Linux kernel'
arch=('x86_64' 'aarch64')
url="https://github.com/pmem/ndctl"
license=('LGPL-2.1-only' 'GPL-2.0-only' 'CC0-1.0' 'MIT')
depends=('iniparser' 'json-c' 'keyutils' 'kmod' 'libtraceevent' 'libtracefs' 'systemd-libs'
         'util-linux-libs')
makedepends=('git' 'asciidoctor' 'bash-completion' 'cmake' 'meson' 'systemd' 'xmlto')
source=("git+https://github.com/pmem/ndctl.git#tag=v$pkgver")
sha512sums=('864b53df51d630528e405c112b26764c707f9e9ccf5ea69bc9c11344b59161660b34ed60c1c33880c1e9d57c440e09bcde1fc74ce0a2759e6e93f93850ebf1cb')

prepare() {
  cd ndctl
  # fix location of modprobe.d conf
  sed -i "s|^modprobedatadir =.*|modprobedatadir = '/usr/lib/modprobe.d/'|" contrib/meson.build
}

build() {
  arch-meson ndctl build
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "$pkgdir"
}
