On Fri, Dec 17, 2010 at 05:15:28PM +0100, Antoine Jacoutot wrote:
> Hi.
>
> I'd like people interested in USB scanning and/or printing to give these
> diffs a go. uscanner(4) was recently disabled in our GENERIC kernel
> configuration which means sane(7) will now default to use libusb for
> scanning. What these patches do is:
>
> * sane-backends
> - fix rc script, we won't use /dev/uscanner0 anymore
> - extend/fix the documentation
> Most of the time, USB scanning should just work *without* the need to
> configure anything (0).
>
> * cups
> - enable libusb support
> - fix rc script, we won't use /dev/ulpt[0-1] anymore
> - remove MESSAGE and add an extended README instead -- ulpt(4) needs to
> be disabled with config(8)
>
>
> With these I'm able to access and use my multi-function printer+scanner
> without issue:
> $ /usr/local/libexec/cups/backend/usb
> DEBUG: list_devices
> DEBUG: usb_find_busses=5
> DEBUG: usb_find_devices=1
> direct usb://EPSON/Stylus%20DX4000?serial=L83010704250947490&interface=1
> "EPSON Stylus DX4000" "EPSON Stylus DX4000"
> "MFG:EPSON;CMD:ESCPL2,BDC,D4,D4PX,ESCPR1;MDL:Stylus
> DX4000;CLS:PRINTER;DES:EPSON Stylus DX4000;" ""
> $ scanimage -L
> device `epson:libusb:/dev/usb1:/dev/ugen0' is a Epson CX4000 flatbed scanner
>
> As the README suggests, I have set the ownership of the corresponding
> usb+ugen device to _cups:_saned so that both print and scanning daemons
> can access the device. I also added my user to the _saned group so that
> I can access the scanner directly without having to use the daemon at
> all.
>
> Note that it is a first shot... things may (and probably will) change.
> Thanks.
>
> (0) scanning may not work reliably -- jakemsr@ has a fix for it but it
> still needs polishing --
I have just committed that.
> the most important is that your scanner is
> recognised using `scanimage -L'
>
> --
> Antoine
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/print/cups/Makefile,v
> retrieving revision 1.88
> diff -u -r1.88 Makefile
> --- Makefile 30 Nov 2010 08:09:09 -0000 1.88
> +++ Makefile 17 Dec 2010 15:39:04 -0000
> @@ -6,7 +6,7 @@
> DISTNAME= cups-${VERSION}-source
> PKGNAME= cups-${VERSION}
>
> -REVISION= 0
> +REVISION= 1
>
> CATEGORIES= print sysutils
>
> @@ -29,7 +29,7 @@
> PERMIT_DISTFILES_FTP= Yes
>
> WANTLIB += asn1 c crypto dbus-1>=7 gssapi jpeg krb5 m png>=3 pthread
> -WANTLIB += ssl stdc++ tiff>=35 z
> +WANTLIB += ssl stdc++ tiff>=35 z usb
>
> MASTER_SITES= http://ftp.easysw.com/pub/cups/${VERSION}/ \
>
> http://ftp.funet.fi/pub/mirrors/ftp.easysw.com/pub/cups/${VERSION}/ \
> @@ -51,6 +51,7 @@
>
> LIB_DEPENDS= graphics/png \
> graphics/tiff \
> + devel/libusb \
> x11/dbus
>
> LIBS_ENV= LIBcups_VERSION=${LIBcups_VERSION} \
> @@ -73,7 +74,7 @@
> AUTOMAKE_VERSION= 1.9
>
> USE_GMAKE= Yes
> -USE_GROFF = Yes
> +USE_GROFF= Yes
>
> CONFIGURE_STYLE= gnu dest
> CONFIGURE_ARGS= ${CONFIGURE_SHARED} \
> @@ -96,8 +97,8 @@
> --enable-raw-printing \
> --enable-gssapi \
> --enable-openssl \
> + --enable-libusb \
> --disable-gnutls \
> - --disable-libusb \
> --disable-pam \
> --disable-launchd \
> --disable-pap \
> @@ -106,7 +107,7 @@
>
> CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include \
> -I${LOCALBASE}/include/libpng" \
> - LDFLAGS="-L${LOCALBASE}/lib -pthread" \
> + LDFLAGS="-L${LOCALBASE}/lib" \
> ${LIBS_ENV}
>
> FLAVORS= ldap
> Index: pkg/MESSAGE
> ===================================================================
> RCS file: pkg/MESSAGE
> diff -N pkg/MESSAGE
> --- pkg/MESSAGE 27 Oct 2010 15:42:06 -0000 1.10
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,4 +0,0 @@
> -If you want to print to non-Postscript printers or use CUPS bundled PPD
> -files (i.e. drivers), you'll need to install ghostscript. You will also
> -most probably want to install the foomatic-filters package which
> -provides a universal filter script.
> Index: pkg/PLIST
> ===================================================================
> RCS file: /cvs/ports/print/cups/pkg/PLIST,v
> retrieving revision 1.28
> diff -u -r1.28 PLIST
> --- pkg/PLIST 12 Nov 2010 07:09:00 -0000 1.28
> +++ pkg/PLIST 17 Dec 2010 15:39:04 -0000
> @@ -1002,6 +1002,7 @@
> share/doc/cups/robots.txt
> share/doc/cups/ru/
> share/doc/cups/ru/index.html
> +share/doc/pkg-readmes/${FULLPKGNAME}
> share/examples/cups/
> @group _cups
> @sample ${SYSCONFDIR}/cups/
> Index: pkg/README
> ===================================================================
> RCS file: pkg/README
> diff -N pkg/README
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ pkg/README 17 Dec 2010 15:39:04 -0000
> @@ -0,0 +1,34 @@
> +$OpenBSD$
> +
> +Using CUPS under OpenBSD
> +========================
> +
> +If you want to print to non-Postscript printers or use CUPS bundled PPD
> +files (i.e. drivers), you'll need to install ghostscript. You will also
> +most probably want to install the foomatic-filters package which
> +provides a universal filter script.
> +
> +Depending on your printer model you may need to install some driver
> +package like (non-exhaustive list): hplip, gutenprint, foo2zjs, splix...
> +
> +libusb and permissions
> +----------------------
> +To make your USB printer work with CUPS, you'll have to disable ulpt(4)
> +in your kernel - see config(8) - which will allow libusb to claim your
> +device.
> +
> +Since USB printing is handled by libusb, you need to allow the _cups
> +user rw access to the corresponding USB endpoint. To do so, find where
> +your printer is attached to using dmesg(8) then change the ownerships
> +accordingly.
> +ugenX = /dev/ugenX
> +uhubX = /dev/usbX
> +
> +e.g.
> +$ dmesg | grep ugen
> +ugen0 at uhub1 port 1 "EPSON USB MFP" rev 1.10/1.00 addr 2
> +$ sudo chown _cups /dev/ugen0.* /dev/usb1
> +
> +The reason we are changing the user and not the group is that it will
> +allow for multi-function devices to work for both printing and scanning
> +(e.g. by being owned by _cups:_saned).
> Index: pkg/cupsd.rc
> ===================================================================
> RCS file: /cvs/ports/print/cups/pkg/cupsd.rc,v
> retrieving revision 1.4
> diff -u -r1.4 cupsd.rc
> --- pkg/cupsd.rc 30 Nov 2010 08:09:09 -0000 1.4
> +++ pkg/cupsd.rc 17 Dec 2010 15:39:04 -0000
> @@ -13,7 +13,6 @@
> /usr/share/man/cat8/lpd.0"
>
> rc_pre() {
> - [ -e /dev/ulpt0 ] && chown _cups /dev/ulpt[0-1]
> [ -e /dev/lpt0 ] && chown _cups /dev/lp[a,t][0-2]
>
> if [ -e /usr/sbin/lpd.pre-cups -a ! -f /usr/sbin/lpd -a -L
> /usr/sbin/lpc ]; then
> @@ -60,7 +59,6 @@
> fi
>
> [ -e /dev/lpt0 ] && chown root /dev/lp[a,t][0-2]
> - [ -e /dev/ulpt0 ] && chown root /dev/ulpt[0-1]
> }
>
> rc_cmd $1
> Index: pkg/README
> ===================================================================
> RCS file: /cvs/ports/graphics/sane-backends/pkg/README,v
> retrieving revision 1.2
> diff -u -r1.2 README
> --- pkg/README 6 Dec 2010 18:51:09 -0000 1.2
> +++ pkg/README 17 Dec 2010 15:38:46 -0000
> @@ -5,27 +5,43 @@
>
> First read ${TRUEPREFIX}/share/doc/sane-backends/PROBLEMS.
>
> -Make sure your user has read/write access to the scanner device
> -(e.g. /dev/uscanner0) or you will not be able to scan.
> +USB
> +---
> +Since USB scanning is handled by libusb, you need to allow the _saned
> +group rw access to the corresponding USB endpoint. To do so, find where
> +your scanner is attached to using dmesg(8) then change the ownerships
> +accordingly.
> +ugenX = /dev/ugenX
> +uhubX = /dev/usbX
>
> -* USB
> -With some USB backends, the OpenBSD uscanner(4) driver does not support
> -getting USB vendor and product ids. To make your scanner work with sane,
> -you'll have to disable uscanner(4) in your kernel - see config(8) -
> -which will allow libusb to claim your device instead. When using libusb,
> -you need read/write permissions to ugen(4) (/dev/ugen*.*) and the usb(4)
> -controller (/dev/usb*) your scanner is connected to (consider using
> -hotplugd(8) attach and detach scripts).
> +e.g.
> +$ dmesg | grep ugen
> +ugen0 at uhub1 port 1 "EPSON USB MFP" rev 1.10/1.00 addr 2
> +$ sudo chgrp _saned /dev/ugen0.* /dev/usb1
>
> -* SCSI
> +The reason we are changing the group and not the user is that it will
> +allow for multi-function devices to work for both printing and scanning
> +(e.g. by being owned by _cups:_saned).
> +
> +You can now grant users access to the scanner by adding them to the
> +_saned group.
> +
> +SCSI
> +----
> SANE only supports the generic SCSI uk(4) devices.
> +Make sure your user has read/write access to the scanner device or you
> +will not be able to scan.
>
> -* LOCKING
> +LOCKING
> +-------
> Some backends (like sane-plustek(5)) use a lockfile for allowing
> multiple access to one scanner. If using such a backend, you must
> add yourself to the _saned group or you will not be able to scan.
>
> -* NETWORK
> +NETWORK
> +-------
> +The saned(8) daemon needs rw access to your device, make sure the _saned
> +group as rw permissions.
> If you're planning on using the SANE network daemon (saned) with
> inetd(8) as opposed to starting it standalone from the provided rc
> script, add the following line in /etc/services:
> Index: pkg/saned.rc
> ===================================================================
> RCS file: /cvs/ports/graphics/sane-backends/pkg/saned.rc,v
> retrieving revision 1.4
> diff -u -r1.4 saned.rc
> --- pkg/saned.rc 11 Dec 2010 12:57:37 -0000 1.4
> +++ pkg/saned.rc 17 Dec 2010 15:38:46 -0000
> @@ -8,12 +8,4 @@
> daemon_flags="-a _saned"
> rc_reload=NO
>
> -rc_pre() {
> - [ -e /dev/uscanner0 ] && chgrp _saned /dev/uscanner0
> -}
> -
> -rc_post() {
> - [ -e /dev/uscanner0 ] && chgrp wheel /dev/uscanner0
> -}
> -
> rc_cmd $1
--
[email protected]
SDF Public Access UNIX System - http://sdf.lonestar.org