# Tanım: HP DeskJet, OfficeJet, Photosmart, Business Inkjet ve bazı LaserJet serileri için sürücü
# URL: http://hplipopensource.com/hplip-web/index.html
# Paketçi: milisarge
# Gerekler: v4l-utils libgphoto2 python3-sip python3-qt5 avahi python3 wget ghostscript foomatic-db foomatic-db-engine usbutils sane xsane cups cups-filters rpcbind libusb libusb-compat net-snmp dbus-python python3-gobject python-notify python3-pillow python3-reportlab
# Grup: sürücü

isim=hplip
surum=3.18.7
devir=1
kaynak=(http://downloads.sourceforge.net/$isim/$isim-$surum.tar.gz
        disable_upgrade.patch
        0022-Add-include-cups-ppd.h-in-various-places-as-CUPS-2.2.patch
        0023-Fix-handling-of-unicode-filenames-in-sixext.py.patch)

derle() {
	cd $isim-$surum
	
	patch -Np0 -i ${SRC}/disable_upgrade.patch

	# add missing 'include <cups/ppd.h>' at various places
	patch -Np1 -i ${SRC}/0022-Add-include-cups-ppd.h-in-various-places-as-CUPS-2.2.patch
	# fix some handling unicode file names FS#58412
	patch -Np1 -i ${SRC}/0023-Fix-handling-of-unicode-filenames-in-sixext.py.patch
    export PYTHON=/usr/bin/python3
	export AUTOMAKE='automake --foreign'
	autoreconf --force --install
	
	./configure --prefix=/usr \
	 --enable-qt5 \
	 --disable-qt4 \
	 --disable-policykit \
	 --enable-hpcups-install \
	 --enable-cups-drv-install \
	 --enable-pp-build #--help
	make
	make -j1 rulesdir=/usr/lib/udev/rules.d DESTDIR="$PKG/" install

	# remove config provided by sane and autostart of hp-daemon
	rm -rf "$PKG"/etc/{sane.d,xdg}
	install -dm755 ${PKG}/etc/sane.d/dll.d
	echo hpaio > ${PKG}/etc/sane.d/dll.d/hpaio

	# remove HAL .fdi file because HAL is no longer used
	rm -vrf "$PKG"/usr/share/hal
    #systemd sil
    rm -vrf "$PKG"/usr/lib/systemd
	# remove rc script
	rm -vrf "$PKG"/etc/init.d
	#doc sil
	rm -vrf "$PKG"/usr/share/doc

	# add mixed license file
	install -Dt "${PKG}"/usr/share/licenses/${isim} -m644 COPYING
	cd $PKG/usr/share/hplip
    grep -rli python | xargs sed -i "s/\/usr\/bin\/env python/\/usr\/bin\/env python3/g"
}
