# Template file for 'imagescan-plugin-networkscan'
pkgname=imagescan-plugin-networkscan
version=1.1.3
revision=1
archs="i686 x86_64"
_bversion=3.63.0
_dst=ubuntu
_rel=18.04
build_style=fetch
depends="imagescan"
short_desc="Image Scan v3 Plugin for using Epson scanners over network"
maintainer="Giuseppe Fierro <gspe@ae-design.ws>"
license="custom:Proprietary"
homepage="http://support.epson.net/linux/en/imagescanv3.php"

case "${XBPS_TARGET_MACHINE}" in
	x86_64)
		_type=x64
		_arch=amd64
		_hash=318372a594fdff4d0f1d5dbe4d7d818036ee7f78edbb6d14ed1ad49b1c057c51
		;;
	i686)
		_type=x86
		_arch=i386
		_hash=412430d264fb3c3e80e5a22ecacec774b8a52d95b26db0930a17e4e58bd7e52c
		;;
esac

distfiles="https://download2.ebz.epson.net/imagescanv3/ubuntu/lts2/deb/${_type}/imagescan-bundle-${_dst}-${_rel}-${_bversion}.${_type}.deb.tar.gz"
checksum=${_hash}

do_extract() {
	bsdtar xzf ${XBPS_SRCDISTDIR}/${pkgname}-${version}/imagescan-bundle-${_dst}-${_rel}-${_bversion}.${_type}.deb.tar.gz
	ar x imagescan-bundle-${_dst}-${_rel}-${_bversion}.${_type}.deb/plugins/${pkgname}_${version}-1epson4${_dst}${_rel}_${_arch}.deb data.tar.xz
	bsdtar xf data.tar.xz
}

do_install() {
	vmkdir usr/share/licenses/imagescan-plugin-networkscan
	zcat usr/share/doc/imagescan-plugin-networkscan/COPYING.EPSON.en.txt.gz \
		> ${DESTDIR}/usr/share/licenses/imagescan-plugin-networkscan/COPYING.EPSON.en.txt
	zcat usr/share/doc/imagescan-plugin-networkscan/COPYING.EPSON.ja.txt.gz \
		> ${DESTDIR}/usr/share/licenses/imagescan-plugin-networkscan/COPYING.EPSON.ja.txt

	rm usr/share/doc/imagescan-plugin-networkscan/COPYING.EPSON.en.txt.gz
	rm usr/share/doc/imagescan-plugin-networkscan/COPYING.EPSON.ja.txt.gz

	vcopy usr /
}
