# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=tpm2-tools
pkgver=5.6
pkgrel=1
pkgdesc='Trusted Platform Module 2.0 tools based on tpm2-tss'
arch=(x86_64)
url='https://github.com/tpm2-software/tpm2-tools'
license=(BSD-3-Clause)
depends=(
  glibc
)
makedepends=(
  curl
  openssl
  tpm2-tss
)
checkdepends=(
  cmocka
  expect
  iproute2
  python-yaml
  swtpm
  tpm2-abrmd
  util-linux-libs
  xxd
)
optdepends=('tpm2-abrmd: user space resource manager')
options=(!lto)
source=($url/releases/download/$pkgver/$pkgname-$pkgver.tar.gz{,.asc})
sha512sums=('14216f29ed3ecca5fbe356ed3744c8b6b25a62ff11b2aed596d11101328c8bfd29a02f6ca5a218f9a4477a5e9648c50f0ae96e71de0b4ff5ea1f98ebeeb73cd7'
            'SKIP')
b2sums=('fe88722c26d62128cd6dfbdd8ef2568656a75fe27b1443fed28387d0db1f50b7d0651819d34dfa98acde785b4cfb4e7c11420b110bb5333ed2bb6b67cdd4fc70'
        'SKIP')
  '5B482B8E3E19DA7C978E1D016DE2E9078E1F50C1'  # William Roberts (Bill Roberts) <william.c.roberts@intel.com>
  '6313E6DC41AAFC315A8760A414986F6944B1F72B'  # Desai, Imran (idesai-github-gpg) <imran.desai@intel.com>
  '6F72A30EEA41B9B548570AD20D0DB2B265493E29'  # ajay kishore <ajay.kishore@intel.com>
)

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr --enable-unit
  make
}

check() {
  cd $pkgname-$pkgver
  make check
}

package() {
  depends+=(
    curl libcurl.so
    openssl libcrypto.so
    tpm2-tss libtss2-esys.so libtss2-fapi.so libtss2-mu.so libtss2-rc.so libtss2-sys.so libtss2-tctildr.so
  )

  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -Dm644 docs/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}
