# Template file for 'foomatic-db-nonfree'
# Update when there is a new commit at https://github.com/OpenPrinting/foomatic-db-nonfree.
pkgname=foomatic-db-nonfree
version=20210104
revision=1
_commit=6ddae02ac89240c019f8b5026cfe70e30fd2b3db
build_style=gnu-configure
hostmakedepends="tar xmlstarlet automake"
short_desc="OpenPrinting printer support - nonfree database"
maintainer="fosslinux <fosslinux@aussies.space>"
license="custom:Various Nonfree"
homepage="https://wiki.linuxfoundation.org/openprinting/database/foomatic"
distfiles="https://github.com/OpenPrinting/foomatic-db-nonfree/archive/${_commit}.tar.gz"
checksum=958c1067a24c37cb753ee2b4aeb9e8325629f4363ce9e108f1f6d0f828e5b7c5
repository="nonfree"

pre_configure() {
	# From make_configure
	aclocal
	autoconf
	sed -i "s=\#include \<xmlversion.h\>=\#include \<libxml/xmlversion.h\>=g" configure
}

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
}
