summarylogtreecommitdiffstats
path: root/cupswrappermfcl9570cdw.patch
blob: 2ea4bd107f8cfedd260e3710cbf8b3646a84992f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
--- a/opt/brother/Printers/mfcl9570cdw/cupswrapper/cupswrappermfcl9570cdw	2018-12-12 11:41:30.000000000 +0900
+++ b/opt/brother/Printers/mfcl9570cdw/cupswrapper/cupswrappermfcl9570cdw	2020-03-19 19:04:09.625604098 +0900
@@ -23,337 +23,88 @@
 device_name=`echo $printer_name | eval sed -e 's/MFC/MFC-/' -e 's/DCP/DCP-/' -e 's/HL/HL-/' -e 's/FAX/FAX-/'`
 pcfilename=`echo $printer_name | tr -d '[A-Z]'`
 device_model="Printers"
-tmp_filter=/var/tmp/brother_lpdwrapper_${printer_model}
 ldpwrapper=/opt/brother/${device_model}/${printer_model}/cupswrapper/brother_lpdwrapper_${printer_model}
 
-if [ -d "/usr/share/cups/model" ]; then
-  mkdir -p /usr/share/cups/model/Brother
+if [ -d "$DESTDIR/usr/share/cups/model" ]; then
+  mkdir -p $DESTDIR/usr/share/cups/model/Brother
 else
-  mkdir -p /usr/share/ppd/Brother
+  mkdir -p $DESTDIR/usr/share/ppd/Brother
 fi
 
-if [ -d "/usr/share/ppd" ]; then
-  mkdir -p /usr/share/ppd/Brother       
+if [ -d "$DESTDIR/usr/share/ppd" ]; then
+  mkdir -p $DESTDIR/usr/share/ppd/Brother       
 else
-  mkdir -p /usr/share/cups/model/Brother
+  mkdir -p $DESTDIR/usr/share/cups/model/Brother
 fi
 
 
 
 if [ "$1" = '-e' ]; then
   lpadmin -x ${printer_name}
-  rm -f /usr/share/cups/model/Brother/brother_${printer_model}_printer_en.ppd
-  rm -f /usr/share/ppd/Brother/brother_${printer_model}_printer_en.ppd
-  rm -f /usr/lib/cups/filter/brother_lpdwrapper_${printer_model}
-  rm -f /usr/lib64/cups/filter/brother_lpdwrapper_${printer_model}
-  rm -f /opt/brother/${device_model}/${printer_model}/cupswrapper/brother_lpdwrapper_${printer_model}
-#  rm -f /usr/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1
-if [  -e /etc/init.d/cups ]; then
-   /etc/init.d/cups restart
-elif [  -e /etc/init.d/cupsys ]; then
-   /etc/init.d/cupsys restart
-fi
-#  /etc/init.d/cups restart
-  exit 0
-fi
-if [ "$1" = "-r" ]; then
-  lpadmin -x ${printer_name}
-if [  -e /etc/init.d/cups ]; then
-   /etc/init.d/cups restart
-elif [  -e /etc/init.d/cupsys ]; then
-   /etc/init.d/cupsys restart
-fi
-#  /etc/init.d/cups restart
+  rm -f $DESTDIR/usr/share/cups/model/Brother/brother_${printer_model}_printer_en.ppd
+  rm -f $DESTDIR/usr/share/ppd/Brother/brother_${printer_model}_printer_en.ppd
+  rm -f $DESTDIR/usr/lib/cups/filter/brother_lpdwrapper_${printer_model}
+  rm -f $DESTDIR/usr/lib64/cups/filter/brother_lpdwrapper_${printer_model}
+  rm -f $DESTDIR/opt/brother/${device_model}/${printer_model}/cupswrapper/brother_lpdwrapper_${printer_model}
+#  rm -f $DESTDIR/usr/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1
   exit 0
 fi
 if [ "$1" = "help" ] || [ "$1" = "-h" ]; then
   echo   'option -h : help'
   echo   '       -i : install'
   echo   '       -e : uninstall'
-  echo   '       -r : remove printer'
   exit 0
 fi
-#mkdir -p /usr/local/Brother/${device_model}/${printer_model}/filter
-#mkdir -p /usr/lib/cups/filter
+#mkdir -p $DESTDIR/usr/local/Brother/${device_model}/${printer_model}/filter
+#mkdir -p $DESTDIR/usr/lib/cups/filter
 
