# Template file for 'hplip-plugin'
# This package must be kept in sync with hplip
pkgname=hplip-plugin
version=3.23.12
revision=1
archs="i686 x86_64 armv[67]l aarch64"
hostmakedepends="tar"
short_desc="Binary plugin for HPs hplip printer driver library"
maintainer="biopsin <biopsin@teknik.io>"
license="custom:proprietary"
homepage="https://developers.hp.com/hp-linux-imaging-and-printing/binary_plugin.html"
changelog="https://developers.hp.com/hp-linux-imaging-and-printing/release_notes"
distfiles="https://developers.hp.com/sites/default/files/hplip-${version}-plugin.run"
checksum=402799c0c8e2efafc8452a5a0929b06efbfd7bee2ff8ce060bdc447b2a34067f
repository=nonfree
restricted=yes

ignore_elf_dirs="/usr/share/hplip"

do_extract() {
	/bin/sh ${XBPS_SRCDISTDIR}/${pkgname}-${version}/hplip-${version}-plugin.run \
	--noexec --target ${wrksrc}
}

do_install() {
	local _arch _f

	case "$XBPS_TARGET_MACHINE" in
		i686) _arch='x86_32' ;;
		x86_64) _arch='x86_64' ;;
		armv[67]l) _arch='arm32' ;;
		aarch64) _arch='arm64' ;;
	esac

	vinstall plugin.spec 0644 usr/share/hplip

	for _f in hp_laserjet_*.fw.gz; do
		vinstall "${_f}" 0644 usr/share/hplip/data/firmware
	done

	vinstall "fax_marvell-${_arch}.so" 0755 \
		usr/share/hplip/fax/plugins fax_marvell.so

	vinstall "hbpl1-${_arch}.so" 0755 \
		usr/share/hplip/prnt/plugins hbpl1.so

	vinstall "lj-${_arch}.so" 0755 \
		usr/share/hplip/prnt/plugins lj.so

	for _f in bb_*-"${_arch}.so"; do
		vinstall "${_f}" 0755 \
			usr/share/hplip/scan/plugins "${_f/-${_arch}}"
	done
	vsconf 40-libsane.rules

	vlicense license.txt

	cat <<-EOF > hplip.state
		[plugin]
		installed = 1
		eula = 1
		version = ${version}
		EOF

	vinstall hplip.state 0644 var/lib/hp
}
