summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/printer/main.pm69
-rw-r--r--perl-install/printer/printerdrake.pm60
2 files changed, 100 insertions, 29 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index 808c8f6e5..ea9bbcb0e 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -29,7 +29,7 @@ our %printer_type = (
N("Printer on remote CUPS server") => "CUPS",
N("Printer on remote lpd server") => "LPD",
N("Network printer (TCP/Socket)") => "SOCKET",
- N("Printer on SMB/Windows 95/98/NT server") => "SMB",
+ N("Printer on SMB/Windows server") => "SMB",
N("Printer on NetWare server") => "NCP",
N("Enter a printer device URI") => "URI",
N("Pipe job into a command") => "POSTPIPE"
@@ -2472,6 +2472,8 @@ sub hplip_simple_model {
my ($model) = @_;
my $simplemodel = $model;
$simplemodel =~ s/[^A-Za-z0-9]//g;
+ $simplemodel =~ s/HewlettPackard/HP/gi;
+ $simplemodel =~ s/HP//gi;
$simplemodel =~ s/(DeskJet\d+C?)([a-z]*?)/$1/gi;
$simplemodel =~ s/((LaserJet|OfficeJet|PhotoSmart|PSC)\d+)([a-z]*?)/$1/gi;
$simplemodel =~ s/DeskJet/DJ/gi;
@@ -2486,8 +2488,8 @@ sub hplip_simple_model {
sub hplip_device_entry {
my ($device, @autodetected) = @_;
- # Currently, only devices on USB work
- return undef if $device !~ /usb/i;
+ # Currently, only devices on USB or TCP/Socket work
+ return undef if ($device !~ /usb/i) && ($device !~ m!^socket://!i);
if (!$hplipdevicesdb) {
# Read the HPLIP device database if not done already
@@ -2505,6 +2507,11 @@ sub hplip_device_entry {
# Exact match
return $entry;
}
+ my $hpmodelstr = "HP_" . $modelstr;
+ if ($entry = $hplipdevicesdb->{$hpmodelstr}) {
+ # Exact match
+ return $entry;
+ }
# More 'fuzzy' matching
my $simplemodel = hplip_simple_model($modelstr);
foreach my $key (keys %{$hplipdevicesdb}) {
@@ -2517,7 +2524,7 @@ sub hplip_device_entry {
$simplekey =~ s/(\d\d\d)0(C?)$/$1\\d$2/;
$simplekey =~ s/(\d\d)0(\dC?)$/$1\\d$2/;
return $hplipdevicesdb->{$key} if
- $simplemodel =~ m/^$simplekey$/;
+ $simplemodel =~ m/^$simplekey$/i;
}
# Device not supported
return undef;
@@ -2558,6 +2565,8 @@ sub start_hplip {
$device =~ m!/dev/lp! ||
$device =~ /printers/) {
$bus = "par";
+ } elsif ($device =~ m!^socket://!) {
+ $bus = "net";
} else {
return undef;
}
@@ -2566,26 +2575,50 @@ sub start_hplip {
printer::services::start_not_running_service("hplip");
# Determine HPLIP device URI for the CUPS queue
- foreach my $a (@autodetected) {
- $device eq $a->{port} or next;
+ if ($bus eq "net") {
+ $device =~ m!^socket://([^:]+)(|:\d+)$!;
+ my $host = $1;
+ my $ip;
+ if ($host !~ m!^\d+\.\d+\.\d+\.\d+$!) {
+ my $addr = gethostbyname("$host");
+ my ($a,$b,$c,$d) = unpack('C4',$addr);
+ $ip = sprintf("%d.%d.%d.%d", $a, $b, $c, $d);
+ } else {
+ $ip = $host;
+ }
open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- '/bin/sh -c "export LC_ALL=C; /usr/lib/cups/backend/hp" |') or
- die 'Could not run "/usr/lib/cups/backend/hp"!';
+ "/bin/sh -c \"export LC_ALL=C; /usr/bin/hp-makeuri $ip\" |") or
+ die "Could not run \"/usr/bin/hp-makeuri $ip\"!";
while (my $line = <$F>) {
- if (($line =~ m!^direct\s+(hp:/$bus/(\S+)\?serial=(\S+))\s+!) ||
- ($line =~ m!^direct\s+(hp:/$bus/(\S+))\s+!)) {
+ if ($line =~ m!(hp:/net/\S+)!) {
my $uri = $1;
- my $modelstr = $2;
- my $serial = $3;
- if ((uc($modelstr) eq uc($hplipentry->{model})) &&
- (!$serial ||
- (uc($serial) eq uc($a->{val}{SERIALNUMBER})))) {
- close $F;
- return $uri;
- }
+ close $F;
+ return $uri;
}
}
close $F;
+ } else {
+ foreach my $a (@autodetected) {
+ $device eq $a->{port} or next;
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
+ '/bin/sh -c "export LC_ALL=C; /usr/lib/cups/backend/hp" |') or
+ die 'Could not run "/usr/lib/cups/backend/hp"!';
+ while (my $line = <$F>) {
+ if (($line =~ m!^direct\s+(hp:/$bus/(\S+)\?serial=(\S+))\s+!) ||
+ ($line =~ m!^direct\s+(hp:/$bus/(\S+))\s+!)) {
+ my $uri = $1;
+ my $modelstr = $2;
+ my $serial = $3;
+ if ((uc($modelstr) eq uc($hplipentry->{model})) &&
+ (!$serial ||
+ (uc($serial) eq uc($a->{val}{SERIALNUMBER})))) {
+ close $F;
+ return $uri;
+ }
+ }
+ }
+ close $F;
+ }
last;
}
# HPLIP URI not found
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index 32ef8f2d5..e16ec3f92 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -2027,9 +2027,14 @@ sub setup_socket {
my ($uri, $remotehost, $remoteport);
my $queue = $printer->{OLD_QUEUE};
if ($printer->{configured}{$queue} &&
- $printer->{currentqueue}{connect} =~ m!^(socket:|ptal://?hpjd:)!) {
+ $printer->{currentqueue}{connect} =~
+ m!^(socket:|ptal://?hpjd:|hp:/net/)!) {
$uri = $printer->{currentqueue}{connect};
- if ($uri =~ m!^ptal:!) {
+ if ($uri =~ m!^hp:!) {
+ if ($uri =~ m!^hp:/net/[^\?]+\?ip=(\d+\.\d+\.\d+\.\d+)!) {
+ ($remotehost, $remoteport) = ($1, 9100);
+ }
+ } elsif ($uri =~ m!^ptal:!) {
if ($uri =~ m!^ptal://?hpjd:([^/:]+):([0-9]+)/?\s*$!) {
my $ptalport = $2 - 9100;
($remotehost, $remoteport) = ($1, $ptalport);
@@ -2061,9 +2066,9 @@ sub setup_socket {
foreach my $p (@autodetected) {
my $menustr;
if ($p->{port} =~ m!^socket://([^:]+):(\d+)$!) {
- $host = $1;
- $port = $2;
- }
+ $host = $1;
+ $port = $2;
+ }
if ($p->{val}{DESCRIPTION}) {
$menustr = $p->{val}{DESCRIPTION};
$menustr .= N(", host \"%s\", port %s",
@@ -2082,7 +2087,7 @@ sub setup_socket {
$menuentries->{$a} cmp $menuentries->{$b};
} keys(%$menuentries);
if ($printer->{configured}{$queue} &&
- $printer->{currentqueue}{connect} =~ m!^(socket:|ptal://?hpjd:)! &&
+ $printer->{currentqueue}{connect} =~ m!^(socket:|ptal://?hpjd:|hp:/net/)! &&
$menuchoice eq "") {
my $menustr;
if ($printer->{currentqueue}{make}) {
@@ -2387,7 +2392,8 @@ sub setup_common {
$makemodel =~ /^\s*$/) {
local $::isWizard = 0;
if (!$printer->{noninteractive}) {
- if ($device =~ m!/usb/! &&
+ if (($device =~ m!/usb/! ||
+ $device =~ m!^socket://!) &&
$printer->{SPOOLER} eq 'cups') {
my $choice = $in->ask_from_list
(N("Add a new printer"),
@@ -2461,13 +2467,15 @@ sub setup_common {
if !$printer->{noninteractive};
if (!$hplipinstallfailed) {
- if ($isHPLIP) {
+ if ($isHPLIP && ($device !~ m!^socket://!)) {
my @uris = printer::main::start_hplip_manual();
my (@menu, %menuhash);
foreach my $item (@uris) {
if ($item =~ m!^hp:/(usb|par|net)/(\S*?)(\?\S*|)$!) {
- my $modelname = "HP " . $2;
+ my $modelname = $2;
$modelname =~ s/_/ /g;
+ $modelname = "HP " . $modelname
+ if $modelname !~ m!^HP\s!i;
push(@menu, $modelname);
$menuhash{$modelname} = $item;
}
@@ -2486,6 +2494,17 @@ sub setup_common {
} else {
$hplipdevice = printer::main::start_hplip
($device, $hplipentry, @autodetected);
+ if (!$hplipentry) {
+ $hplipentry =
+ printer::main::hplip_device_entry_from_uri
+ ($hplipdevice);
+ }
+ if ($makemodel !~ /\S/) {
+ $makemodel = $hplipentry->{model};
+ $makemodel =~ s/_/ /g;
+ $makemodel = "HP " . $makemodel
+ if $makemodel !~ m!^HP\s!i;
+ }
}
}
@@ -2758,6 +2777,16 @@ sub setup_common {
#- Search the database entry which matches the detected printer best
my $descr = "";
+ if ((!$do_auto_detect) &&
+ ($makemodel =~ m!^(\S+)\s+(.*?)$!)) {
+ my $mk = $1;
+ my $md = $2;
+ @autodetected = ({ port => $device,
+ val => { CLASS => 'PRINTER',
+ MANUFACTURER => $mk,
+ MODEL => $md,
+ DESCRIPTION => $makemodel } });
+ }
foreach (@autodetected) {
$device eq $_->{port} or next;
my ($automake, $automodel, $autodescr, $autocmdset, $autosku) =
@@ -2778,6 +2807,12 @@ sub setup_common {
$descr =~ s/ /|/;
} elsif ($automake) {
$descr = "$descrmake|";
+ } elsif ($makemodel =~ /\S/) {
+ $descr = $makemodel;
+ $descr =~ s/ /|/;
+ } else {
+ $printer->{DBENTRY} = "";
+ last;
}
# Remove manufacturer's name from the beginning of the
# description (do not do this with manufacturer names which
@@ -5430,8 +5465,11 @@ What do you want to modify on this printer?",
#- Which printer type did we have before (check
#- beginning of URI)
if ($printer->{configured}{$queue}) {
- if ($printer->{currentqueue}{connect} =~ m!^ptal://?hpjd!) {
- $printer->{TYPE} = "socket";
+ if (($printer->{currentqueue}{connect} =~
+ m!^ptal://?hpjd!) ||
+ ($printer->{currentqueue}{connect} =~
+ m!^hp:/net!)) {
+ $printer->{TYPE} = "SOCKET";
} else {
foreach my $type (qw(file parallel serial usb ptal hp
mtink lpd socket smb ncp