Linux HOWTOs

About | Home | Search


HOWTO: sane
Description: Scanner Access Now Easy - API for scanners
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# SANE
# ====
# To see how I got my Epson Perfection 2400 Photo (USB) set up, go here:
# http://englanders.cc/~jason/scanner.php

# This howto used to use the default prefix (/usr/local).  If you have an
# old version of anything below that was installed from source, cd into
# it's source directory and run 'make uninstall' before you proceed here.

# Create necessary directories (for the permanant home of the tarball and
# source), remove the Slackware 'sane' package if there is one, and back up
# the sane.d configuration directory (~/backup/sane.d-yyyymmdd.tar.bz2):
mkdir -p -m 0700 ~/installed/sane ~/src/sane
su
test -x /sbin/removepkg && /sbin/removepkg sane
test -d /etc/sane.d &&
 ( mkdir -p -m 0700 ~/backup
   cd ~/backup
   tar cjvf sane.d-`date +%Y%m%d`.tar.bz2 /etc/sane.d )
test -d /etc/sane.d && rm -r /etc/sane.d
exit


# sane-backends 1.0.18
# ====================
# Slackware 9.0's 'sane' package includes sane-backends version 1.0.11,
# 9.1's includes 1.0.12, 10.0's includes 1.0.14, 10.1's includes 1.0.15,
# 10.2's includes 1.0.16, 11.0 and 12.0's include 1.0.18

# Prerequisites:
# gettext
# tex's dvips, texi2pdf (Slackware has a 'tetex' package)
# libjpeg (for certain backends)
# libieee1284 >= 0.1.5 (for certain backends, if you have a parallel port
#   scanner)
# pkg-config
# libgphoto2 >= 2.0 (for the gphoto2 backend)
# libusb >= 0.1.6 (if you have a USB scanner)

# I use the --disable-translations configure option below because I'm in the
# U.S. and only read/write English (well <g>).  If this is not the
# case for you, leave that option off.

cd
test -f installed/sane/sane-backends-1.0.18.tar.gz &&
 mv installed/sane/sane-backends-1.0.18.tar.gz .
test ! -f sane-backends-1.0.18.tar.gz &&
 wget ftp://ftp.sane-project.org/pub/sane/sane-backends-1.0.18/\
sane-backends-1.0.18.tar.gz

# Verify tarball w/ md5sum:
echo "7ca7e2908e24721471de92cf40c75e60  sane-backends-1.0.18.tar.gz" | \
 md5sum -c

cd src/sane
find -maxdepth 1 -type d -name "sane-backends-*" -exec rm -r {} \;
tar xzvf ~/sane-backends-1.0.18.tar.gz
cd sane-backends-1.0.18
test $UID = 0 && chown -R root:root .

# configure has to be run as root for the configure test that checks to
# make sure that the --with-group group exists
# (normally we'd become root after 'make' has been run)
su

# Create the scanner group, if you don't already have one
getent group | grep "^scanner:" > /dev/null 2>&1 || groupadd scanner

# Add user jason to that group
gpasswd -a jason scanner

# Build it
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
 --disable-ipv6 --disable-translations --with-group=scanner 
make
find /usr/doc -maxdepth 1 -type d -name "sane-*" -exec rm -r {} \;

# When upgrading sane-backends, I periodically like to blow away my
# configuration directory (which was backed up above) to make sure I'm not
# missing anything new in there:
test -d /etc/sane.d && rm -r /etc/sane.d

( cd /usr/lib ; rm -f libsane.* sane/libsane-*.so.* )
make install
ldconfig
chown -R $USER .
chmod -R u+w .

