# Template file for 'foomatic-db'
# Update when there is a new commit at https://github.com/OpenPrinting/foomatic-db.
pkgname=foomatic-db
version=20210104
revision=1
_commit=28466ef2f9f931f49816ed70c499001d1783f5cb
build_style=gnu-configure
hostmakedepends="xmlstarlet tar automake"
short_desc="OpenPrinting printer support - database"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later, MIT"
homepage="https://wiki.linuxfoundation.org/openprinting/database/foomatic"
distfiles="https://github.com/OpenPrinting/foomatic-db/archive/${_commit}.tar.gz"
checksum=eb412f7967300ae49bd22a886ecd478767828eff5da4d1e875c3409898265866

pre_configure() {
	# Taken 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
}
