summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rwxr-xr-xperl-install/scanner.pm13
-rwxr-xr-xperl-install/standalone/scannerdrake73
2 files changed, 80 insertions, 6 deletions
diff --git a/perl-install/scanner.pm b/perl-install/scanner.pm
index 34ecb01b9..85341e10c 100755
--- a/perl-install/scanner.pm
+++ b/perl-install/scanner.pm
@@ -34,7 +34,7 @@ my $scannerDBdir = "$::prefix$ENV{SHARE_PATH}/ldetect-lst";
our $scannerDB = readScannerDB("$scannerDBdir/ScannerDB");
sub confScanner {
- my ($model, $port, $vendor, $product) = @_;
+ my ($model, $port, $vendor, $product, $firmware) = @_;
$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";
@@ -47,11 +47,13 @@ sub confScanner {
next if $line =~ /\$VENDOR/;
$line =~ s/\$PRODUCT/$product/g if $product;
next if $line =~ /\$PRODUCT/;
+ $line =~ s/\$FIRMWARE/$firmware/g if $firmware;
+ next if $line =~ /\$FIRMWARE/;
my $linetype;
if ($line =~ /^(\S*)LINE\s+(.*?)$/) {
- $linetype = $1;
- $line = $2;
- }
+ $linetype = $1;
+ $line = $2;
+ }
next if !$line;
if (!$linetype ||
($linetype eq "USB" && ($port =~ /usb/i || $vendor)) ||
@@ -60,6 +62,8 @@ sub confScanner {
($linetype eq "SCSI" && !$vendor &&
$port =~ m!(/sg|scsi|/scanner)!i)) {
handle_configs::set_directive(\@driverconf, $line, 1);
+ } elsif ($linetype eq "FIRMWARE" && $firmware) {
+ handle_configs::set_directive(\@driverconf, $line, 0);
}
}
output("$sanedir/$a.conf", @driverconf);
@@ -370,6 +374,7 @@ sub readScannerDB {
SCSILINE => sub { push @{$card->{lines}}, "SCSILINE $val" },
USBLINE => sub { push @{$card->{lines}}, "USBLINE $val" },
PARPORTLINE => sub { push @{$card->{lines}}, "PARPORTLINE $val" },
+ FIRMWARELINE => sub { push @{$card->{lines}}, "FIRMWARELINE $val" },
NAME => sub {
#$cards{$card->{type}} = $card if ($card and !$card->{flags}{unsupported});
$cards{$card->{type}} = $card if $card;
diff --git a/perl-install/standalone/scannerdrake b/perl-install/standalone/scannerdrake
index 3cdf44302..1e1b3b086 100755
--- a/perl-install/standalone/scannerdrake
+++ b/perl-install/standalone/scannerdrake
@@ -144,13 +144,77 @@ sub dynamic() {
next;
}
scanner::confScanner($name, $_->{port},
- $_->{val}{vendor}, $_->{val}{id});
+ $_->{val}{vendor}, $_->{val}{id}, "");
} else {
$in->ask_warn('Scannerdrake', N("The %s is not known by this version of Scannerdrake.", removeverticalbar($name)));
}
}
}
+sub installfirmware {
+ my ($model) = @_;
+ my $firmware;
+ my $choice = N("Do not install firmware file");
+ while (1) {
+ # Tell user about firmware installation
+ $in->ask_from('Scannerdrake',
+ N("It is possible that your %s needs its Firmware to be uploaded everytime when it is turned on.", removeverticalbar($model)) . " " .
+ N("If this is the case, you can make this be done automatically for you.") . " " .
+ N("To do so, you need to supply the firmware file for your scanner so that it can be installed.") . " " .
+ N("You find the file on the CD or floppy coming with the scanner, on the manufacturer's home page, or on your Windows partition."),
+ [
+ { label => N("Install firmware file from"),
+ val => \$choice,
+ list => [N("CD-ROM"),
+ N("Floppy Disk"),
+ N("Other place"),
+ N("Do not install firmware file")],
+ not_edit => 1, sort => 0 },
+ ],
+ ) or return "///";
+ my $dir;
+ if ($choice eq N("CD-ROM")) {
+ $dir = "/mnt/cdrom";
+ } elsif ($choice eq N("Floppy Disk")) {
+ $dir = "/mnt/floppy";
+ } elsif ($choice eq N("Other place")) {
+ $dir = "/mnt";
+ } else {
+ return "";
+ }
+ # Let user select a firmware file from a floppy, hard disk, ...
+ $firmware = $in->ask_file(N("Select firmware file"), "$dir");
+ last if !$firmware || (-r $firmware);
+ $in->ask_warn('Scannerdrake',
+ N("The firmware file %s does not exist or is unreadable!",
+ $firmware));
+
+ }
+ if ($firmware) {
+ # Install firmware
+ run_program::rooted($::prefix, "mkdir", "-p",
+ "/usr/share/sane/firmware") || do {
+ $in->ask_warn('Scannerdrake',
+ N("Could not create directory /usr/share/sane/firmware!"));
+ return "";
+ };
+ run_program::rooted($::prefix, "cp", "-f", "$firmware",
+ "/usr/share/sane/firmware") || do {
+ $in->ask_warn('Scannerdrake',
+ N("Could not copy firmware file %s to /usr/share/sane/firmware!", $firmware));
+ return "";
+ };
+ $firmware =~ s!^(.*)(/[^/]+)$!/usr/share/sane/firmware$2!;
+ run_program::rooted($::prefix, "chmod", "644",
+ $firmware) || do {
+ $in->ask_warn('Scannerdrake',
+ N("Could not set permissions of firmware file %s!", $firmware));
+ return "";
+ };
+ }
+ return $firmware;
+}
+
sub tryConfScanner {
# take care if interactive output is needed (unsupported, parallel..)
my ($model, $port, $vendor, $product) = @_;
@@ -230,7 +294,12 @@ sub tryConfScanner {
}
}
($vendor, $product) = scanner::get_usb_ids_for_port($port);
- scanner::confScanner($model, $port, $vendor, $product);
+ my $firmware;
+ if (grep { /FIRMWARELINE/ } @{$scanner::scannerDB->{$model}{lines}} ) {
+ $firmware = installfirmware($model);
+ return 0 if $firmware eq "///";
+ }
+ scanner::confScanner($model, $port, $vendor, $product, $firmware);
$in->ask_warn(N("Congratulations!"),
N("Your %s has been configured.\nYou may now scan documents using \"XSane\" from Multimedia/Graphics in the applications menu.", removeverticalbar($model)));
return 1;