From 76593ee019c356db5507c81ebf4790bfa46d8d57 Mon Sep 17 00:00:00 2001
From: Monkey 7 <monkeyseven@fblog.ch>
Date: Tue, 9 Jul 2019 18:09:07 +0200
Subject: [PATCH] New package: brother-hl5340d-lpr-2.0.3

---
 srcpkgs/brother-hl5340d-lpr/INSTALL           |  5 +++
 srcpkgs/brother-hl5340d-lpr/files/LICENSE     |  9 +++++
 .../patches/filterHL5340D.patch               | 11 ++++++
 .../patches/setupPrintcap.patch               | 11 ++++++
 srcpkgs/brother-hl5340d-lpr/template          | 36 +++++++++++++++++++
 5 files changed, 72 insertions(+)
 create mode 100644 srcpkgs/brother-hl5340d-lpr/INSTALL
 create mode 100644 srcpkgs/brother-hl5340d-lpr/files/LICENSE
 create mode 100644 srcpkgs/brother-hl5340d-lpr/patches/filterHL5340D.patch
 create mode 100644 srcpkgs/brother-hl5340d-lpr/patches/setupPrintcap.patch
 create mode 100644 srcpkgs/brother-hl5340d-lpr/template

diff --git a/srcpkgs/brother-hl5340d-lpr/INSTALL b/srcpkgs/brother-hl5340d-lpr/INSTALL
new file mode 100644
index 00000000000..d329b943643
--- /dev/null
+++ b/srcpkgs/brother-hl5340d-lpr/INSTALL
@@ -0,0 +1,5 @@
+case "${ACTION}" in
+    post)
+        mkdir -p var/spool/lpd
+    ;;
+esac
diff --git a/srcpkgs/brother-hl5340d-lpr/files/LICENSE b/srcpkgs/brother-hl5340d-lpr/files/LICENSE
new file mode 100644
index 00000000000..a3d7fdf8754
--- /dev/null
+++ b/srcpkgs/brother-hl5340d-lpr/files/LICENSE
@@ -0,0 +1,9 @@
+License Agreement
+
+This Agreement provides terms and conditions for license grant from Brother Industries, Ltd ("Brother"). Brother, who owns all copyrights to the software that is distributed with this Agreement ("Software") to recipients thereof ("User"), for use of the Software. User shall have the right to use the Software only in accordance with the terms and conditions of this Agreement. Any use by User of the Software shall be deemed as its agreement hereto.
+
+Brother retains any and all copyrights to the Software. In no case this Agreement shall be construed to assign or otherwise transfer from Brother to User any copyrights or other intellectual property rights to whole or any part of the Software.
+
+Brother grants User a non-exclusive license: to reproduce and/or distribute (via Internet or in any other manner) the Software. Further, Brother grants User a non-exclusive license to modify, alter, translate or otherwise prepare derivative works of the Software and to reproduce and distribute (via Internet or in any other manner) such modification, alteration, translation or other derivative works for any purpose.
+
+The license of the Software from Brother hereunder is granted "AS IS." BROTHER HEREBY DISCLAIMS ANY WARRANTIES WITH RESPECT TO THE SOFTWARE, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTY FOR THE QUALITY, MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE OR NON-INFRINGEMENT. Brother shall have no liability in contract, tort (including negligence or breach of statutory duty) or otherwise for any interruption of use, loss of data, or for any indirect, incidental, punitive or consequential loss or damage, or for any loss of profit, revenue, data, goodwill or anticipated savings that arises under, out of, or in contemplation of this Agreement or otherwise arises due to any error, inaccuracy or defect in the Software even if Brother has been advised of the possibility of such loss or damage. Further, Brother shall have no liability to disclose and/or distribute the source code of the Software to User under any circumstances. In no case shall the above license by Brother to modify, alter, translate or otherwise prepare derivative works of the Software be construed as Brother's implied agreement or undertakings to disclose and/or distribute the source code of the Software. 
diff --git a/srcpkgs/brother-hl5340d-lpr/patches/filterHL5340D.patch b/srcpkgs/brother-hl5340d-lpr/patches/filterHL5340D.patch
new file mode 100644
index 00000000000..0b953f33f57
--- /dev/null
+++ b/srcpkgs/brother-hl5340d-lpr/patches/filterHL5340D.patch
@@ -0,0 +1,11 @@
+--- orig/usr/local/Brother/lpd/filterHL5340D	2008-09-18 08:26:25.000000000 +0200
++++ new/usr/local/Brother/lpd/filterHL5340D	2019-07-08 15:04:31.252101733 +0200
+@@ -22,7 +22,7 @@
+ PRINTER_TMP=$(echo $PRINTER | sed -e 's/ //g' -e 's/-//g')
+ PCL=1
+ 
+-BR_PRT_PATH=/usr/local/Brother
++BR_PRT_PATH=/usr/lib/brother
+ RCFILE=`eval echo $BR_PRT_PATH/inf/brPRINTERrc | eval sed 's/PRINTER/"$PRINTER_TMP"/'`
+ PAPER_INF=$BR_PRT_PATH/inf/paperinf
+ PSCONV=$BR_PRT_PATH/lpd/psconvert2
diff --git a/srcpkgs/brother-hl5340d-lpr/patches/setupPrintcap.patch b/srcpkgs/brother-hl5340d-lpr/patches/setupPrintcap.patch
new file mode 100644
index 00000000000..61c27ab5124
--- /dev/null
+++ b/srcpkgs/brother-hl5340d-lpr/patches/setupPrintcap.patch
@@ -0,0 +1,11 @@
+--- orig/usr/local/Brother/inf/setupPrintcap	2008-09-18 08:26:25.000000000 +0200
++++ new/usr/local/Brother/inf/setupPrintcap	2019-07-08 15:03:43.515834792 +0200
+@@ -46,7 +46,7 @@
+         :sd=/var/spool/lpd/$BRPRINTER_NAME:\\
+         :sh:\\
+         :lp=$DEVICE_IF:\\
+-        :if=/usr/local/Brother/lpd/filter$BRPRINTER_NAME:
++        :if=/usr/lib/brother/lpd/filter$BRPRINTER_NAME:
+ EOF
+ 	;;
+ 	-e)
diff --git a/srcpkgs/brother-hl5340d-lpr/template b/srcpkgs/brother-hl5340d-lpr/template
new file mode 100644
index 00000000000..8260f55a3f2
--- /dev/null
+++ b/srcpkgs/brother-hl5340d-lpr/template
@@ -0,0 +1,36 @@
+# Template file for 'brother-hl5340d-lpr'
+pkgname=brother-hl5340d-lpr
+br_version=2.0.3
+br_revision=1
+version=${br_version}
+revision=1
+maintainer="Monkey 7<monkeyseven@fblog.ch>"
+homepage="http://support.brother.com"
+license="brother-eula GPL-2"
+short_desc="LPR driver for the brother HL5340D printer"
+distfiles="http://www.brother.com/pub/bsc/linux/dlf/hl5340dlpr-${br_version}-${br_revision}.i386.deb"
+checksum="32f2d3e0297bbbcc4aab70f911fab3ba3cc6a0eb98c3569dfcb22beef6e32c19"
+archs="i686 x86_64"
+create_wrksrc=yes
+depends="a2ps ghostscript"
+nopie=yes
+patch_args="-Np1"
+
+if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
+	depends+=" glibc-32bit"
+fi
+
+do_extract() {
+	ar x ${XBPS_SRCDISTDIR}/${pkgname}-${version}/hl5340dlpr-${br_version}-${br_revision}.i386.deb
+	tar xzpvf data.tar.gz -C ${wrksrc}
+}
+
+do_install() {
+	mkdir -p ${DESTDIR}
+	cp -a ${wrksrc}/usr ${DESTDIR}/
+	mv ${DESTDIR}/usr/lib ${DESTDIR}/usr/lib32
+	mkdir -p ${DESTDIR}/usr/lib
+	mv ${DESTDIR}/usr/local/Brother ${DESTDIR}/usr/lib/brother
+	rm -rf ${DESTDIR}/usr/local
+	vlicense ${FILESDIR}/LICENSE
+}