# If you have a USB scanner, you basically have three choices for how to
# set it up.  Use the scanner.o module that comes with 2.4.x kernels (it
# doesn't come with >= 2.6.3), use hotplug and libusb
# on older machines, or use udev and libusb.
#
#
# 1) 2.4.x kernels
# To use the module, make sure you have CONFIG_USB_SCANNER ("USB Scanner
# support") set to 'm'.  Once it's built and installed, run 'modprobe scanner'
# and you should see something like this:
#
# usb.c: registered new driver usbscanner
# scanner.c: USB scanner device (0x04b8/0x011b) now attached to scanner0
# scanner.c: 0.4.16:USB Scanner Driver
#
# Then to set up SANE to use it, open up the appropriate config file for
# your backend (/etc/sane.d/scannertype.conf) and put a line like this in
# there:
# usb /dev/usb/scanner0
#
# and open up /etc/sane.d/dll.conf and make sure the scannertype line is not
# commented out.  Make sure any users that will be using the scanner have
# appropriate permissions to access /dev/usb/scanner0
#
#
# 2) hotplug
# The second option is to use libusb and have hotplug handle setting the
# permissions so non-root users can use the scanner.
#
# Install the hotplug files included with sane-backends:
install -m 644 tools/hotplug/libsane.usermap /etc/hotplug/usb/
install tools/hotplug/libusbscanner /etc/hotplug/usb/
#
# This part tells hotplug to not load the scanner.o module (so sane can use
# libusb instead).  This is not necessary if you use kernel 2.6.3 or greater,
# the scanner.o module no longer exists in >= 2.6.3
egrep -q "^scanner$" /etc/hotplug/blacklist || \
 echo -e "\n# Added for SANE\nscanner\n\n" >> /etc/hotplug/blacklist
#
# and now either add add each user that can have access to the scanner to
# the scanner group:  gpasswd -a user scanner
# (the user will have to log in again for it to take effect)
# or open up /etc/hotplug/usb/libusbscanner and change the 0660 to
# 0666 to give everyone on the system access to it.
#
# FYI, libusbscanner will change the permissions of the device as seen
# by hotplug.  This will be named something like /proc/bus/usb/001/009.
# If you need to know what that device file name is, run 'scanimage -L' as
# root.  If it says 'epson:libusb:001:011', then the file is
# /proc/bus/usb/001/011.
#
# You may notice that you don't have access to the scanner if you're
# logged in but aren't in a login shell.  If 'scanimage -L' doesn't
# work, but you 'su - username' and then it does work, this is probably
# the case.  If you have that trouble, it may be easier to just set
# the permissions to 666 in libusbscanner.
#
# Make sure that /etc/hotplug/usb/libsane.usermap knows about your scanner.
# If not, add an entry for yours.  You can get it's vendor and product ID by
# running 'lsusb' as root, or by running 'sane-find-scanner' or
# 'scanimage -L' if everything is configured and working.  Once you're set,
# then post your entry (telling them what scanner it is) to the sane-devel
# mailing list so it can be added in a future release.
#
#
# 3) udev
# If you use udev, make sure you have CONFIG_USB_DEVICEFS and
# CONFIG_USB_DEVICE_CLASS (which is deprecated in 2.6.23.14) enabled in
# your kernel or you'll have a nice headache trying to get udev set up to
# get the permissions set as you need them.
#
# Back up your existing rules file (if you have one) and copy the sample
# rules file into place.  It's set to use the "scanner" group, if you named
# your group something else, make sure you change it in the rules file.
# Make sure you log out and back in if you haven't done so since you added
# that user to the scanner group.  You may want/need to name the rules file
# something like 45-libsane.rules so it gets loaded at the right time.
test -f /etc/udev/rules.d/libsane.rules &&
 ( mkdir -p -m 0700 ~/backup
   cp /etc/udev/rules.d/libsane.rules ~/backup/ )
cp tools/udev/libsane.rules /etc/udev/rules.d/
test -x /etc/rc.d/rc.udev && /etc/rc.d/rc.udev reload

# Now unplug and replug your scanner's USB cable so the device file will
# be re-created with the correct ownership and permissions.
#
# If you have any trouble setting up a USB scanner with udev, see:
# (in no particular order)
# * /usr/doc/sane-1.0.18/README.linux
# * man sane-usb
# * http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
# * the home page for your SANE backend:
#   http://www.sane-project.org/sane-backends.html
# * http://tldp.org/HOWTO/Scanner-HOWTO/

# To configure my scanner's backend, I opened up /etc/sane.d/dll.conf and
# commented out every line except for "epson" (it's an "Epson Perfection
# 2400 Photo" scanner.  If you won't ever be messing with others, and you
# also use the "epson" backend, you may just want to do this:
#   echo "epson" > /etc/sane.d/dll.conf
# This is not really necessary, but I don't use any other backend on a
# regular basis, so why not.  I use libusb, so I didn't need to change
# anything in /etc/sane.d/epson.conf
# One line "usb" in there is sufficient, for mine anyway.

