### this file is sourced not run
PKGVER=0.24.1
PKGBUILD=1
PKGARCH=x86_64

# source: BLFS 11.3
TARBALL=p11-kit-$PKGVER.tar.xz
MD5SUM=67b2539bdca6b4bedaeecc12864d2796
SRC_URL=https://github.com/p11-glue/p11-kit/releases/download/$PKGVER/$TARBALL
BUNDLE=

SLACKREQ='' 
SLACKDESC="libp11kit: libp11kit $PKGVER (PKCS #11 library)
libp11kit: 
libp11kit: The p11-kit package provides a way to load and enumerate PKCS #11 (a 
libp11kit: Cryptographic Token Interface Standard) modules.
libp11kit: 
libp11kit: https://p11-glue.github.io/p11-glue/p11-kit.html
libp11kit: 
libp11kit: 
libp11kit: 
libp11kit: 
libp11kit: 
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/p11* &&

	# BLFS 9.0 / BLFS 11.3 patch
	sed '20,$ d' -i trust/trust-extract-compat &&
	cat >> trust/trust-extract-compat.in << "EOF"
# Copy existing anchor modifications to /etc/ssl/local
/usr/libexec/make-ca/copy-trust-modifications

# BLFS 9.0 - Generate a new trust store
#/usr/sbin/make-ca -f -g

# BLFS 11.3 - Update trust stores
/usr/sbin/make-ca -r
EOF

}

### default pkg_package
### build
pkg_build() {
	MESONFLAGS="$MESONFLAGS --buildtype=release -Dtrust_paths=/etc/pki/anchors"
	pkg_build_meson p11-build &&
	pkg_build_slackdesc &&

	ln -sfv /usr/libexec/p11-kit/trust-extract-compat \
        /usr/bin/update-ca-certificates &&

	# libnssckbi compat
	ln -sfv ./pkcs11/p11-kit-trust.so /usr/$LIBDIR/libnssckbi.so
}
