From 1dfd8181df68cbc22441d6938f5b9518903b593b Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Thu, 13 Mar 2003 00:55:20 +0000 Subject: Bug fixes: - SHOWSTOPPER: SCSI scanners were never recognized as already configured, the user was always asked whether he wants to configure them. Problem was that device files are symlinks. - Made most ISDN and ADSL devices not being considered as a scanner by Scannerdrake, SANE does not support internet scanners. --- perl-install/scanner.pm | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/perl-install/scanner.pm b/perl-install/scanner.pm index 3c8f60a8c..88c607970 100755 --- a/perl-install/scanner.pm +++ b/perl-install/scanner.pm @@ -150,7 +150,7 @@ sub detect { } # The Alcatel Speed Touch internet scanner is not supported by # SANE - next if $description =~ /Alcatel.*Speed.*Touch|Camera/i; + next if $description =~ /Alcatel.*Speed.*Touch|Camera|ISDN|ADSL/i; # Extract port $line =~ /\s+(\S+)\s*$/; $port = $1; @@ -190,11 +190,14 @@ sub detect { if (@configured) { # Remove scanners which are already working foreach my $d (@res) { - my $searchport1 = handle_configs::searchstr($d->{port}); - my $searchport2 = handle_configs::searchstr($d->{port2}); + my $searchport1 = + handle_configs::searchstr(resolve_symlinks($d->{port})); + my $searchport2 = + handle_configs::searchstr(resolve_symlinks($d->{port2})); foreach my $c (@configured) { - if ($c->{port} =~ /$searchport1$/ || - $searchport2 && $c->{port} =~ /$searchport2$/) { + my $currentport = resolve_symlinks($c->{port}); + if ($currentport =~ /$searchport1$/ || + $searchport2 && $currentport =~ /$searchport2$/) { $d->{configured} = 1; last; } @@ -205,6 +208,35 @@ sub detect { return @res; } +sub resolve_symlinks { + + # Check if a given file (either the pure filename or in a SANE device + # string as ":") is a symlink, if so expand the link. + # If the new file name is a link, expand again, until finding the + # physical file. + my ($file) = @_; + my $prefix = ""; + if ($file =~ m!^([^/]*)(/.*)$!) { + $prefix = $1; + $file = $2; + } else { + return $file; + } + while (1) { + my $ls = `ls -l $file`; + if ($ls =~ m!\s($file)\s*\->\s*(\S+)\s*$!) { + my $target = $2; + if (($target !~ m!^/!) && ($file =~ m!^(.*)/[^/]+$!)) { + $target = "$1/$target"; + } + $file = $target; + } else { + last; + } + } + return $prefix . $file; +} + sub get_usb_ids_for_port { my ($port) = @_; local *DETECT; -- cgit v1.2.1