summaryrefslogtreecommitdiffstats
path: root/foo2zjs/foo2zjs-20091017-udevfwld.patch
blob: 70dcccc60172739d00102eeee09c0ec6c802a730 (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
--- a/Makefile	2009-10-19 01:15:01.000000000 -0700
+++ b/Makefile	2009-10-19 01:21:11.000000000 -0700
@@ -19,6 +19,10 @@
 PREFIX=/usr/local
 PREFIX=$(DESTDIR)/usr
 
+# USB_PRINTERID is also installed there because it is needed by the FWloader
+FWLOADERDIR=$(DESTDIR)/sbin
+FIRMWAREDIR=$(DESTDIR)/lib/firmware
+
 # Pathnames for this package...
 BIN=$(PREFIX)/bin
 SHAREZJS=$(PREFIX)/share/foo2zjs
@@ -664,21 +668,21 @@
 	    fi; \
 	done
 	# foo2zjs Firmware files (if any)
-	$(INSTALL) $(LPuid) $(LPgid) -m 775 -d $(SHAREZJS)/firmware/
+	$(INSTALL) $(LPuid) $(LPgid) -m 755 -d $(FIRMWAREDIR)/
 	for i in sihp1*.img; do \
 	    if [ -f $$i ]; then \
 		base=`basename $$i .img`; \
 		./arm2hpdl $$i >$$base.dl; \
-		$(INSTALL) -c -m 644 $$base.dl $(SHAREZJS)/firmware/; \
+		$(INSTALL) -c -m 644 $$base.dl $(FIRMWAREDIR)/; \
 	    fi; \
 	done
 	# foo2xqx Firmware files (if any)
-	$(INSTALL) $(LPuid) $(LPgid) -m 775 -d $(SHAREXQX)/firmware/
+	$(INSTALL) $(LPuid) $(LPgid) -m 755 -d $(FIRMWAREDIR)/
 	for i in sihpP*.img; do \
 	    if [ -f $$i ]; then \
 		base=`basename $$i .img`; \
 		./arm2hpdl $$i >$$base.dl; \
-		$(INSTALL) -c -m 644 $$base.dl $(SHAREXQX)/firmware/; \
+		$(INSTALL) -c -m 644 $$base.dl $(FIRMWAREDIR)/; \
 	    fi; \
 	done
 	# foo2oak ICM files (if any)
@@ -822,6 +826,8 @@
 UDEVDIR=$(DESTDIR)/etc/udev/rules.d
 RULES=hplj10xx.rules
 install-udev:
+	[ -d $(FWLOADERDIR) ] || install -d -m 755 $(FWLOADERDIR)/
+	install -c -m 755 foo2zjs-loadfw $(FWLOADERDIR)/
 	[ -d $(UDEVDIR) ] || install -d -m 755 $(UDEVDIR)/
 	install -c -m 644 $(RULES) $(UDEVDIR)/11-$(RULES)
 
--- foo2zjs.orig/foo2zjs-loadfw	1969-12-31 14:00:00.000000000 -1000
+++ foo2zjs/foo2zjs-loadfw	2008-02-25 20:09:13.000000000 -0900
@@ -0,0 +1,127 @@
+#!/bin/sh
+
+#	foo2zjs-loadfw:
+#
+#	Hotplug script for HP1000/1005/1020 USB laser printers. The model number
+#	that this script deals with is determined from the udev env.
+#
+#	Used to download firmware automatically into the printer when it
+#	is powered up or plugged into the USB port.
+#
+#	The inspiration fo this script is from:
+#		Oscar Santacreu. Alicante-Spain (2002)
+#		Mike Morgan (2004)
+#	Modified by Stefan Schweizer (2005) to work as a udev-RUN-script
+
+#
+# Directory to find downloadable HP firmware files sihpMMMM.dl
+#
+FWDIR=/lib/firmware
+
+#
+# Program used to determine USB id information
+#
+USBID=/bin/usb_printerid
+
+#
+# Timeout to load firmware
+#
+TIMEOUT=6
+
+#
+#	Figure out how to log our messages
+#
+if [ -t 1 ]; then
+    # Running from a tty...
+    log() {
+	echo "$0: $@"
+    }
+elif [ -x /usr/bin/logger ]; then
+    # Have logger...
+    log() {
+	logger -t "$0" -- "$@"
+    }
+else
+    # No logger...
+    log() {
+	echo "$0: $@" >> /var/log/messages
+    }
+fi
+
+#
+#	Figure out the model number from the name of this script
+#
+case "$1" in
+1000)
+    MODEL=1000
+    MODELNAME="hp LaserJet $MODEL"
+    ;;
+1005)
+    MODEL=1005
+    MODELNAME="hp LaserJet $MODEL"
+    ;;
+1018)
+    MODEL=1018
+    MODELNAME="HP LaserJet $MODEL"
+    ;;
+1020)
+    MODEL=1020
+    MODELNAME="HP LaserJet $MODEL"
+    ;;
+*)
+    log "Only HP LaserJet 1000, 1005, 1018 and 1020 are supported"
+    log "You need to supply one of these on the cmdline: $0 10**"
+    exit
+    ;;
+esac
+
+if [ -n "$2" ]; then
+    DEVNAME=$2
+elif [ -n "$DEVNAME" ]; then
+    log 'using $DEVNAME'
+else
+    log "You need to either have $DEVNAME set in the environment or supply it on the cmdline, like:"
+    log "$0 10** /dev/usb/lp0"
+    exit 1
+fi
+
+#
+#	Procedure to load a single device with firmware
+#
+load1() {
+    fw="$FWDIR/sihp$MODEL.dl"
+    if [ ! -f "$fw" ]; then
+	log "Missing HP LaserJet $MODEL firmware file $fw"
+	log "...read foo2zjs installation instructions and run ./getweb $MODEL"
+	return 1
+    fi
+
+    log "loading HP LaserJet $MODEL firmware $fw to $DEVNAME ..."
+    if cat $fw > $DEVNAME; then
+	sleep $TIMEOUT
+	log "... download successful."
+    else
+	log "... download failed."
+    fi
+    return 0
+}
+
+#
+#	OK, now download firmware to any printers that need it
+#
+if [ -x $USBID ]; then
+	if $USBID $DEVNAME | grep "$MODELNAME" 2> /dev/null; then
+	    # This is a LaserJet 100x
+	    if $USBID $DEVNAME | grep 'FWVER' 2> /dev/null; then
+		log "HP LaserJet $MODEL firmware already loaded into $DEVNAME"
+	    else
+		# Firmware is not yet loaded
+		load1 "$DEVNAME"
+	    fi
+	else
+	    log "No supported printer found."
+	fi
+else
+    log "HP LaserJet $MODEL firmware was not downloaded..."
+    log "...couldn't find $USBID"
+fi
--- a/hplj1000	2009-09-08 09:08:29.000000000 -0700
+++ b/hplj1000	2009-10-19 01:35:11.000000000 -0700
@@ -35,7 +35,7 @@
 #
 # Directory to find downloadable HP firmware files sihpMMMM.dl
 #
