Rebuilding SANE (Canon Pixma MP730) for Ubuntu

I'm still seeking a new distro that takes less work than Gentoo but sits on the cutting edge and has reasonable package management. Kubuntu is potentially my next favourite distro and I'm currently running 9.04. I hate KDE4 but that's another story. Long live KDE3!

Unfortunately, the work we did in resolving the scanning problems for the Canon MP730 (pixma driver) didn't make it into SANE before 1.0.20 was released so probably even Ubuntu Karmic won't have MP730 support until SANE tags a new release. This leaves me with a problem: How do I rebuild the SANE packages to get my scanner supported?

Here are the steps to get the MP730 (and MP700) working in Ubuntu:

Update 29/8/09: Julien Blache, the maintainer of the Debian packages that Ubuntu builds on, has kindly incorporated the necessary patch starting with 1.0.20-6. You can save yourself a lot of trouble by simply using his packages. Look for a file named 'libsane_1.0.20-6_<arch>.deb' where <arch> is the architecture (amd64, i386 etc) of your machine, at http://ftp.debian.org/debian/pool/main/s/sane-backends/ then download and install it the same way as noted below. Jaunty users will likely get failed dependencies for libgphoto2 and libsane-extras but they can be safely ignored for the purposes of getting a working MP700/MP730 scanner. These packages do not require libusb to be installed.

Download

Download all the files from the Download section of https://launchpad.net/ubuntu/karmic/+source/sane-backends/1.0.20-4ubuntu2 to a temporary working directory, then open a shell window in that directory.

$ mkdir sane
$ cd sane
$ wget https://launchpad.net/ubuntu/karmic/+source/sane-backends/1.0.20-4ubuntu2/+files/{sane-backends_1.0.20.orig.tar.gz,sane-backends_1.0.20-4ubuntu2.diff.gz,sane-backends_1.0.20-4ubuntu2.dsc}

Download Nicolas' patch to sanei/sanei_usb.c that is attached to this page.

$ wget http://waddles.org/sane-backends_1.0.20-fix_sanei_usb.patch_.txt

Download my debian/rules patch. Note that this patch will only produce a backend library for the pixma driver and will also prevent documentation being built with Latex which reduces the amount of extra package dependencies needed for building. If you want all backends to be built, just remove the first hunk of the patch or remove the BACKENDS="pixma" prefix to configure in debian/rules.

$ wget http://waddles.org/sane-backends_1.0.20-pixma_only.patch_.txt

Unpack

$ dpkg-source -x sane-backends_1.0.20-4ubuntu2.dsc
dpkg-source: extracting sane-backends in sane-backends-1.0.20
dpkg-source: info: unpacking sane-backends_1.0.20.orig.tar.gz
dpkg-source: info: applying sane-backends_1.0.20-4ubuntu2.diff.gz

Patch

$ pushd sane-backends-1.0.20
$ patch -p1 --ignore-whitespace < ../sane-backends_1.0.20-fix_sanei_usb.patch.txt
patching file sanei/sanei_usb.c
$ patch -p1 --ignore-whitespace < ../sane-backends_1.0.20-pixma_only.patch.txt
patching file debian/rules

Build

$ dpkg-buildpackage -rfakeroot -b
dpkg-buildpackage: set CFLAGS to default value: -g -O2
dpkg-buildpackage: set CPPFLAGS to default value:
dpkg-buildpackage: set LDFLAGS to default value: -Wl,-Bsymbolic-functions
dpkg-buildpackage: set FFLAGS to default value: -g -O2
dpkg-buildpackage: set CXXFLAGS to default value: -g -O2
dpkg-buildpackage: source package sane-backends
dpkg-buildpackage: source version 1.0.20-4ubuntu2
dpkg-buildpackage: source changed by Martin Pitt <[email protected]>
dpkg-buildpackage: host architecture amd64
dpkg-checkbuilddeps: Unmet build dependencies: libv4l-dev libgphoto2-2-dev libltdl3-dev libjpeg62-dev libtiff4-dev libusb-dev (>= 2:0.1.10a-9) libieee1284-3-dev (>= 0.2.10-5) libavahi-client-dev (>= 0.6.4) texlive-latex-extra autotools-dev chrpath
dpkg-buildpackage: warning: Build dependencies/conflicts unsatisfied; aborting.
dpkg-buildpackage: warning: (Use -d flag to override.)