-if [ -e "/opt/brother/${device_model}/${printer_model}/lpd/filter_${printer_model}" ]; then
+if [ -e "$DESTDIR/opt/brother/${device_model}/${printer_model}/lpd/filter_${printer_model}" ]; then
   :
 else
   echo "ERROR : Brother LPD filter is not installed."
 fi
-rm -f /usr/share/cups/model/Brother/brother_${printer_model}_printer_en.ppd
-if [ -d "/usr/share/cups/model" ]; then
-  ppd_file_name=/usr/share/cups/model/Brother/brother_${printer_model}_printer_en.ppd
+rm -f $DESTDIR/usr/share/cups/model/Brother/brother_${printer_model}_printer_en.ppd
+if [ -d "$DESTDIR/usr/share/cups/model" ]; then
+  ppd_file_name=$DESTDIR/usr/share/cups/model/Brother/brother_${printer_model}_printer_en.ppd
 else
-  ppd_file_name=/usr/share/ppd/Brother/brother_${printer_model}_printer_en.ppd
+  ppd_file_name=$DESTDIR/usr/share/ppd/Brother/brother_${printer_model}_printer_en.ppd
 fi
 
-if [ -e "/opt/brother/${device_model}/${printer_model}/cupswrapper/brother_${printer_model}_printer_en.ppd" ];	then
-cp "/opt/brother/${device_model}/${printer_model}/cupswrapper/brother_${printer_model}_printer_en.ppd" $ppd_file_name
+if [ -e "$DESTDIR/opt/brother/${device_model}/${printer_model}/cupswrapper/brother_${printer_model}_printer_en.ppd" ];	then
+cp "$DESTDIR/opt/brother/${device_model}/${printer_model}/cupswrapper/brother_${printer_model}_printer_en.ppd" $ppd_file_name
 fi
 
 chmod 644 $ppd_file_name
 
-if [ -d /usr/share/ppd ]
+if [ -d $DESTDIR/usr/share/ppd ]
 then
-if [ -d /usr/share/cups/model ]
+if [ -d $DESTDIR/usr/share/cups/model ]
 then
-	cp $ppd_file_name /usr/share/ppd/Brother/brother_${printer_model}_printer_en.ppd
-	chmod 644 /usr/share/ppd/Brother/brother_${printer_model}_printer_en.ppd
+	cp $ppd_file_name $DESTDIR/usr/share/ppd/Brother/brother_${printer_model}_printer_en.ppd
+	chmod 644 $DESTDIR/usr/share/ppd/Brother/brother_${printer_model}_printer_en.ppd
 fi
 fi
 
 #
