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 1/3] 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
+}

From 85e979058dcfd0d0237592fb2163d4ba115212db Mon Sep 17 00:00:00 2001
From: Monkey 7 <monkeyseven@fblog.ch>
Date: Tue, 9 Jul 2019 19:17:18 +0200
Subject: [PATCH 2/3] mv ${DESTDIR}/usr/lib ${DESTDIR}/usr/lib32 fixed in
 template

---
 srcpkgs/brother-hl5340d-lpr/template | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/brother-hl5340d-lpr/template b/srcpkgs/brother-hl5340d-lpr/template
index 8260f55a3f2..0680cad8f87 100644
--- a/srcpkgs/brother-hl5340d-lpr/template
+++ b/srcpkgs/brother-hl5340d-lpr/template
@@ -28,8 +28,10 @@ do_extract() {
 do_install() {
 	mkdir -p ${DESTDIR}
 	cp -a ${wrksrc}/usr ${DESTDIR}/
-	mv ${DESTDIR}/usr/lib ${DESTDIR}/usr/lib32
-	mkdir -p ${DESTDIR}/usr/lib
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
+	  mkdir -p ${DESTDIR}/usr/lib32/
+ 	  mv ${DESTDIR}/usr/lib/* ${DESTDIR}/usr/lib32/
+	fi
 	mv ${DESTDIR}/usr/local/Brother ${DESTDIR}/usr/lib/brother
 	rm -rf ${DESTDIR}/usr/local
 	vlicense ${FILESDIR}/LICENSE

From 765e3eae011ecb3220ca25b0b721f417777daf97 Mon Sep 17 00:00:00 2001
From: Monkey 7 <monkeyseven@fblog.ch>
Date: Tue, 9 Jul 2019 20:58:16 +0200
Subject: [PATCH 3/3] New package : brother-hl5340d-lpr-2.0.3 - corrected
 various details

---
 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          | 23 ++++++++++---------
 5 files changed, 12 insertions(+), 47 deletions(-)
 delete mode 100644 srcpkgs/brother-hl5340d-lpr/INSTALL
 delete mode 100644 srcpkgs/brother-hl5340d-lpr/files/LICENSE
 delete mode 100644 srcpkgs/brother-hl5340d-lpr/patches/filterHL5340D.patch
 delete mode 100644 srcpkgs/brother-hl5340d-lpr/patches/setupPrintcap.patch

diff --git a/srcpkgs/brother-hl5340d-lpr/INSTALL b/srcpkgs/brother-hl5340d-lpr/INSTALL
deleted file mode 100644
index d329b943643..00000000000
--- a/srcpkgs/brother-hl5340d-lpr/INSTALL
+++ /dev/null
@@ -1,5 +0,0 @@
-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
deleted file mode 100644
index a3d7fdf8754..00000000000
--- a/srcpkgs/brother-hl5340d-lpr/files/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-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
deleted file mode 100644
index 0b953f33f57..00000000000
--- a/srcpkgs/brother-hl5340d-lpr/patches/filterHL5340D.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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
deleted file mode 100644
index 61c27ab5124..00000000000
--- a/srcpkgs/brother-hl5340d-lpr/patches/setupPrintcap.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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
index 0680cad8f87..a6f533cca24 100644
--- a/srcpkgs/brother-hl5340d-lpr/template
+++ b/srcpkgs/brother-hl5340d-lpr/template
@@ -1,27 +1,29 @@
 # Template file for 'brother-hl5340d-lpr'
 pkgname=brother-hl5340d-lpr
-br_version=2.0.3
-br_revision=1
-version=${br_version}
+_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
+make_dirs="/var/spool/lpd 0775 root lp"
 depends="a2ps ghostscript"
+short_desc="LPR driver for the brother HL5340D printer"
+maintainer="Monkey 7<monkeyseven@fblog.ch>"
+license="brother-eula GPL-2"
+homepage="http://support.brother.com"
+distfiles="http://www.brother.com/pub/bsc/linux/dlf/hl5340dlpr-${version}-${_br_revision}.i386.deb"
+checksum="32f2d3e0297bbbcc4aab70f911fab3ba3cc6a0eb98c3569dfcb22beef6e32c19"
 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
+	ar x ${XBPS_SRCDISTDIR}/${pkgname}-${version}/hl5340dlpr-${_br_version}-${_br_revision}.i386.deb
 	tar xzpvf data.tar.gz -C ${wrksrc}
 }
 
@@ -34,5 +36,4 @@ do_install() {
 	fi
 	mv ${DESTDIR}/usr/local/Brother ${DESTDIR}/usr/lib/brother
 	rm -rf ${DESTDIR}/usr/local
-	vlicense ${FILESDIR}/LICENSE
 }
