Bug 133417

Summary: /etc/init.d/sane-dev fails with 2 scanners, because of scanimage output
Product: [openSUSE] SUSE LINUX 10.0 Reporter: Siegbert Baude <siegbert.baude>
Component: BasesystemAssignee: Johannes Meixner <jsmeix>
Status: RESOLVED INVALID QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None    
Version: Final   
Target Milestone: ---   
Hardware: Other   
OS: SuSE Linux 10.0   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Siegbert Baude 2005-11-11 09:09:51 UTC
/etc/init.d/sane-dev tries to parse the output of
scanimage --formatted-device-list "%d"
with a for-loop. This fails if you have more than one device, because scanimage doesn't put newline or whitespace in the output between the devices. E.g. on my system it gives:
# /usr/bin/scanimage -f "%d"
v4l:/dev/video0umax:/dev/sg1#

A workaround given in https://alioth.debian.org/tracker/?group_id=30186&atid=410366&func=detail&aid=302446
would be to change the call of scanimage in /etc/init.d/sane-dev to:
        devices=`/usr/bin/scanimage -f "%d
                "`
i.e. insert the newline directly after the %d parameter. This works for me, but seems not to be very elegant. Maybe you can find an agreement with the upstream sane developpers or patch the SUSE version of scanimage. Its output is simply not usable at the moment.
Comment 1 Johannes Meixner 2005-11-11 10:47:00 UTC
Do you realy have more than one scanner?
/etc/init.d/sane-dev works well for my scanners.
Did you really inspect it carefully?
In particular note the following lines:
---------------------------------------------------------------------
cat ${store_file}.raw | tr ',' '\n' | grep -v 'net:' | tr ':' '\n' \
 | grep '^/dev/' | sort -u >$store_file
---------------------------------------------------------------------
do [ -c $d ] && chmod 666 $d && echo -n "$d "
---------------------------------------------------------------------
Comment 2 Johannes Meixner 2005-11-11 10:52:56 UTC
Your SANE device name "v4l:/dev/video0umax:/dev/sg1" is strange.
A normal SCSI scanner has a SANE device like "hp:/dev/sg0".
I assume /etc/init.d/sane-dev mai fail because of your strange
SANE device name.

Show me your files
/var/lib/sane/devices.raw
and
/var/lib/sane/devices
Comment 3 Johannes Meixner 2005-11-11 10:59:46 UTC
It works for me even with a SANE device like "v4l:/dev/video0umax:/dev/sg1".
I get in /var/lib/sane/devices
/dev/sg1
/dev/video0umax
Then it depends on what the "[ -c $d ]" test results for those
device files.
Note that (inientionally) only character devices are changed
(see the comment in /etc/init.d/sane-dev).

Comment 4 Siegbert Baude 2005-11-12 15:57:20 UTC
Thanks for your fast reply.

O.k., there were two things, which influenced the behaviour. First, this was an upgrade from 10.0-OSS-RC1 and no clean install. Second, the guru and packman repositories not only updated the multimedia, but also the sane RPMs, where /etc/init.d/sane-dev is quite different from the original SUSE one. But even after downgrading to the original SUSE one, /var/lib/sane/devices remained empty. So I decided to reinstall from scratch to check the behaviour.

Now the scanner detection only detects my scanner and leaves out my TV card as scanner device (contrary to the behaviour of the guru sane package, which you stumbled upon). The script magic now works as expected.

The only thing, which could still be improved, is: After the scanner detection in yast, the sane-dev script seems to be not called directly. So the permissions are not yet set, to be able to scan as normal user. Only after a reboot or calling sane-dev as root by hand, everything is perfect. Is this worth a separate bug report, or can you just check this?

So, sorry for the fuzz, next time I will check which version I actually use before a bug report. :-) If my reported problem was triggered by the update from OSS-RC1 or by the guru-packaging, I will check out for my own.
Comment 5 Johannes Meixner 2005-11-14 09:58:31 UTC
Regarding "After the scanner detection in yast, the sane-dev script
seems to be not called directly":

YaST runs sane-dev if there is a SANE device with the sub-sting ":/dev/",
see the SetScsiScannerAccessPermissions() function in
/usr/share/YaST2/modules/Scanner.ycp
You can test it with
scanimage -L | grep ":/dev/"