# Maintainer: aur.chaotic.cx

_pkgname="fuse3-p7zip"
pkgname="$_pkgname-git"
pkgver=2.2.1.r0.gc39a694
pkgrel=1
pkgdesc="A fuse3 file system that uses the 7zip library to mount archives"
url="https://github.com/andrew-grechkin/fuse3-p7zip"
license=('GPL-3.0-only')
arch=('x86_64')

depends=(
  '7zip'
  'fuse3'
)
makedepends=(
  'cmake'
  'git'
  'go-md2man'
  'ninja'
)

provides=("$_pkgname")
conflicts=("$_pkgname")

_pkgsrc="$_pkgname"
source=("$_pkgsrc"::"git+$url.git")
sha256sums=('SKIP')

prepare() {
  cd "$_pkgsrc"
  git submodule update --init --depth=1
}

pkgver() {
  cd "$_pkgsrc"
  git describe --long --tags --abbrev=7 --exclude='*[a-zA-Z][a-zA-Z]*' \
    | sed -E 's/^[^0-9]*//;s/([^-]*-g)/r\1/;s/-/./g'
}

build() {
  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -G Ninja
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX='/usr'
    -Wno-author
  )

  cmake "${_cmake_options[@]}"
  cmake --build build

  go-md2man -in="$_pkgsrc/README.md" -out="$_pkgname.1"
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -Dm644 "$_pkgname.1" -t "$pkgdir/usr/share/man/man1/"
}