# Become yourself again
exit

cd
rm -f installed/sane/sane-backends-*.tar.*
mv sane-backends-1.0.18.tar.gz installed/sane/


# sane-frontends 1.0.14
# =====================
# Slackware 9.0's 'sane' package includes sane-frontends version 1.0.10,
# 9.1's includes 1.0.11, 10.0's includes 1.0.12, 10.1's and 10.2's
# include 1.0.13, 11.0 and 12.0's include 1.0.18

# Prerequisites:
# XFree86 or X.org (for xscanimage and xcam)
# GTK+ (for xscanimage and xcam)
# The Gimp (to use xscanimage as a gimp plugin)

cd
test -f installed/sane/sane-frontends-1.0.14.tar.gz &&
 mv installed/sane/sane-frontends-1.0.14.tar.gz .
test ! -f sane-frontends-1.0.14.tar.gz &&
 wget ftp://ftp.sane-project.org/pub/sane/sane-frontends-1.0.14/\
sane-frontends-1.0.14.tar.gz

# Verify tarball w/ md5sum:
echo "c63bf7b0bb5f530cf3c08715db721cd3  sane-frontends-1.0.14.tar.gz" | \
 md5sum -c

cd src/sane
find -maxdepth 1 -type d -name "sane-frontends-*" -exec rm -r {} \;
tar xzvf ~/sane-frontends-1.0.14.tar.gz
cd sane-frontends-1.0.14
test $UID = 0 && chown -R root:root .
./configure --prefix=/usr --sysconfdir=/etc
make
su -c "make install"
cd
rm -f installed/sane/sane-frontends-*.tar.*
mv sane-frontends-1.0.14.tar.gz installed/sane/


# GOCR 0.45 - commandline OCR tool
# =========
# Prerequisites:
# netpbm (optional)
# transfig (optional)

cd
test -f installed/sane/gocr-0.45.tar.gz &&
 mv installed/sane/gocr-0.45.tar.gz .
test ! -f gocr-0.45.tar.gz &&
 wget http://download.sf.net/jocr/gocr-0.45.tar.gz
cd src/sane
find -maxdepth 1 -type d -name "gocr-*" -exec rm -r {} \;
tar xzvf ~/gocr-0.45.tar.gz
cd gocr-0.45
test $UID = 0 && chown -R root:root .
./configure
make
make examples
su -c "make install"
cd
rm -f installed/sane/gocr-*.tar.*
mv gocr-0.45.tar.gz installed/sane/


# XSane 0.995
# ===========
# Slackware 9.0's 'xsane' package includes version 0.90, 9.1's includes 0.91,
# 10.0's includes 0.93, 10.1's includes 0.96, 10.2's includes 0.97, 11.0's
# includes 0.997, and 12.0's includes 0.994

# Prerequisites:
# sane >= 1.0.0
# GTK+ 1.2.x
# Glib 1.2.x
# zlib (for png support)
# libpng (for png support)
# libjpeg (for jpeg support)
# libtiff (for tiff support)
# LCMS (color management)
# The Gimp >= 1.3.23 (to use xsane as a gimp plugin)

cd
test -f installed/sane/xsane-0.995.tar.gz &&
 mv installed/sane/xsane-0.995.tar.gz .
test ! -f xsane-0.995.tar.gz &&
 wget ftp://ftp.sane-project.org/pub/sane/xsane/xsane-0.995.tar.gz
cd src/sane
find -maxdepth 1 -type d -name "xsane-*" -exec rm -r {} \;
tar xzvf ~/xsane-0.995.tar.gz
cd xsane-0.995
test $UID = 0 && chown -R root:root .
./configure --prefix=/usr --disable-nls
make

# Become root to install it
su

test -x /sbin/removepkg && /sbin/removepkg xsane
make install

# Become yourself again
exit

# src/xsane-48x48.png in the source directory makes for a good desktop icon

cd
rm -f installed/sane/xsane-*.tar.*
mv xsane-0.995.tar.gz installed/sane/

Back to the list


Last updated: Mon, 30 May 2016 18:30:05 -0400
Jason Englander <jason at englanders dot us>