# Maintainer: Toolybird <toolybird at tuta dot io>

# NOTES:
# 1. The upstream repo includes src for a C API library and some rust crates.
# This PKGBUILD is concerned *only* with the library. More details here:
# https://bugzilla.redhat.com/show_bug.cgi?id=2124697#c18

# 2. Library license clarification:
# https://bugzilla.redhat.com/show_bug.cgi?id=2124697#c13

# 3. crosvm license applies only to virtio-driver crate which is not built here. See:
# https://gitlab.com/libblkio/libblkio/-/commit/02ade52f495381719f049ebdd9575a66ce00ad00

# 4. This pkg uses Meson and a shell script to build Rust code. Not sure if the ArchWiki
# Rust package guidelines are applicable here or not, but try to follow them anyway.

#Included in Slint by Didier Spaier didieratslintdotfr
pkgname=libblkio
pkgver=1.3.0
pkgrel=1slint
export srcver=v$pkgver
slackdesc="$pkgname (High-performance block device I/O library with C API)"
docs=("license*" "README.html")
options=("nosrcpack")
url="https://gitlab.com/libblkio/libblkio"
license=(MIT Apache)
depends=(gcc-libs)
makedepends=(cargo git meson python-docutils)
source=(https://gitlab.com/libblkio/libblkio/-/archive/v1.3.0/libblkio-v1.3.0.tar.gz)


build() {
  cd $pkgname-$srcver
[ -f README.md ] && pandoc -f gfm -t html5 -o README.html README.md
   cargo fetch --locked --target x86_64-unknown-linux-gnu
  sed -i 's/--locked/--frozen/' src/cargo-build.sh
  meson setup --prefix=/usr build
  meson compile -C build
   # For some unknown reason this now fails with a permissions error on "/root/.cargo/registry/index/github.com-*"
  # Work around it by calling ninja directly..
  # meson install -C build --destdir "$PKG"
  DESTDIR="$PKG" ninja install -C build
}