If you have everything installed already, you should end up with .deb files in your parent directory at this point, however, they will probably still be broken. I had to build it with libusb to make it work properly, so you should continue anyway. The step above is really to work out what dependencies are needed to build the packages. I'm going to force an override to avoid most of them anyway.

Install build dependencies

These are the packages I really needed to install:

$ sudo apt-get install autotools-dev chrpath libusb-1.0-0-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libusb-1.0-0
The following NEW packages will be installed:
  autotools-dev chrpath libusb-1.0-0 libusb-1.0-0-dev
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/254kB of archives.
After this operation, 1364kB of additional disk space will be used.
Do you want to continue [Y/n]?
Selecting previously deselected package autotools-dev.
(Reading database ... 300410 files and directories currently installed.)
Unpacking autotools-dev (from .../autotools-dev_20080123.2_all.deb) ...
Selecting previously deselected package chrpath.
Unpacking chrpath (from .../chrpath_0.13-2_amd64.deb) ...
Selecting previously deselected package libusb-1.0-0.
Unpacking libusb-1.0-0 (from .../libusb-1.0-0_2%3a1.0.0-1_amd64.deb) ...
Selecting previously deselected package libusb-1.0-0-dev.
Unpacking libusb-1.0-0-dev (from .../libusb-1.0-0-dev_2%3a1.0.0-1_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for doc-base ...
Processing 1 added doc-base file(s)...
Registering documents with scrollkeeper...
Setting up autotools-dev (20080123.2) ...
Setting up chrpath (0.13-2) ...
Setting up libusb-1.0-0 (2:1.0.0-1) ...

Setting up libusb-1.0-0-dev (2:1.0.0-1) ...

Processing triggers for libc6 ...
ldconfig deferred processing now taking place

Build the .deb packages

$ dpkg-buildpackage -rfakeroot -b -d

Note the -d flag to override the missing dependencies. I have removed the output from this step as it is fairly pointless.

You should now have a set of .deb packages in your parent directory.

Install

Install at least the libsane .deb file which contains the patched sanei/sanei_usb.c code. The others don't seem to be necessary but you may choose to install all of them anyway.

$ sudo dpkg -i ../libsane_1.0.20-4ubuntu2_amd64.deb
(Reading database ... 300705 files and directories currently installed.)
Preparing to replace libsane 1.0.19-23ubuntu7 (using .../libsane_1.0.20-4ubuntu2_amd64.deb) ...
Unpacking replacement libsane ...
Setting up libsane (1.0.20-4ubuntu2) ...
Installing new version of config file /etc/sane.d/dll.conf ...

Processing triggers for man-db ...
Processing triggers for hal ...
Regenerating hal fdi cache ...
* Restarting Hardware abstraction layer hald                                            [ OK ]
Processing triggers for libc6 ...
ldconfig deferred processing now taking place
 

Scan

I did have a permissions issue as a normal user when scanning from Gimp which magically resolved itself, but now scanning works fine using scanimage, xsane or xscanimage with or without the Gimp.

$ sane-find-scanner

  # sane-find-scanner will now attempt to detect your scanner. If the
  # result is different from what you expected, first make sure your
  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that
  # you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x04a9 [Canon Inc.], product=0x262f [MP730]) at libusb:003:002
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports
  # can't be detected by this program.

  # You may want to run this program as root to find all devices. Once you
  # found the scanner devices, be sure to adjust access permissions as
  # necessary.
$ scanimage -L
libusb couldn't open USB device /dev/bus/usb/001/001: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/002/001: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/003/001: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/004/001: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/001/003: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/004/002: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/001/004: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/001/005: Permission denied.
libusb requires write access to USB device nodes.
device `pixma:04A9262F_00000000F972' is a CANON Canon MultiPASS MP730 multi-function peripheral
$ scanimage -d pixma:04A9262F_00000000F972 --resolution 150 --mode Color --format pnm -x 10 -y 20 > /tmp/foo2.pnm
libusb couldn't open USB device /dev/bus/usb/001/001: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/002/001: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/003/001: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/004/001: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/001/003: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/004/002: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/001/004: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/001/005: Permission denied.
libusb requires write access to USB device nodes.

Ignore all those lines from libusb - they are for other devices in my USB subsystem. The scan worked successfully.

comments powered by Disqus