-#	create temporary CUPS Filter
-#
-
-cat <<!ENDOFWFILTER! >$tmp_filter
-#! /bin/sh
-#
-# Copyright (C) 2005-2016 Brother. Industries, Ltd.
-#                                    Ver1.10
-
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-# Place, Suite 330, Boston, MA  02111-1307  USA
-#
-
-LOGFILE="/dev/null"
-LOGLEVEL="1"
-LOGCLEVEL="7"
-DEBUG=0
-NUPENABLE=1
-LOG_LATESTONLY=1
-
-
-touch /tmp/${printer_model}_latest_print_info
-chmod 600 -R /tmp/${printer_model}_latest_print_info
-
-errorcode=0
-
-if [ \$DEBUG != 0 ]; then
-    LOGFILE=/tmp/br_cupsfilter_debug_log
-fi
-
-PPDC=\`printenv | grep "PPD="\`
-PPDC=\`echo \$PPDC | sed -e 's/PPD=//'\`
-
-if [ "\$PPDC" = "" ]; then
-    PPDC="/usr/share/cups/model/Brother/brother_${printer_model}_printer_en.ppd"
-fi
-
-
-if [ \$LOGFILE != "/dev/null" ]; then
-  if [ \$LOG_LATESTONLY == "1" ]; then
-    rm -f \$LOGFILE
-    date                                                           >\$LOGFILE
-  else
-    if [ -e \$LOGFILE ]; then
-	    date                                                        >>\$LOGFILE
-    else
-	    date                                                        >\$LOGFILE
-    fi
-  fi
-    echo "arg0 = \$0"                                           >>\$LOGFILE
-    echo "arg1 = \$1"                                           >>\$LOGFILE
-    echo "arg2 = \$2"                                           >>\$LOGFILE
-    echo "arg3 = \$3"                                           >>\$LOGFILE
-    echo "arg4 = \$4"                                           >>\$LOGFILE
-    echo "arg5 = \$5"                                           >>\$LOGFILE
-    echo "arg6 = \$6"                                           >>\$LOGFILE
-    echo "PPD  = \$PPD"                                         >>\$LOGFILE
-fi
-
-cp  /opt/brother/Printers/${printer_model}/inf/br${printer_model}rc  /tmp/br${printer_model}rc_\$$
-chmod 777 -R /tmp/br${printer_model}rc_\$$
-export BRPRINTERRCFILE=/tmp/br${printer_model}rc_\$$
-
-INPUT_TEMP_PS=\`mktemp /tmp/br_input_ps.XXXXXX\`
-
-nup="cat"
-if [ "\`echo \$5 | grep 'Nup='\`" != '' ] && [ \$NUPENABLE != 0 ]; then
-
-	if   [ "\`echo \$5 | grep 'Nup=64'\`" != '' ]; then
-		nup="psnup -64"
-	elif [ "\`echo \$5 | grep 'Nup=32'\`" != '' ]; then
-		nup="psnup -32"
-	elif [ "\`echo \$5 | grep 'Nup=25'\`" != '' ]; then
-		nup="psnup -25"
-	elif [ "\`echo \$5 | grep 'Nup=16'\`" != '' ]; then
-		nup="psnup -16"
-	elif [ "\`echo \$5 | grep 'Nup=8'\`" != '' ]; then
-		nup="psnup -8"
-	elif [ "\`echo \$5 | grep 'Nup=6'\`" != '' ]; then
-		nup="psnup -6"
-	elif [ "\`echo \$5 | grep 'Nup=4'\`" != '' ]; then
-		nup="psnup -4"
-	elif [ "\`echo \$5 | grep 'Nup=2'\`" != '' ]; then
-		nup="psnup -2"
-	elif [ "\`echo \$5 | grep 'Nup=1'\`" != '' ]; then
-		nup="cat"
-	fi
-	echo   "NUP=\$nup"                                      >>\$LOGFILE
-   if [ -e /usr/bin/psnup ]; then
-       if [ \$# -ge 7 ]; then
-	       cat \$6  | \$nup > \$INPUT_TEMP_PS
-       else
-	       cat       | \$nup > \$INPUT_TEMP_PS
-       fi
-   else
-       if [ \$# -ge 7 ]; then
-	       cp \$6  \$INPUT_TEMP_PS
-       else
-	       cat    > \$INPUT_TEMP_PS
-       fi
-   fi
-else
-   if [ \$# -ge 7 ]; then
-      cp \$6  \$INPUT_TEMP_PS
-   else
-      cat    > \$INPUT_TEMP_PS
-   fi
-fi
-if [ -e "/opt/brother/${device_model}/${printer_model}/lpd/filter${printer_model}" ]; then
-       :
-else
-    echo "ERROR: /opt/brother/${device_model}/${printer_model}/lpd/filter${printer_model} does not exist"   >>\$LOGFILE
-    echo "ERROR: /opt/brother/${device_model}/${printer_model}/lpd/filter${printer_model} does not exist"   >>/tmp/${printer_model}_latest_print_info
-    errorcode=30
-    exit
-fi
-
-CUPSOPTION=\`echo "\$5 Copies=1" | sed -e 's/BrMirror=OFF/MirrorPrint=OFF/' -e 's/BrMirror=ON/MirrorPrint=ON/' -e 's/BrChain/Chain/' -e 's/BrBrightness/Brightness/' -e 's/BrContrast/Contrast/' -e 's/BrHalfCut/HalfCut/' -e 's/BrAutoTapeCut/AutoCut/' -e 's/BrHalftonePattern/Halftone/' -e 's/Binary/Binary/' -e 's/Dither/Dither/' -e 's/ErrorDiffusion/ErrorDiffusion/' -e 's/BrSheets/Sheets/' -e 's/multiple-document-handling/Collate/' -e 's/separate-documents-collated-copies/ON/' -e 's/separate-documents-uncollated-copies/OFF/'\`
-#if [ -e "/opt/brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1" ]; then
-	
-#  if [ \$DEBUG = 0 ]; then
-#     /opt/brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1  ${printer_name}  \$PPDC 0 "\$CUPSOPTION" #"${printer_model}" \$BRPRINTERRCFILE>> /dev/null
-#  else
-#     /opt/brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1  ${printer_name}  \$PPDC \$LOGCLEVEL "\$CUPSOPTION" #"${printer_model}" \$BRPRINTERRCFILE>>\$LOGFILE
-#  fi
-#fi
-
-if [ \$DEBUG -lt 10 ]; then
-    cat    \$INPUT_TEMP_PS | /opt/brother/${device_model}/${printer_model}/lpd/filter${printer_model} 
-    echo br${printer_model}rc_\$$   > /tmp/${printer_model}_latest_print_info
-    cat  /tmp/br${printer_model}rc_\$$  >> /tmp/${printer_model}_latest_print_info
-    rm -f /tmp/br${printer_model}rc_\$$
-
-    if [ \$LOGLEVEL -gt 2 ];  then
-	   if [ \$LOGFILE != "/dev/null" ]; then
-	     echo ""                                                >>\$LOGFILE
-	     echo "    ------PostScript Data-------"                >>\$LOGFILE
-	     cat    \$INPUT_TEMP_PS                                  >>\$LOGFILE
-	   fi
-    fi
-fi
-rm -f  \$INPUT_TEMP_PS
-
-exit $errorcode
-
-!ENDOFWFILTER!
-
-chmod 755 $tmp_filter
-
-#
 #	check /usr/lib/cups/filter
 #
-if [ -d /usr/lib/cups/filter ]; then
-	brotherlpdwrapper=/usr/lib/cups/filter/brother_lpdwrapper_${printer_model}
+if [ -d $DESTDIR/usr/lib/cups/filter ]; then
+	brotherlpdwrapper=$DESTDIR/usr/lib/cups/filter/brother_lpdwrapper_${printer_model}
 	rm -f  $brotherlpdwrapper
-	#cp $tmp_filter	$brotherlpdwrapper
 	ln -s $ldpwrapper $brotherlpdwrapper
 fi
 
 #
 #	check /usr/lib64/cups/filter
 #
-if [ -e /usr/lib64/cups/filter ]; then
-	brotherlpdwrapper64=/usr/lib64/cups/filter/brother_lpdwrapper_${printer_model}
+if [ -e $DESTDIR/usr/lib64/cups/filter ]; then
+	brotherlpdwrapper64=$DESTDIR/usr/lib64/cups/filter/brother_lpdwrapper_${printer_model}
 	rm -f  $brotherlpdwrapper64
-	#cp $tmp_filter	$brotherlpdwrapper64
 	ln -s $ldpwrapper $brotherlpdwrapper64
 fi
 
-#
-#	remove temporary script file
-#
-rm -f  $tmp_filter
-
 #chmod a+w /opt/brother/${device_model}/${printer_model}/inf/br${printer_model}rc
 #chmod a+w /opt/brother/${device_model}/${printer_model}/inf
-if [ -e /etc/init.d/lpd ]; then
-   /etc/init.d/lpd stop
-fi
-if [  -e /etc/init.d/lprng ]; then
-   /etc/init.d/lprng stop
-fi
-
-
-if [  -e /etc/init.d/cups ]; then
-   /etc/init.d/cups restart
-elif [  -e /etc/init.d/cupsys ]; then
-   /etc/init.d/cupsys restart
-fi
-
-sleep 2s
-
-uris=$(lpinfo -v)
-
-for uri in $uris
-do
-	URI=$(echo $uri | grep ${device_name} | grep usb)
-	if [ "$URI" != '' ];then
-		break;
-	fi
-done
-
-if [ "$URI" = '' ];then
-	for uri in $uris
-	do
-		URI=$(echo $uri | grep ${device_name} )
-		if [ "$URI" != '' ];then
-			break;
-		fi
-	done
-fi
-
-if [ "$URI" = '' ];then
-	for uri in $uris
-	do
-		URI=$(echo $uri | grep -i Brother | grep usb )
-		if [ "$URI" != '' ];then
-			break;
-		fi
-	done
-fi	
-
-if [ "$URI" = '' ];then
-	for uri in $uris
-	do
-		URI=$(echo $uri | grep usb )
-		if [ "$URI" != '' ];then
-			break;
-		fi
-	done
-fi
-
-
-if [ "$URI" = '' ];then
-	URI="usb://dev/usb/lp0"
-fi
-
-echo lpadmin -p ${printer_name} -E -v $URI -P $ppd_file_name
-lpadmin -p ${printer_name} -E -v $URI -P $ppd_file_name
 								
 exit 0