[Pkg-cups-devel] r631 - in cupsys/trunk: . debian debian/local/backends debian/local/filters
Martin Pitt
mpitt at alioth.debian.org
Fri Nov 30 17:33:34 UTC 2007
Author: mpitt
Date: Fri Nov 30 17:33:34 2007
New Revision: 631
Log:
* Add debian/local/backends/dnssd: Printer discovery backend for
several cheaper printers, like the HP Color LaserJet 2600n, are not
discovered by the "snmp" backend. In addition, this backend extracts more
info from the printers than the "snmp" backend, like for example available
page description languages. This leads to better driver choices for
unknown printer models.
* debian/cupsys.install, debian/cupsys.{prerm,postinst,templates,rules}:
Install new backend.
* debian/control: Add Recommends: to avahi-utils; if it is installed, the
dnssd backend can actually work.
Added:
cupsys/trunk/debian/local/backends/
cupsys/trunk/debian/local/backends/dnssd (contents, props changed)
Modified:
cupsys/trunk/ (props changed)
cupsys/trunk/debian/changelog
cupsys/trunk/debian/control
cupsys/trunk/debian/cupsys.install
cupsys/trunk/debian/cupsys.postinst
cupsys/trunk/debian/cupsys.prerm
cupsys/trunk/debian/cupsys.templates
cupsys/trunk/debian/local/filters/oopstops (contents, props changed)
cupsys/trunk/debian/local/filters/pdftops (contents, props changed)
cupsys/trunk/debian/local/filters/textonly (contents, props changed)
cupsys/trunk/debian/rules
Modified: cupsys/trunk/debian/changelog
==============================================================================
--- cupsys/trunk/debian/changelog (original)
+++ cupsys/trunk/debian/changelog Fri Nov 30 17:33:34 2007
@@ -13,6 +13,18 @@
* debian/control: Demote cups-pdf from Recommends: to Suggests: to match the
semantics (apt installs recommends by default now).
+ [ Till Kamppeter ]
+ * Add debian/local/backends/dnssd: Printer discovery backend for
+ several cheaper printers, like the HP Color LaserJet 2600n, are not
+ discovered by the "snmp" backend. In addition, this backend extracts more
+ info from the printers than the "snmp" backend, like for example available
+ page description languages. This leads to better driver choices for
+ unknown printer models.
+ * debian/cupsys.install, debian/cupsys.{prerm,postinst,templates,rules}:
+ Install new backend.
+ * debian/control: Add Recommends: to avahi-utils; if it is installed, the
+ dnssd backend can actually work.
+
-- Kenshi Muto <kmuto at debian.org> Fri, 30 Nov 2007 17:30:39 +0100
cupsys (1.3.4-1) unstable; urgency=high
Modified: cupsys/trunk/debian/control
==============================================================================
--- cupsys/trunk/debian/control (original)
+++ cupsys/trunk/debian/control Fri Nov 30 17:33:34 2007
@@ -53,7 +53,7 @@
Depends: ${shlibs:Depends}, debconf (>= 1.2.9) | debconf-2.0, poppler-utils | xpdf-utils, perl-modules, procps, ghostscript, lsb-base (>= 3), cupsys-common, ssl-cert (>= 1.0.11), adduser
Replaces: cupsys-pstoraster
Conflicts: cupsys-pstoraster (<< 2)
-Recommends: cupsys-client, smbclient (>= 3.0.9), foomatic-filters
+Recommends: cupsys-client, smbclient (>= 3.0.9), foomatic-filters, avahi-utils
Suggests: cupsys-bsd, cupsys-driver-gutenprint, foomatic-filters-ppds, hplip, xpdf-korean | xpdf-japanese | xpdf-chinese-traditional | xpdf-chinese-simplified, cups-pdf
Description: Common UNIX Printing System(tm) - server
The Common UNIX Printing System (or CUPS(tm)) is a printing system and
Modified: cupsys/trunk/debian/cupsys.install
==============================================================================
--- cupsys/trunk/debian/cupsys.install (original)
+++ cupsys/trunk/debian/cupsys.install Fri Nov 30 17:33:34 2007
@@ -34,6 +34,7 @@
usr/share/man/man8/cups-driverd.8.gz
usr/share/man/man8/cupsfilter.8.gz
../presubj usr/share/bug/cupsys/
+../local/backends/* usr/lib/cups/backend-available/
../local/filters/* usr/lib/cups/filter/
../local/*.ppd usr/share/ppd/cups-included/
../local/*.types usr/share/cups/mime/
Modified: cupsys/trunk/debian/cupsys.postinst
==============================================================================
--- cupsys/trunk/debian/cupsys.postinst (original)
+++ cupsys/trunk/debian/cupsys.postinst Fri Nov 30 17:33:34 2007
@@ -94,7 +94,7 @@
list=`echo $SELECTED | sed -e 's/, /,/g'`
save_IFS=$IFS
IFS=,
- (cd /usr/lib/cups/backend && rm -f http ipp lpd parallel scsi serial socket usb snmp)
+ (cd /usr/lib/cups/backend && rm -f http ipp lpd parallel scsi serial socket usb snmp dnssd)
for module in $list; do
ln /usr/lib/cups/backend-available/$module /usr/lib/cups/backend/$module
if [ "$module" = "ipp" ]; then
Modified: cupsys/trunk/debian/cupsys.prerm
==============================================================================
--- cupsys/trunk/debian/cupsys.prerm (original)
+++ cupsys/trunk/debian/cupsys.prerm Fri Nov 30 17:33:34 2007
@@ -19,7 +19,7 @@
case "$1" in
remove)
- (cd /usr/lib/cups/backend && rm -f http ipp lpd parallel scsi serial socket usb snmp)
+ (cd /usr/lib/cups/backend && rm -f http ipp lpd parallel scsi serial socket usb snmp dnssd)
if [ -L /usr/lib/cups/backend/smb ]; then
rm -f /usr/lib/cups/backend/smb 2>/dev/null || true
fi
Modified: cupsys/trunk/debian/cupsys.templates
==============================================================================
--- cupsys/trunk/debian/cupsys.templates (original)
+++ cupsys/trunk/debian/cupsys.templates Fri Nov 30 17:33:34 2007
@@ -19,8 +19,8 @@
Template: cupsys/backend
Type: multiselect
-__Choices: ipp, lpd, parallel, scsi, serial, socket, usb, snmp
-Default: ipp, lpd, parallel, scsi, serial, socket, usb, snmp
+__Choices: ipp, lpd, parallel, scsi, serial, socket, usb, snmp, dnssd
+Default: ipp, lpd, parallel, scsi, serial, socket, usb, snmp, dnssd
_Description: Printer communication backends:
CUPS uses backend programs to communicate with the printer device or port.
.
Added: cupsys/trunk/debian/local/backends/dnssd
==============================================================================
--- (empty file)
+++ cupsys/trunk/debian/local/backends/dnssd Fri Nov 30 17:33:34 2007
@@ -0,0 +1,207 @@
+#!/usr/bin/perl
+# The above Perl path may vary on your system; fix it!!! -*- perl -*-
+
+# dnssd - Search for network printers with the avahi-browse command
+# (Zeroconf, DNS-SD)
+
+# Printer discovery CUPS backend (like the SNMP backend)
+# See also http://qa.mandriva.com/show_bug.cgi?id=21812
+
+# Copyright 2007 Till Kamppeter <till.kamppeter at gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+# USA.
+
+# Usage:
+#
+# cp dnssd /usr/lib/cups/backend/
+# chmod 755 /usr/lib/cups/backend/dnssd
+# killall -HUP cupsd (or "/etc/init.d/cups restart", CUPS 1.1.x only)
+# lpinfo -v (or use any printer setup tool)
+
+#use strict;
+
+$0 =~ m!^(.*)/([^/]+)\s*$!;
+my $progname = ($2 || $0 || "dnssd");
+my $progpath = ($1 || "/usr/lib/cups/backend");
+
+if ($ARGV[0]){
+ die "This backend is only for printer discovery, not for actual printing.\n";
+}
+
+my $avahicmd = "avahi-browse -k -t -v -r -a 2> /dev/null";
+
+# IPs which are for computers, consider their printer entries as queues
+# set up with the local printing system (CUPS, LPD, Windows/Samba SMB, ...)
+my @ipblacklist = ();
+my $output;
+my ($interface, $nettype, $ip, $host, $make, $model, $description, $cmd, $makemodel, $deviceid, $protocol, $port, $uriext, $uri);
+
+open (AVAHI, "$avahicmd |") or exit 0;
+while (my $line = <AVAHI>) {
+ chomp ($line);
+ if ($line =~ /^\s*=\s+(\S+)\s+(\S+)\s+(.*?)\s+(\S+)\s+(\S+)\s*$/) {
+ # New item
+ $interface = $1;
+ $nettype = $2;
+ my $itemname = $3;
+ my $protocolinfo = $4;
+ if ($protocolinfo =~ /_workstation/) {
+ $protocol = "computer";
+ } elsif ($protocolinfo =~ /_pdl-datastream/) {
+ $protocol = "socket";
+ } elsif ($protocolinfo =~ /_printer/) {
+ $protocol = "lpd";
+ #} elsif ($protocolinfo =~ /_ipp/) {
+ # $protocol = "ipp";
+ }
+ } elsif ($line =~ /^\s*hostname\s*=\s*\[([^\]]+)\]\s*$/) {
+ $host = $1;
+ $host =~ s/\.local\.?$//;
+ } elsif ($line =~ /^\s*address\s*=\s*\[([^\]]+)\]\s*$/) {
+ $ip = $1;
+ if ($protocol eq "computer") {
+ push (@ipblacklist, $ip);
+ $protocol = "";
+ }
+ } elsif ($line =~ /^\s*port\s*=\s*\[([^\]]+)\]\s*$/) {
+ $port = $1;
+ } elsif ($line =~ /^\s*txt\s*=\s*\[(.+)\]\s*$/) {
+ my $info = $1;
+ if ($protocol) {
+ my ($ty, $product, $pdls, $usb_MFG, $usb_MDL, $usb_DES, $usb_CMD) =
+ ("", "", "", "", "", "", "");
+ while ($info =~ s/^\s*\"([^\"]+)\"\s*//) {
+ my $infoitem = $1;
+ if ($infoitem =~ /^([^=]*)=(.*)$/) {
+ my $field = $1;
+ my $content = $2;
+ if ($field eq "ty") {
+ $ty = $content;
+ } elsif ($field eq "product") {
+ $product = $content;
+ $product =~ s/^\((.*)\)$/$1/;
+ } elsif ($field eq "usb_MFG") {
+ $usb_MFG = $content;
+ } elsif ($field eq "usb_MDL") {
+ $usb_MDL = $content;
+ } elsif ($field eq "usb_DES") {
+ $usb_DES = $content;
+ } elsif ($field eq "usb_CMD") {
+ $usb_CMD = $content;
+ } elsif ($field eq "rp") {
+ $uriext = $content;
+ } elsif ($field eq "pdl") {
+ while ($content =~ s/^\s*([^\,]+?)\s*\,\s*//) {
+ my $i = $1;
+ if ($i =~ m!\b(postscript|ps)\b!i) {
+ $pdls .= "POSTSCRIPT,";
+ } elsif ($i =~ m!\b(pdf)\b!i) {
+ $pdls .= "PDF,";
+ } elsif ($i =~ m!\b(pcl6|pclxl|pxl)\b!i) {
+ $pdls .= "PCLXL,";
+ } elsif ($i =~ m!\b(pcl[345][ce]?|pcl)\b!i) {
+ $pdls .= "PCL,";
+ }
+ }
+ $pdls =~ s/\,$//;
+ }
+ }
+ }
+ $usb_MDL ||= $ty;
+ $usb_DES ||= $product;
+ if ($usb_MFG) {
+ $make = $usb_MFG;
+ } elsif ($usb_DES =~ /^KONICA\s+MINOLTA\b/i) {
+ $make = "KONICA MINOLTA";
+ } elsif ($usb_DES) {
+ $usb_DES =~ /^\s*(\S*)\b/;
+ $make = $1;
+ }
+ $model = $usb_MDL;
+ if (!$model) {
+ $usb_DES =~ /^\s*\S*\s*(.*)$/;
+ $model = $1;
+ }
+ $usb_CMD ||= $pdls;
+ my $extra;
+ if ($protocol eq "socket") {
+ $uri = "socket://$ip:$port";
+ $extra = "Port $port";
+ } elsif ($protocol eq "lpd") {
+ $uri = "lpd://$ip" . ($uriext ? "/$uriext" : "");
+ $extra = ($uriext ? "Queue: $uriext" : "Default queue");
+ } elsif ($protocol eq "ipp") {
+ $uri = "ipp://$ip:$port" . ($uriext ? "/$uriext" : "");
+ $extra = ($uriext ? "Queue: $uriext" : "Default queue");
+ }
+ if ($make && $model) {
+ $make =~ s/Hewlett.?Packard/HP/i;
+ $make =~ s/Lexmark.?International/Lexmark/i;
+ $model =~ s/Hewlett.?Packard/HP/i;
+ $model =~ s/Lexmark.?International/Lexmark/i;
+ while ($model =~ s/^\s*$make\s*//i) {};
+ $makemodel = "$make $model";
+ } elsif ($usb_DES) {
+ $makemodel = $usb_DES;
+ } else {
+ $makemodel = "Unknown";
+ }
+ $deviceid = ($usb_MFG ? "MFG:$usb_MFG;" : "") .
+ ($usb_MDL ? "MDL:$usb_MDL;" : "") .
+ ($usb_DES ? "DES:$usb_DES;" : "") .
+ ($usb_CMD ? "CMD:$usb_CMD;" : "");
+ $deviceid .= "CLS:PRINTER;" if $deviceid;
+ $output->{$ip}{$protocol}{$extra} =
+ "network $uri \"$makemodel\" \"$makemodel $ip ($extra)\" \"$deviceid\"\n";
+ ($interface, $nettype, $ip, $host, $make, $model, $description, $cmd, $makemodel, $deviceid, $protocol, $port, $uriext, $uri) =
+ ("", "", "", "", "", "", "", "", "", "", "", "", "", "");
+ }
+ }
+}
+
+foreach my $ip (keys(%{$output})) {
+ next if member($ip, @ipblacklist);
+ if ($output->{$ip}{"socket"}) {
+ foreach my $extra (keys(%{$output->{$ip}{"socket"}})) {
+ if (keys(%{$output->{$ip}{"socket"}}) = 1) {
+ $output->{$ip}{"socket"}{$extra} =~
+ s/^(\s*\S*\s*\S*\s*\"[^\"]*\"\s*\"[^\"\(]*?)\s*\([^\)]*\)\s*(\"\s*.*)$/$1$2/;
+ }
+ print $output->{$ip}{"socket"}{$extra};
+ }
+ } elsif ($output->{$ip}{"lpd"}) {
+ foreach my $extra (keys(%{$output->{$ip}{"lpd"}})) {
+ if (keys(%{$output->{$ip}{"lpd"}}) = 1) {
+ $output->{$ip}{"lpd"}{$extra} =~
+ s/^(\s*\S*\s*\S*\s*\"[^\"]*\"\s*\"[^\"\(]*?)\s*\([^\)]*\)\s*(\"\s*.*)$/$1$2/;
+ }
+ print $output->{$ip}{"lpd"}{$extra};
+ }
+ } elsif ($output->{$ip}{"ipp"}) {
+ foreach my $extra (keys(%{$output->{$ip}{"ipp"}})) {
+ if (keys(%{$output->{$ip}{"ipp"}}) == 1) {
+ $output->{$ip}{"ipp"}{$extra} =~
+ s/^(\s*\S*\s*\S*\s*\"[^\"]*\"\s*\"[^\"]*?)\s*\([^\)]*\)\s*(\"\s*.*)$/$1$2/;
+ }
+ print $output->{$ip}{"ipp"}{$extra};
+ }
+ }
+}
+
+exit 0;
+
+# member( $a, @b ) returns 1 if $a is in @b, 0 otherwise.
+sub member { my $e = shift; foreach (@_) { $e eq $_ and return 1 } 0 };
Modified: cupsys/trunk/debian/local/filters/oopstops
==============================================================================
Modified: cupsys/trunk/debian/local/filters/pdftops
==============================================================================
Modified: cupsys/trunk/debian/local/filters/textonly
==============================================================================
Modified: cupsys/trunk/debian/rules
==============================================================================
--- cupsys/trunk/debian/rules (original)
+++ cupsys/trunk/debian/rules Fri Nov 30 17:33:34 2007
@@ -27,6 +27,11 @@
DEB_DH_INSTALL_SOURCEDIR := debian/tmp
LDFLAGS := -Wl,--as-needed
+common-post-build-arch::
+ # Fix permissions of filters/backends installed from debian/local/
+ chmod 755 debian/local/filters/*
+ chmod 755 debian/local/backends/*
+
clean::
rm -f man/client.conf.man packaging/cups.list
rm -f conf/mime.convs conf/snmp.conf init/org.cups.cups-lpd.plist
@@ -54,9 +59,6 @@
# the system-config-printer applet
install -D -m 644 packaging/cups-dbus.conf $(DEB_DESTDIR)/../cupsys/etc/dbus-1/system.d/cups.conf
- # Fix permissions of filters installed from debian/local/
- chmod 755 debian/cupsys/usr/lib/cups/filter/*
-
binary-post-install/libcupsimage2-dev::
rm -r debian/libcupsimage2-dev/usr/share/doc/libcupsimage2-dev
ln -s libcupsimage2 debian/libcupsimage2-dev/usr/share/doc/libcupsimage2-dev
More information about the Pkg-cups-devel
mailing list