# Contributor:  David Runge <dvzrv@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: Hugo Doria <hugo@archlinux.org>

_pkgname=libcap
pkgname=static-compat-$_pkgname
pkgver=2.67
pkgrel=1
pkgdesc="POSIX 1003.1e capabilities"
arch=(x86_64)
url="https://sites.google.com/site/fullycapable/"
license=(GPL2)
depends=(glibc-static-compat)
makedepends=(static-compat-environment)
options=(staticlibs)
source=("https://kernel.org/pub/linux/libs/security/linux-privs/${_pkgname}2/${_pkgname}-$pkgver.tar."{xz,sign})
sha512sums=('2e52c5a571cc1565e6829b0889f63216af10dfd9a86485f8ae7d0fcf4cc0db96aa21eb2ddea29e8dadf41a1194e91fb5961fe84ba07beb2ce950b6131be099d4'
            'SKIP')
b2sums=('bd9be22e439397a3c1726093cfee2410df93773b3139d50a1cdc10daecb666ddb9b64daded6e0ec9f2fd6defd16ea156dbd66bd55360ea266131f31ea0f0e989'
        'SKIP')
validpgpkeys=(38A644698C69787344E954CE29EE848AE2CCF3F4) # Andrew G. Morgan <morgan@kernel.org>

build() {
  source static-compat-environment
  export DYNAMIC=no PAM_CAP=no KERNEL_HEADERS=$static_compat_prefix/include lib=lib
  make prefix=$static_compat_prefix sbindir=bin -C $_pkgname-$pkgver
}

check() {
  source static-compat-environment
  export DYNAMIC=no PAM_CAP=no KERNEL_HEADERS=$static_compat_prefix/include lib=lib
  make test -k -C $_pkgname-$pkgver
}

package() {
  source static-compat-environment
  export DYNAMIC=no PAM_CAP=no KERNEL_HEADERS=$static_compat_prefix/include lib=lib
  make DESTDIR="$pkgdir" RAISE_SETFCAP=no lib=lib prefix=$static_compat_prefix sbindir=bin install -C $_pkgname-$pkgver
  find "$pkgdir" -iname '*.so*' -delete
  rm -r "$pkgdir/$static_compat_prefix"/share
}
