diff --git a/Makefile b/Makefile index ce510c4..b4171d8 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,11 @@ VERSION=0.0 # Installation prefix... PREFIX=/usr/local -PREFIX=/usr +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 @@ -22,7 +26,7 @@ MANDIR=$(PREFIX)/share/man DOCDIR=$(PREFIX)/share/doc/foo2zjs/ # Pathnames for referenced packages... -FOODB=/usr/share/foomatic/db/source +FOODB=${PREFIX}/share/foomatic/db/source # User ID's LPuid=-olp @@ -192,7 +196,7 @@ ifeq ($(UNAME),Linux) endif # Compiler flags -CFLAGS += -O2 -Wall +CFLAGS ?= -O2 -Wall #CFLAGS += -g # @@ -396,12 +400,14 @@ install-test: install-prog: + [ -d ${BIN} ] || install -d -m 755 ${BIN}/ + [ -d ${DESTDIR}/bin/ ] || install -d -m 755 ${DESTDIR}/bin/ # # Install driver, wrapper, and development tools # install -c $(PROGS) $(SHELLS) $(BIN)/ if [ "$(BINPROGS)" != "" ]; then \ - install -c $(BINPROGS) /bin/; \ + install -c $(BINPROGS) ${DESTDIR}/bin/; \ fi # # Install gamma correction files. These are just templates, @@ -429,6 +435,7 @@ install-foo: # @if [ -d $(FOODB) ]; then \ for dir in driver printer opt; do \ + [ -d ${FOODB}/$$dir/ ] || install -d -m 755 ${FOODB}/$$dir/; \ echo install -m 644 foomatic-db/$$dir/*.xml $(FOODB)/$$dir/; \ install -c -m 644 foomatic-db/$$dir/*.xml $(FOODB)/$$dir/; \ done \ @@ -446,10 +453,10 @@ install-foo: # # Clear foomatic cache and rebuild database if needed # - rm -rf /var/cache/foomatic/*/* - rm -f /var/cache/foomatic/printconf.pickle - if [ -d /var/cache/foomatic/compiled ]; then \ - cd /var/cache/foomatic/compiled; \ + rm -rf ${DESTDIR}/var/cache/foomatic/*/* + rm -f ${DESTDIR}/var/cache/foomatic/printconf.pickle + if [ -d ${DESTDIR}/var/cache/foomatic/compiled ]; then \ + cd ${DESTDIR}/var/cache/foomatic/compiled; \ foomatic-combo-xml -O >overview.xml; \ fi @@ -503,12 +510,12 @@ install-extra: fi; \ done # foo2zjs Firmware files (if any) - install $(LPuid) $(LPgid) -m 775 -d $(SHAREZJS)/firmware/ + install $(LPuid) $(LPgid) -m 775 -d $(FIRMWAREDIR)/ for i in sihp*.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 # foo2oak ICM files (if any) @@ -528,35 +535,26 @@ install-extra: fi; \ done -MODEL=/usr/share/cups/model -LOCALMODEL=/usr/local/share/cups/model +MODEL=${PREFIX}/usr/share/cups/model +#LOCALMODEL=/usr/local/share/cups/model install-ppd: # # Install PPD files for CUPS # - if [ -d /usr/share/ppd/ ]; then \ - find /usr/share/ppd/ -name '*foo2zjs*' | xargs rm -f; \ - find /usr/share/ppd/ -name '*foo2hp*' | xargs rm -f; \ - find /usr/share/ppd/ -name '*foo2xqx*' | xargs rm -f; \ - find /usr/share/ppd/ -name '*foo2lava*' | xargs rm -f; \ - find /usr/share/ppd/ -name '*foo2qpdl*' | xargs rm -f; \ - fi if [ -d $(MODEL) ]; then \ cd PPD; \ for ppd in *.ppd; do \ gzip < $$ppd > $(MODEL)/$$ppd.gz; \ done; \ - elif [ -d $(LOCALMODEL) ]; then \ + elif [ -n "${LOCALMODEL}" -a -d $(LOCALMODEL) ]; then \ cd PPD; \ for ppd in *.ppd; do \ gzip < $$ppd > $(LOCALMODEL)/$$ppd.gz; \ done; \ fi -USBDIR=/etc/hotplug/usb -UDEVDIR=/etc/udev/rules.d -RULES=hplj10xx.rules -install-hotplug: install-hotplug-test install-hotplug-prog +USBDIR=${DESTDIR}/etc/hotplug/usb +install-hotplug: install-hotplug-test install-udev install-hotplug-test: # @@ -574,18 +572,20 @@ install-hotplug-test: # install-hotplug-prog: - if [ -d $(UDEVDIR) ]; then \ - install -c -m 644 $(RULES) $(UDEVDIR)/11-$(RULES); \ - fi [ -d $(USBDIR) ] || install -d -m 755 $(USBDIR)/ install -c -m 755 hplj1000 $(USBDIR)/ ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1005 ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1018 ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1020 - $(USBDIR)/hplj1000 install-usermap - $(USBDIR)/hplj1005 install-usermap - $(USBDIR)/hplj1018 install-usermap - $(USBDIR)/hplj1020 install-usermap + install -c -m 644 hplj.usermap ${USBDIR}/ + +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} cups: FRC if [ -x /etc/init.d/cups ]; then \ @@ -910,7 +910,6 @@ install-doc: doc install -c -m 644 README $(DOCDIR) install -c -m 644 ChangeLog $(DOCDIR) -GROFF=/usr/local/test/bin/groff GROFF=groff manual.pdf: $(MANPAGES) -$(GROFF) -t -man $(MANPAGES) | ps2pdf - $@ diff --git a/foo2zjs-loadfw b/foo2zjs-loadfw new file mode 100644 index 0000000..c748b1a --- /dev/null +++ b/foo2zjs-loadfw @@ -0,0 +1,121 @@ +#!/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 + +# +# 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 [ -z "$DEVNAME" ]; then + if [ -n "$2" ]; then + DEVNAME=$2 + 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 +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 + 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 diff --git a/getweb.in b/getweb.in index 1841a3a..f17d084 100755 --- a/getweb.in +++ b/getweb.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash WGETOPTS=--passive-ftp diff --git a/hplj.usermap b/hplj.usermap new file mode 100644 index 0000000..0e8b64d --- /dev/null +++ b/hplj.usermap @@ -0,0 +1,4 @@ +hplj1000 0x0003 0x03f0 0x0517 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +hplj1005 0x0003 0x03f0 0x1317 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +hplj1018 0x0003 0x03f0 0x4117 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +hplj1020 0x0003 0x03f0 0x2b17 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 diff --git a/hplj1000 b/hplj1000 index ca57960..89fb2b6 100755 --- a/hplj1000 +++ b/hplj1000 @@ -35,7 +35,7 @@ DEV="" # # Directory to find downloadable HP firmware files sihpMMMM.dl # -FWDIR=/usr/share/foo2zjs/firmware +FWDIR=/lib/firmware # # Program used to determine USB id information diff --git a/hplj10xx.rules b/hplj10xx.rules index 2929a6d..b9dcde4 100644 --- a/hplj10xx.rules +++ b/hplj10xx.rules @@ -1,8 +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%e", MODE="0666", RUN+="/etc/hotplug/usb/hplj1000" +KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="0517", NAME="usb/%k", SYMLINK+="hplj1000%e", MODE="0660", GROUP="lp", RUN+="/sbin/foo2zjs-loadfw 1000" #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%e", MODE="0666", RUN+="/etc/hotplug/usb/hplj1005" +KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="1317", NAME="usb/%k", SYMLINK+="hplj1005%e", MODE="0660", GROUP="lp", RUN+="/sbin/foo2zjs-loadfw 1005" #Own udev rule for HP Laserjet 1018 -KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", SYSFS{product}=="HP LaserJet 1018", NAME="usb/%k", SYMLINK+="hplj1018%e", MODE="0666", RUN+="/etc/hotplug/usb/hplj1018" +KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="4117", NAME="usb/%k", SYMLINK+="hplj1018%e", MODE="0660", GROUP="lp", RUN+="/sbin/foo2zjs-loadfw 1018" #Own udev rule for HP Laserjet 1020 -KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", SYSFS{product}=="HP LaserJet 1020", NAME="usb/%k", SYMLINK+="hplj1020%e", MODE="0666", RUN+="/etc/hotplug/usb/hplj1020" +KERNEL=="lp*", BUS=="usb", SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="2b17", NAME="usb/%k", SYMLINK+="hplj1020%e", MODE="0660", GROUP="lp", RUN+="/sbin/foo2zjs-loadfw 1020" diff --git a/icc2ps/Makefile b/icc2ps/Makefile index e899212..97fa971 100644 --- a/icc2ps/Makefile +++ b/icc2ps/Makefile @@ -1,10 +1,10 @@ -PREFIX= /usr +PREFIX= ${DESTDIR}/usr BIN= $(PREFIX)/bin SRC= icc2ps.c xgetopt.c LIB= cmscam97.c cmscnvrt.c cmserr.c cmsgamma.c cmsgmt.c cmsintrp.c cmsio1.c \ cmslut.c cmsmatsh.c cmsmtrx.c cmsnamed.c cmspack.c cmspcs.c cmsps2.c \ cmssamp.c cmswtpnt.c cmsxform.c cmsio0.c cmsvirt.c -CFLAGS= -O3 +CFLAGS?= -O3 all: foo2zjs-icc2ps