1 Maintainer: Nicola Bignami <nicola@kernel-panic.dnsdojo.net>
2 Contributor: Muhammed Uluyol <uluyol0@gmail.com>
3 Date: Wed, 28 Dec 2011 19:30:24
4 Subject: [PATCH] Firmware destdir support
7 Makefile | 97 ++++++++++----------------------
8 foo2zjs-loadfw.in | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++
9 hplj10xx.rules | 59 +++++++-------------
10 3 files changed, 211 insertions(+), 107 deletions(-)
11 create mode 100644 foo2zjs-loadfw.in
13 diff --git a/Makefile b/Makefile
14 index 8f9bbce..a97b36b 100644
17 @@ -18,7 +18,6 @@ VERSION=0.0
19 # Installation prefix...
24 # Pathnames for this package...
25 @@ -37,7 +36,7 @@ INSTALL=install
28 # Pathnames for referenced packages...
29 -FOODB=$(DESTDIR)/usr/share/foomatic/db/source
30 +FOODB=$(PREFIX)/share/foomatic/db/source
34 @@ -163,6 +162,7 @@ FILES = \
41 foo2hp2600-wrapper.in \
42 @@ -239,7 +240,7 @@ # CUPS vars
43 -CUPS_SERVERBIN := $(shell cups-config --serverbin 2>/dev/null)
44 +CUPS_SERVERBIN := $(DESTDIR)$(shell cups-config --serverbin 2>/dev/null)
45 -CUPS_DEVEL := $(shell grep cupsSideChannelDoRequest /usr/include/cups/sidechannel.h 2>/dev/null)
46 +CUPS_DEVEL := $(DESTDIR)$(shell grep cupsSideChannelDoRequest /usr/include/cups/sidechannel.h 2>/dev/null)
47 -CUPS_GOODAPI := $(shell cups-config --api-version 2>/dev/null | sed "s/1\.[0123].*//")
48 +CUPS_GOODAPI := $(DESTDIR)$(shell cups-config --api-version | sed "s/1\.[0123].*//" 2>/dev/null)
50 # hpclj2600n-0.icm km2430_0.icm km2430_1.icm km2430_2.icm samclp300-0.icm
51 # sihp1000.img sihp1005.img sihp1020.img sihp1018.img
52 # sihpP1005.img sihpP1006.img sihpP1505.img
53 @@ -262,7 +262,7 @@ endif
54 SHELLS= foo2zjs-wrapper foo2oak-wrapper foo2hp2600-wrapper \
55 foo2xqx-wrapper foo2lava-wrapper foo2qpdl-wrapper \
56 foo2slx-wrapper foo2hiperc-wrapper
57 -SHELLS+= foo2zjs-pstops
58 +SHELLS+= foo2zjs-loadfw foo2zjs-pstops
59 SHELLS+= printer-profile
60 MANPAGES= foo2zjs-wrapper.1 foo2zjs.1 zjsdecode.1
61 MANPAGES+= foo2oak-wrapper.1 foo2oak.1 oakdecode.1
62 @@ -465,6 +465,11 @@ foo2slx: foo2slx.o $(LIBJBG)
63 foo2hiperc: foo2hiperc.o $(LIBJBG)
64 $(CC) $(CFLAGS) -o $@ foo2hiperc.o $(LIBJBG)
66 +foo2zjs-loadfw: foo2zjs-loadfw.in Makefile
67 + [ ! -f $@ ] || chmod +w $@
69 + -e 's:@ZJSFWDIR@:$(SHAREZJS)/firmware:' -e 's:@XQXFWDIR@:$(SHAREXQX)/firmware/:' || (rm -f $@ && exit 1)
72 foo2zjs-wrapper: foo2zjs-wrapper.in Makefile
73 [ ! -f $@ ] || chmod +w $@
74 @@ -623,6 +628,8 @@ install-test:
75 UDEVBIN=$(DESTDIR)/bin/
78 + [ -d $(BIN) ] || $(INSTALL) -d -m 755 $(BIN)/
79 + [ -d $(DESTDIR)/bin/ ] || $(INSTALL) -d -m 755 $(DESTDIR)/bin/
81 # Install driver, wrapper, and development tools
83 @@ -630,7 +637,7 @@ install-prog:
84 $(INSTALL) -c $(PROGS) $(SHELLS) $(BIN)/
85 if [ "$(BINPROGS)" != "" ]; then \
86 $(INSTALL) -d $(UDEVBIN); \
87 - $(INSTALL) -c $(BINPROGS) $(UDEVBIN); \
88 + $(INSTALL) -c $(BINPROGS) $(DESTDIR)/bin/; \
91 # Install gamma correction files. These are just templates,
92 @@ -683,10 +690,10 @@ install-foo:
94 # Clear foomatic cache and rebuild database if needed
96 - rm -rf /var/cache/foomatic/*/*
97 - rm -f /var/cache/foomatic/printconf.pickle
98 - if [ -d /var/cache/foomatic/compiled ]; then \
99 - cd /var/cache/foomatic/compiled; \
100 + rm -rf $(DESTDIR)/var/cache/foomatic/*/*
101 + rm -f $(DESTDIR)/var/cache/foomatic/printconf.pickle
102 + if [ -d $(DESTDIR)/var/cache/foomatic/compiled ]; then \
103 + cd $(DESTDIR)/var/cache/foomatic/compiled; \
104 foomatic-combo-xml -O >overview.xml; \
107 @@ -748,7 +755,7 @@ install-extra:
110 # foo2zjs Firmware files (if any)
111 - $(INSTALL) $(LPuid) $(LPgid) -m 775 -d $(SHAREZJS)/firmware/
112 + $(INSTALL) $(LPuid) $(LPgid) -m 755 -d $(SHAREZJS)/firmware/
113 for i in sihp1*.img; do \
114 if [ -f $$i ]; then \
115 base=`basename $$i .img`; \
116 @@ -757,7 +764,7 @@ install-extra:
119 # foo2xqx Firmware files (if any)
120 - $(INSTALL) $(LPuid) $(LPgid) -m 775 -d $(SHAREXQX)/firmware/
121 + $(INSTALL) $(LPuid) $(LPgid) -m 755 -d $(SHAREXQX)/firmware/
122 for i in sihpP*.img; do \
123 if [ -f $$i ]; then \
124 base=`basename $$i .img`; \
125 @@ -808,10 +815,10 @@ install-extra:
129 -MODEL=$(DESTDIR)/usr/share/cups/model
130 +MODEL=$(PREFIX)/share/cups/model
131 -LOCALMODEL=$(DESTDIR)/usr/local/share/cups/model
132 +LOCALMODEL=$(PREFIX)/usr/local/share/cups/model
133 MACMODEL=/Library/Printers/PPDs/Contents/Resources
134 -PPD=$(DESTDIR)/usr/share/ppd
135 +PPD=$(PREFIX)/share/ppd
139 @@ -829,13 +836,6 @@ install-ppd:
142 elif [ -d $(PPD) ]; then \
143 - find $(PPD) -name '*foo2zjs*' | xargs rm -rf; \
144 - find $(PPD) -name '*foo2hp*' | xargs rm -rf; \
145 - find $(PPD) -name '*foo2xqx*' | xargs rm -rf; \
146 - find $(PPD) -name '*foo2lava*' | xargs rm -rf; \
147 - find $(PPD) -name '*foo2qpdl*' | xargs rm -rf; \
148 - find $(PPD) -name '*foo2slx*' | xargs rm -rf; \
149 - find $(PPD) -name '*foo2hiperc*' | xargs rm -rf; \
150 [ -d $(PPD)/foo2zjs ] || mkdir $(PPD)/foo2zjs; \
152 for ppd in *.ppd; do \
153 @@ -868,9 +868,9 @@ install-ppd:
157 -APPL=$(DESTDIR)/usr/share/applications
158 -OLDAPPL=$(DESTDIR)/usr/share/gnome/apps/System
159 -PIXMAPS=$(DESTDIR)/usr/share/pixmaps
160 +APPL=$(PREFIX)/share/applications
161 +OLDAPPL=$(PREFIX)/share/gnome/apps/System
162 +PIXMAPS=$(PREFIX)/share/pixmaps
166 @@ -894,7 +894,7 @@ install-gui:
167 $(INSTALL) -c -m 755 hplj10xx_gui.tcl $(SHAREZJS)
170 -USBDIR=/etc/hotplug/usb
171 +USBDIR=$(DESTDIR)/etc/hotplug/usb
172 UDEVDIR=/etc/udev/rules.d
173 LIBUDEVDIR=/lib/udev/rules.d
175 @@ -939,61 +939,22@@ install-hotplug-test:
178 install-hotplug-prog:
180 - # remove HPLIP (proprietary) files and install our version
182 - if [ -d $(UDEVDIR) ]; then \
183 - rm -f $(UDEVDIR)/*hpmud*laserjet_1000*; \
184 - rm -f $(UDEVDIR)/*hpmud*laserjet_1005*; \
185 - rm -f $(UDEVDIR)/*hpmud*laserjet_1018*; \
186 - rm -f $(UDEVDIR)/*hpmud*laserjet_1020*; \
187 - rm -f $(UDEVDIR)/*hpmud*laserjet_p1005*; \
188 - rm -f $(UDEVDIR)/*hpmud*laserjet_p1006*; \
189 - rm -f $(UDEVDIR)/*hpmud*laserjet_p1007*; \
190 - rm -f $(UDEVDIR)/*hpmud*laserjet_p1008*; \
191 - rm -f $(UDEVDIR)/*hpmud*laserjet_p1505*; \
192 - rm -f $(UDEVDIR)/*hpmud_support.rules; \
193 - rm -f $(LIBUDEVDIR)/*-hplj10xx.rules; \
194 - version=`$(UDEVD) --version 2>/dev/null`; \
195 - if [ "$$version" = "" ]; then version=0; fi; \
196 - echo "*** udev version $$version"; \
197 - if [ "$$version" -lt 148 ]; then \
198 - $(INSTALL) -c -m 644 $(RULES).old $(UDEVDIR)/11-$(RULES); \
200 - $(INSTALL) -c -m 644 $(RULES) $(UDEVDIR)/11-$(RULES); \
203 + install -d -m 755 $(DESTDIR)$(UDEVDIR)
204 + $(INSTALL) -c -m 644 $(RULES) $(DESTDIR)$(UDEVDIR)/11-$(RULES); \
205 if [ -d $(DEVDDIR) ]; then \
206 $(INSTALL) -c -m 644 hplj10xx.conf $(DEVDDIR)/; \
208 [ -d $(USBDIR) ] || $(INSTALL) -d -m 755 $(USBDIR)/
209 - $(INSTALL) -c -m 755 hplj1000 $(USBDIR)/
210 - ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1005
211 - ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1018
212 - ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1020
213 - ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hpljP1005
214 - ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hpljP1006
215 - ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hpljP1007
216 - ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hpljP1008
217 - ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hpljP1505
218 - $(USBDIR)/hplj1000 install-usermap
219 - $(USBDIR)/hplj1005 install-usermap
220 - $(USBDIR)/hplj1018 install-usermap
221 - $(USBDIR)/hplj1020 install-usermap
222 - $(USBDIR)/hpljP1005 install-usermap
223 - $(USBDIR)/hpljP1006 install-usermap
224 - $(USBDIR)/hpljP1007 install-usermap
225 - $(USBDIR)/hpljP1008 install-usermap
226 - $(USBDIR)/hpljP1505 install-usermap
228 - $(USBDIR)/hplj1000 install-usblp
229 + $(INSTALL) -d -m 755 $(DESTDIR)/sbin
230 + $(INSTALL) -c -m 755 foo2zjs-loadfw $(DESTDIR)/sbin
233 cd osx-hotplug; $(MAKE) PREFIX=$(PREFIX) install-hotplug
236 if [ "$(CUPS_SERVERBIN)" != "" ]; then \
237 + install -d -m 755 $(CUPS_SERVERBIN)/filter; \
238 - ln -sf $(BIN)/command2foo2lava-pjl $(CUPS_SERVERBIN)/filter/; \
239 + ln -sf ../../../bin/command2foo2lava-pjl $(CUPS_SERVERBIN)/filter/; \
242 CUPSDCONF=/etc/cups/cupsd.conf
243 diff --git a/foo2zjs-loadfw.in b/foo2zjs-loadfw.in
245 index 0000000..a7e1bfc
247 +++ b/foo2zjs-loadfw.in
253 +# Hotplug script for HP1000/1005/1020 USB laser printers. The model number
254 +# that this script deals with is determined from the udev env.
256 +# Used to download firmware automatically into the printer when it
257 +# is powered up or plugged into the USB port.
259 +# The inspiration fo this script is from:
260 +# Oscar Santacreu. Alicante-Spain (2002)
261 +# Mike Morgan (2004)
262 +# Modified by Stefan Schweizer (2005) to work as a udev-RUN-script
265 +# Directory to find downloadable HP firmware files sihpMMMM.dl
271 +# Program used to determine USB id information
273 +USBID=/bin/usb_printerid
276 +# Timeout to load firmware
281 +# Figure out how to log our messages
284 + # Running from a tty...
288 +elif [ -x /usr/bin/logger ]; then
291 + logger -t "$0" -- "$@"
296 + echo "$0: $@" >> /var/log/messages
301 +# Figure out the model number from the name of this script
305 + MODEL=P1005; FWMODEL=$MODEL
306 + MODELNAME="HP LaserJet $MODEL"
310 + MODEL=P1006; FWMODEL=$MODEL
311 + MODELNAME="HP LaserJet $MODEL"
315 + MODEL=P1007; FWMODEL=P1005 # Alias
316 + MODELNAME="HP LaserJet $MODEL"
320 + MODEL=P1008; FWMODEL=P1006 # Alias
321 + MODELNAME="HP LaserJet $MODEL"
325 + MODEL=P1505; FWMODEL=$MODEL
326 + MODELNAME="HP LaserJet $MODEL"
330 + MODEL=P1505n; FWMODEL=$MODEL
331 + MODELNAME="HP LaserJet $MODEL"
335 + MODEL=1000; FWMODEL=$MODEL
336 + MODELNAME="hp LaserJet $MODEL"
340 + MODEL=1005; FWMODEL=$MODEL
341 + MODELNAME="hp LaserJet $MODEL"
345 + MODEL=1018; FWMODEL=$MODEL
346 + MODELNAME="HP LaserJet $MODEL"
350 + MODEL=1020; FWMODEL=$MODEL
351 + MODELNAME="HP LaserJet $MODEL"
355 + log "Only HP LaserJet 1000, 1005, 1018 and 1020 are supported"
356 + log "You need to supply one of these on the cmdline: $0 10**"
361 +if [ -n "$2" ]; then
363 +elif [ -n "$DEVNAME" ]; then
364 + log 'using $DEVNAME'
366 + log "You need to either have $DEVNAME set in the environment or supply it on the cmdline, like:"
367 + log "$0 10** /dev/usb/lp0"
372 +# Procedure to load a single device with firmware
375 + fw="$FWDIR/sihp$FWMODEL.dl"
376 + if [ ! -f "$fw" ]; then
377 + log "Missing HP LaserJet $MODEL firmware file $fw"
378 + log "...read foo2zjs installation instructions and run ./getweb $MODEL"
382 + log "loading HP LaserJet $MODEL firmware $fw to $DEVNAME ..."
383 + if cat $fw > $DEVNAME; then
385 + log "... download successful."
387 + log "... download failed."
393 +# OK, now download firmware to any printers that need it
395 +if [ -x $USBID ]; then
396 + if $USBID $DEVNAME | grep "$MODELNAME" 2> /dev/null; then
397 + # This is a LaserJet 100x
398 + if $USBID $DEVNAME | grep 'FWVER' 2> /dev/null; then
399 + log "HP LaserJet $MODEL firmware already loaded into $DEVNAME"
401 + # Firmware is not yet loaded
405 + log "No supported printer found."
408 + log "HP LaserJet $MODEL firmware was not downloaded..."
409 + log "...couldn't find $USBID"
411 diff --git a/hplj10xx.rules b/hplj10xx.rules
412 index ee0295d..b81ff9e 100644
417 -# hplj10xx.rules.old: udev equal or after 1.30
419 -#Own udev rule for HP Laserjet 1000
420 -KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
421 - ATTRS{product}=="hp LaserJet 1000", NAME="usb/%k", \
422 - SYMLINK+="hplj1000-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1000"
423 -#Own udev rule for HP Laserjet 1005
424 -KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
425 - ATTRS{product}=="hp LaserJet 1005 series", NAME="usb/%k", \
426 - SYMLINK+="hplj1005-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1005"
427 -#Own udev rule for HP Laserjet 1018
428 -KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
429 - ATTRS{product}=="HP LaserJet 1018", NAME="usb/%k", \
430 - SYMLINK+="hplj1018-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1018"
431 -#Own udev rule for HP Laserjet 1020
432 -KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
433 - ATTRS{product}=="HP LaserJet 1020", NAME="usb/%k", \
434 - SYMLINK+="hplj1020-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1020"
435 -#Own udev rule for HP Laserjet P1005
436 -KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
437 - ATTRS{product}=="HP LaserJet P1005", NAME="usb/%k", \
438 - SYMLINK+="hpljP1005-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1005"
439 -#Own udev rule for HP Laserjet P1006
440 -KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
441 - ATTRS{product}=="HP LaserJet P1006", NAME="usb/%k", \
442 - SYMLINK+="hpljP1006-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1006"
443 -#Own udev rule for HP Laserjet P1007
444 -KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
445 - ATTRS{product}=="HP LaserJet P1007", NAME="usb/%k", \
446 - SYMLINK+="hpljP1007-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1007"
447 -#Own udev rule for HP Laserjet P1008
448 -KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
449 - ATTRS{product}=="HP LaserJet P1008", NAME="usb/%k", \
450 - SYMLINK+="hpljP1008-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1008"
451 -#Own udev rule for HP Laserjet P1505
452 -KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
453 - ATTRS{product}=="HP LaserJet P1505", NAME="usb/%k", \
454 - SYMLINK+="hpljP1505-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1505"
455 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
456 + ATTRS{idProduct}=="0517", RUN+="/sbin/foo2zjs-loadfw 1000 $tempnode"
457 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
458 + ATTRS{idProduct}=="1317", RUN+="/sbin/foo2zjs-loadfw 1005 $tempnode"
459 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
460 + ATTRS{idProduct}=="4117", RUN+="/sbin/foo2zjs-loadfw 1018 $tempnode"
461 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
462 + ATTRS{idProduct}=="2b17", RUN+="/sbin/foo2zjs-loadfw 1020 $tempnode"
463 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
464 + ATTRS{idProduct}=="3d17", RUN+="/sbin/foo2zjs-loadfw P1005 $tempnode"
465 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
466 + ATTRS{idProduct}=="3e17", RUN+="/sbin/foo2zjs-loadfw P1006 $tempnode"
467 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
468 + ATTRS{idProduct}=="4817", RUN+="/sbin/foo2zjs-loadfw P1007 $tempnode"
469 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
470 + ATTRS{idProduct}=="4917", RUN+="/sbin/foo2zjs-loadfw P1008 $tempnode"
471 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
472 + ATTRS{idProduct}=="3f17", RUN+="/sbin/foo2zjs-loadfw P1505 $tempnode"
473 +ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
474 + ATTRS{idProduct}=="4017", RUN+="/sbin/foo2zjs-loadfw P1505n $tempnode"