#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgbase=libcap-ng
pkgname=(libcap-ng python-capng)
pkgver=0.8.4
pkgrel=01
pkgdesc='A library for Linux that makes using posix capabilities easy'
url='https://people.redhat.com/sgrubb/libcap-ng/'
depends=(glibc)
makedepends=(python swig)
#options=(debug)  # uncomment if you want libcap-ng-debug package made
source=(https://github.com/stevegrubb/libcap-ng/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)

_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

prepare() {
  cd $pkgbase-$pkgver
  # make stupid autotools happy -_-
  touch NEWS
  autoreconf -fiv
}

build() {
  cd $pkgbase-$pkgver
  ./configure \
    --prefix=/usr \
    --enable-static=no \
    --without-python \
    --with-python3
  make
}

check() {
  make check -C $pkgbase-$pkgver
}

package_libcap-ng() {
  provides=(libcap-ng.so libdrop_ambient.so)

  make DESTDIR="$pkgdir" install -C $pkgbase-$pkgver

  (
    cd "$pkgdir"
    _pick python-capng usr/lib/python*
  )
}

package_python-capng() {
  pkgdesc+=' (Python bindings)'
  depends+=(libcap-ng.so)
  provides=(python-libcap-ng)

  mv -v python-capng/* "$pkgdir"
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=(GPL-2.0-or-later LGPL-2.1-or-later)

sha256sums=(5615c76a61039e283a6bd107c4faf345ae5ad4dcd45907defe5e474d8fdb6fd2) # libcap-ng-0.8.4.tar.gz
