Tuesday, August 4, 2009

Compiling Sane from GIT

My trusty old scanjet 4c just gave up a few months ago and all I was left with was a crappy Scanjet ScanJet G2710, which has a really basic driver. And basic I mean it can only be trusted to scan BW drawings, not even grayscale gets a decent result.

But that was not the only problem. Even though I use Debian SID (unstable) in all my workstations the sane backends were not detecting my scanner so I've had to compile from the sources. Being lazy, one of the big virtues of a hacker according to Eric Raymond, I've created a bash script to fetch the sources from CVS, compile and install sane.

Now that sane has switched to GIT I've rewrote the script and added a patch to xsane so I would not have to manually declare the SANE_CAP_ALWAYS_SETTABLE constant, which has been removed by sane but is still used by xsane. I seems Oliver Rauch has some problems with the way the sane development is going and is not updating xsane to conform to the changes made to the sane backends.

You can download the script form here

Below is the listing of the script

#!/bin/bash

co_compile_install()
{
DIR=$1
PARAMS=$2
COMMAND=$3
if [ -d $DIR ]; then
echo "Directory exists - UPDATING"
cd $DIR
#svn update
git pull
else
echo "Directory does not exists - CHECKING OUT"
git clone git://git.debian.org/sane/$DIR
cd $DIR
fi

if [ -n $COMMAND ]
then
eval $COMMAND
fi

./autogen.sh
pwd
./configure --sysconfdir=/etc --prefix=/usr && make && make install
cd ..
}

co_compile_install sane-backends.git
co_compile_install sane-frontends.git

wget ftp://ftp.sane-project.org/pub/sane/xsane/xsane-0.996.tar.gz
tar -zxvf xsane-0.996.tar.gz
cd xsane-0.996

rm -f /tmp/xsane-back-gtk.h.diff
cat >> /tmp/xsane-back-gtk.h.diff << EOF
55a56
> #define SANE_CAP_ALWAYS_SETTABLE 7
EOF
patch src/xsane-back-gtk.h /tmp/xsane-back-gtk.h.diff
rm -f /tmp/xsane-back-gtk.h.diff

./configure --sysconfdir=/etc --prefix=/usr && make && make install

No comments: