[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#630228: foo2zjs: Firmware upload is not compatible with cups



I have now updated the Ubuntu package (20110210dfsg-1ubuntu4) applying the attached patch. The patch modifies the firmware upload script hplj1000. It adds support for douing the firmware upload through the "usb" backend of CUPS. This makes the upload independent of the presence of usblp. It works also with the new libusb-based CUPS package.

   Till
Index: foo2zjs-20110210dfsg/hplj1000
===================================================================
--- foo2zjs-20110210dfsg.orig/hplj1000	2011-06-14 16:30:59.331940282 +0200
+++ foo2zjs-20110210dfsg/hplj1000	2011-06-14 16:31:26.151976656 +0200
@@ -48,6 +48,12 @@
 DEV=""
 
 #
+# Path to the USB CUPS backend. We use this backend to upload the firmware
+# into the printer when we are on a CUPS/libusb-based system.
+#
+USB_BACKEND=/usr/lib/cups/backend/usb
+
+#
 # Directory to find downloadable HP firmware files sihpMMMM.dl
 #
 FWDIR=/lib/firmware/hp
@@ -195,7 +201,7 @@
 esac
  
 #
-#	Procedure to load a single device with firmware
+#	Procedures to load a single device with firmware
 #
 load1() {
     _dev="$1"
@@ -218,6 +224,33 @@
     return 0
 }
 
+load2() {
+    fw="$FWDIR/sihp$FWMODEL.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 CUPS USB device ..."
+    # There is a timeout problem with udev and FC4, so spin it off.
+    (
+	device_found=0
+	for uri in `$USB_BACKEND 2> /dev/null | grep -i 'HP.*LaserJet.*'"$MODEL" | grep -v FWVER | cut -d ' ' -f 2`; do
+	    device_found=1
+	    if DEVICE_URI="$uri" /usr/lib/cups/backend/usb 1 1 1 1 '' $fw 2> /dev/null; then
+		log "$uri... download successful."
+	    else
+		log "$uri... download failed."
+	    fi
+	done
+	if [ $device_found = 0 ]; then
+	    log "... no devices which need firmware found."
+	fi
+    ) &
+    return 0
+}
+
 #
 #	OK, now download firmware to any printers that need it
 #
@@ -226,6 +259,13 @@
     # force downloading to a specific device
     #
     load1 "$DEV"
+elif [ -x $USB_BACKEND ]; then
+    #
+    # If we have CUPS installed, use the CUPS "usb" backend, as then we do
+    # not need to care whether the system uses the usblp kernel module or
+    # libusb
+    #
+    load2
 elif [ -x $PRINTERID ]; then
     #
     # Sniff around for printers that need a firmware download
@@ -247,5 +287,5 @@
     done
 else
     log "HP LaserJet $MODEL firmware was not downloaded..."
-    log "...couldn't find $PRINTERID and DEV is not set"
+    log "...couldn't find $PRINTERID, DEV is not set, and CUPS not installed."
 fi

Reply to: