# Template file for 'foomatic-db-nonfree'
# Note: update the version=<date> regularly like once/month.
pkgname=foomatic-db-nonfree
version=20201129
revision=1
create_wrksrc=yes
build_style=gnu-configure
hostmakedepends="tar xmlstarlet"
short_desc="OpenPrinting printer support - nonfree database"
maintainer="fosslinux <fosslinux@aussies.space>"
license="custom:Various Nonfree"
homepage="https://wiki.linuxfoundation.org/openprinting/database/foomatic"
repository="nonfree"

do_fetch() {
	$XBPS_FETCH_CMD https://www.openprinting.org/download/foomatic/${pkgname}-current.tar.gz
}

do_extract() {
	bsdtar -xf ${XBPS_BUILDDIR}/${pkgname}-current.tar.gz \
		--strip-components=1 -C ${wrksrc}
}

post_install() {
	for i in db/source/driver/*.xml; do
		if grep -q licensetext $i; then
			xml sel -t -v '//driver/licensetext/en/text()' $i | sed "s/^ *//" \
				> "LICENSE-$(basename $i .xml).txt"
			vlicense "LICENSE-$(basename $i .xml).txt"
		fi
	done
}