-FWDIR=/usr/share/foo2zjs/firmware
+FWDIR=/lib/firmware
 
 #
 # Program used to determine USB printer id information
--- a/hplj10xx.rules	2008-06-05 02:50:38.000000000 -0700
+++ b/hplj10xx.rules	2009-10-19 01:47:21.000000000 -0700
@@ -1,36 +1,8 @@
-#Own udev rule for HP Laserjet 1000
-KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", \
-	SYSFS{product}=="hp LaserJet 1000", NAME="usb/%k", \
-	SYMLINK+="hplj1000-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1000" 
-#Own udev rule for HP Laserjet 1005
-KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", \
-	SYSFS{product}=="hp LaserJet 1005 series", NAME="usb/%k", \
-	SYMLINK+="hplj1005-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1005" 
-#Own udev rule for HP Laserjet 1018
-KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", \
-	SYSFS{product}=="HP LaserJet 1018", NAME="usb/%k", \
-	SYMLINK+="hplj1018-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1018" 
-#Own udev rule for HP Laserjet 1020
-KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", \
-	SYSFS{product}=="HP LaserJet 1020", NAME="usb/%k", \
-	SYMLINK+="hplj1020-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1020" 
-#Own udev rule for HP Laserjet P1005
-KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", \
-	SYSFS{product}=="HP LaserJet P1005", NAME="usb/%k", \
-	SYMLINK+="hpljP1005-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1005" 
-#Own udev rule for HP Laserjet P1006
-KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", \
-	SYSFS{product}=="HP LaserJet P1006", NAME="usb/%k", \
-	SYMLINK+="hpljP1006-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1006" 
-#Own udev rule for HP Laserjet P1007
-KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", \
-	SYSFS{product}=="HP LaserJet P1007", NAME="usb/%k", \
-	SYMLINK+="hpljP1007-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1007" 
-#Own udev rule for HP Laserjet P1008
-KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", \
-	SYSFS{product}=="HP LaserJet P1008", NAME="usb/%k", \
-	SYMLINK+="hpljP1008-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1008" 
-#Own udev rule for HP Laserjet P1505
-KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", \
-	SYSFS{product}=="HP LaserJet P1505", NAME="usb/%k", \
-	SYMLINK+="hpljP1505-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1505" 
+ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
+   ATTRS{idProduct}=="0517", RUN+="/sbin/foo2zjs-loadfw 1000 $tempnode"
+ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
+   ATTRS{idProduct}=="1317", RUN+="/sbin/foo2zjs-loadfw 1005 $tempnode"
+ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
+   ATTRS{idProduct}=="4117", RUN+="/sbin/foo2zjs-loadfw 1018 $tempnode"
+ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", \
+   ATTRS{idProduct}=="2b17", RUN+="/sbin/foo2zjs-loadfw 1020 $tempnode"