summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2003-02-13 02:16:18 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2003-02-13 02:16:18 +0000
commitaf269e66df35a62d822501f66421e11e89568f87 (patch)
tree1aea55ffd229aa3f438c9bbe68d559061b42ff4c
parent2314ca1d9dd8072d7288a622aabd2695142b81c9 (diff)
downloaddrakx-backup-do-not-use-af269e66df35a62d822501f66421e11e89568f87.tar
drakx-backup-do-not-use-af269e66df35a62d822501f66421e11e89568f87.tar.gz
drakx-backup-do-not-use-af269e66df35a62d822501f66421e11e89568f87.tar.bz2
drakx-backup-do-not-use-af269e66df35a62d822501f66421e11e89568f87.tar.xz
drakx-backup-do-not-use-af269e66df35a62d822501f66421e11e89568f87.zip
Improved handling and structure of scanner database
- Scanners with multiple ports are supported now - Fully automatic build of the scanner database, including lines for configuration files - Fixed "SnapScan" <-> "snapscan" bug - Some HP scanners had no manufacturer field. Fixed.
-rw-r--r--perl-install/handle_configs.pm16
-rwxr-xr-xperl-install/scanner.pm74
-rwxr-xr-xperl-install/standalone/scannerdrake12
3 files changed, 77 insertions, 25 deletions
diff --git a/perl-install/handle_configs.pm b/perl-install/handle_configs.pm
index 185d45b38..df817aac0 100644
--- a/perl-install/handle_configs.pm
+++ b/perl-install/handle_configs.pm
@@ -129,12 +129,13 @@ sub set_directive {
# Set a directive, replace the old definition or a commented definition
- my ($lines_ptr, $directive) = @_;
+ my ($lines_ptr, $directive, $full_line) = @_;
- my $searchdirective = searchstr($directive);
- my $olddirective = $searchdirective;
- $olddirective =~ s/^\s*(\S+)\s+.*$/$1/s;
- $olddirective ||= $directive;
+ my $olddirective = $directive;
+ if (!$full_line) {
+ $olddirective =~ s/^\s*(\S+)\s+.*$/$1/s;
+ $olddirective ||= $directive;
+ }
my $success = (replace_directive($lines_ptr, $olddirective,
$directive) or
@@ -152,11 +153,6 @@ sub add_directive {
my ($lines_ptr, $directive) = @_;
- my $searchdirective = searchstr($directive);
- my $olddirective = $searchdirective;
- $olddirective =~ s/^\s*(\S+)\s+.*$/$1/s;
- $olddirective ||= $directive;
-
my $success = insert_directive($lines_ptr, $directive);
if ($success) {
move_directive_to_version_commented_out($lines_ptr, $directive,
diff --git a/perl-install/scanner.pm b/perl-install/scanner.pm
index 6a5dbdacb..3d7fda2b6 100755
--- a/perl-install/scanner.pm
+++ b/perl-install/scanner.pm
@@ -18,11 +18,11 @@ package scanner;
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# pbs/TODO:
-# - scsi mis-configuration
+# - scsi mis-configuration (should work better now)
# - devfs use dev_is_devfs()
-# - with 2 scanners same manufacturer -> will overwrite previous conf -> only 1 conf !!
+# - with 2 scanners same manufacturer -> will overwrite previous conf -> only 1 conf !! (should work now)
# - lp: see printerdrake
-# - install: prefix --> done
+# - install: prefix --> done (partially)
use standalone;
use common;
@@ -35,14 +35,31 @@ my $_scannerDBdir = "$::prefix$ENV{SHARE_PATH}/ldetect-lst";
$scannerDB = readScannerDB("$_scannerDBdir/ScannerDB");
sub confScanner {
- my ($model, $port) = @_;
+ my ($model, $port, $vendor, $product) = @_;
$port ||= detect_devices::dev_is_devfs() ? "$::prefix/dev/usb/scanner0" : "$::prefix/dev/scanner";
my $a = $scannerDB->{$model}{server};
#print "file:[$a]\t[$model]\t[$port]\n| ", (join "\n| ", @{$scannerDB->{$model}{lines}}),"\n";
my @driverconf = cat_("$_sanedir/$a.conf");
my @configlines = @{$scannerDB->{$model}{lines}};
- s/\$DEVICE/$port/ foreach @configlines;
- handle_configs::set_directive(\@driverconf, $_) foreach @configlines;
+ foreach my $line (@configlines) {
+ $line =~ s/\$DEVICE/$port/g if $port;
+ next if $line =~ /\$DEVICE/;
+ $line =~ s/\$VENDOR/$vendor/g if $vendor;
+ next if $line =~ /\$VENDOR/;
+ $line =~ s/\$PRODUCT/$product/g if $product;
+ next if $line =~ /\$PRODUCT/;
+ $line =~ /^(\S+)LINE\s+(.*?)$/;
+ my $linetype = $1;
+ $line = $2;
+ if ((!$linetype) or
+ (($linetype eq "USB") and (($port =~ /usb/i) or ($vendor))) or
+ (($linetype eq "PARPORT") and (!$vendor) and
+ ($port =~ /(parport|pt_drv|parallel)/i)) or
+ (($linetype eq "SCSI") and (!$vendor) and
+ ($port =~ m!(/sg|scsi|/scanner)!i))) {
+ handle_configs::set_directive(\@driverconf, $line, 1);
+ }
+ }
output("$_sanedir/$a.conf", @driverconf);
add2dll($a);
}
@@ -195,7 +212,10 @@ sub readScannerDB {
my ($lineno, $cmd, $val) = 0;
my $fs = {
- LINE => sub { push @{$card->{lines}}, $val },
+ LINE => sub { push @{$card->{lines}}, "LINE $val" },
+ SCSILINE => sub { push @{$card->{lines}}, "SCSILINE $val" },
+ USBLINE => sub { push @{$card->{lines}}, "USBLINE $val" },
+ PARPORTLINE => sub { push @{$card->{lines}}, "PARPORTLINE $val" },
NAME => sub {
#$cards{$card->{type}} = $card if ($card and !$card->{flags}{unsupported});
$cards{$card->{type}} = $card if $card;
@@ -241,7 +261,7 @@ sub updateScannerDBfromUsbtable {
print "#[$name] already in ScannerDB!\n";
next;
}
- $to_add .= "NAME $name\nDRIVER usb\nCOMMENT usb $vendor_id $product_id\nUNSUPPORTED\n\n";
+ $to_add .= "NAME $name\nDRIVER USB\nCOMMENT usb $vendor_id $product_id\nUNSUPPORTED\n\n";
}
$to_add .= "END\n";
@@ -261,7 +281,7 @@ sub updateScannerDBfromSane {
"Epson" => "Epson Corp.",
"Fujitsu Computer Products of America" => "Fujitsu",
"HP" => sub { $_[0] =~ s/HP\s/Hewlett-Packard|/; $_[0] =~ s/HP4200/Hewlett-Packard|ScanJet 4200C/; $_[0] },
- "Hewlett-Packard" => sub { $_[0] =~ s/HP 3200 C/Hewlett-Packard|ScanJet 3200C/; $_[0] },
+ "Hewlett-Packard" => sub { $_[0] =~ s/HP 3200 C/Hewlett-Packard|ScanJet 3200C/ or $_[0] = "Hewlett-Packard|$_[0]"; $_[0] },
"Kodak" => "Kodak Co.",
"Mustek" => "Mustek Systems Inc.",
"NEC" => "NEC Systems",
@@ -274,6 +294,18 @@ sub updateScannerDBfromSane {
"Vobis/Highscreen" => "Vobis",
};
+ # Read templates for configuration file lines
+ my %configlines;
+ my $backend;
+ foreach my $line (cat_("$_scannerDBdir/scannerconfigs")) {
+ chomp $line;
+ if ($line =~ /^\s*SERVER\s+(\S+)\s*$/) {
+ $backend = $1;
+ } elsif ($backend) {
+ push (@{$configlines{$backend}}, $line);
+ }
+ }
+
foreach my $f (glob_("$_sanesrcdir/*.desc")) {
my $F = common::openFileMaybeCompressed($f);
$to_add .= "\n# from $f";
@@ -283,13 +315,29 @@ sub updateScannerDBfromSane {
backend => sub { $backend = $val },
mfg => sub { $mfg = $val; $name = undef },#bug when a new mfg comes. should called $fs->{ $name }(); but ??
model => sub {
- unless ($name) { $name = $val; next }
+ unless ($name) { $name = $val; return }
$name = member($mfg, keys %$sane2DB) ?
(ref $sane2DB->{$mfg}) ? $sane2DB->{$mfg}($name) : "$sane2DB->{ $mfg }|$name" : "$mfg|$name";
- if (member($name, keys %$scanner::scannerDB)) {
+ if (0 && member($name, keys %$scanner::scannerDB)) {
print "#[$name] already in ScannerDB!\n";
} else {
+ # SANE bug "snapscan" calls itself "SnapScan"
+ $backend =~ s/SnapScan/snapscan/g;
$to_add .= "\nNAME $name\nSERVER $backend\nDRIVER $intf\n";
+ # Go through the configuration lines of
+ # this backend and add what is needed for the
+ # interfaces of this scanner
+ foreach my $line (@{$configlines{$backend}}) {
+ $line =~ /^\s*(\S*?)LINE/;
+ my $i = $1;
+ if (!$i or $intf =~ /$i/i) {
+ $to_add .= "$line\n";
+ }
+ }
+ if ($backend =~
+ /(unsupported|mustek_pp|gphoto2)/i) {
+ $to_add .= "UNSUPPORTED\n";
+ }
$to_add .= "COMMENT $comment\n" if $comment;
$comment = undef;
}
@@ -303,8 +351,12 @@ sub updateScannerDBfromSane {
s/\s+$//;
/^\;/ and next;
($cmd, $val) = /:(\S+)\s*\"([^\;]*)\"/ or next; #log::l("bad line $lineno ($_)"), next;
+ if ($f =~ /microtek/) {
+ #print "##### |$cmd|$val|\n";
+ }
my $f = $fs->{$cmd};
$f ? $f->() : log::l("unknown line $lineno ($_)");
+ #$f ? $f->() : print "##### unknown line $lineno ($_)\n";
}
$fs->{model}(); # the last one
}
diff --git a/perl-install/standalone/scannerdrake b/perl-install/standalone/scannerdrake
index f625f4568..a7358e5ad 100755
--- a/perl-install/standalone/scannerdrake
+++ b/perl-install/standalone/scannerdrake
@@ -220,7 +220,8 @@ sub dynamic {
$in->ask_warn('Scannerdrake', N("The %s is not supported by this version of Mandrake Linux.", removeverticalbar($name)));
next;
}
- scanner::confScanner($name, $_->{port});
+ scanner::confScanner($name, $_->{port},
+ $_->{val}{vendor}, $_->{val}{id});
} else {
$in->ask_warn('Scannerdrake', N("The %s is not known by this version of Scannerdrake.", removeverticalbar($name)));
}
@@ -238,7 +239,7 @@ sub tryConfScanner {
if (($scanner::scannerDB->{$model}{ask} =~ /DEVICE/) || (!$port)){
$port = '/dev/usb/scanner0';
$in->ask_from('Scannerdrake',
- N("Scannerdrake was not able to detect your %s.\nPlease select the device where your scanner is attached", removeverticalbar($model)),
+ N("Please select the device where your %s is attached", removeverticalbar($model)),
[
{ label => N("choose device"),
val => \$port,
@@ -264,8 +265,11 @@ sub tryConfScanner {
'/dev/parport0',
'/dev/parport1',
'/dev/parport2',
- '/dev/pt_drv'],
- not_edit => 0, sort => 1 },
+ '/dev/pt_drv',
+ '/dev/ttyS0',
+ '/dev/ttyS1',
+ '/dev/ttyS2'],
+ not_edit => 0, sort => 0 },
],
) or return 0;
}