makedepends=(rustc libcap-ng libseccomp)

description="Vhost-user virtio-fs device backend written in Rust"
url="https://gitlab.com/virtio-fs/virtiofsd"

packager="Great-OS Team"
maintainer="Great-OS Team"

name=virtiofsd
version=1.13.0
release=1

source=(https://gitlab.com/virtio-fs/virtiofsd/-/archive/v$version/virtiofsd-v$version.tar.gz)

prepare() {
  cd $name-v$version
  sed 's/libexec/lib/' -i 50-$name.json
  cargo fetch --locked --target "x86_64-unknown-linux-gnu"
}

build() { 
  cd $name-v$version
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --frozen --release --all-features
}

package() {
  cd $name-v$version;
  install -vDm 755 target/release/$name -t "$PKG/usr/lib/"
  install -vDm 644 50-$name.json -t "$PKG/usr/share/qemu/vhost-user/"
  install -vDm 644 LICENSE* -t "$PKG/usr/share/licenses/$name/"
  install -vDm 644 README.md doc/*.md -t "$PKG/usr/share/doc/$name/"
}
