Bug#637978: cups: Please add a dpkg trigger to update PPDs on driver upgrades

2011-08-16 Thread Didier Raboud
Package: cups
Version: 1.4.8-2
Severity: wishlist

Hi dear CUPS maintainers,

I would like cups to implement a dpkg trigger to update it's queues' PPDs on
driver upgrades.

This task is currently implemented (and duplicated) in each printer driver, as
a postinst. See e.g. c2esp, m2300w, foo2zjs, epson-inkjet-printer-escpr, etc.

My initial take to solve this functionality duplication was the creation of a
tiny cupsppupdate script and package (+ dh_* to include it nicely in the
package building processes), that would be launched by each package's
postinst. You can see this on the pkg-printing-tools initial repository:

http://anonscm.debian.org/gitweb/?p=collab-maint/pkg-printing-tools.git

But now I think this is not the right way to do it. As all drivers are
supposed to be installable even in the absence of CUPS (aka Recommends), the
script (and previously the postinst) checks for the presence and running status
of CUPS, and then goes updating files under /etc/cups/.

This should IMHO be implemented on CUPS's side, as a dpkg trigger: this way,
each time a driver would install or upgrade a file under
/usr/lib/cups/{driver,filter}, CUPS's dpkg-trigger would schedule an update
of its concerned queues' PPDs.

This would greatly reduce the code duplication and put the responsability to
update the CUPS queues on CUPS' shoulders instead of putting it on each
drivers'.

I plan to provide a patch, soon.

Cheers,

OdyX

-- System Information:
Debian Release: wheezy/sid
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'unstable'), (500, 'testing'), 
(500, 'stable'), (150, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.0.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_CH.UTF-8, LC_CTYPE=fr_CH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages cups depends on:
ii  adduser 3.113add and remove users and groups
ii  bc  1.06.95-2+b1 The GNU bc arbitrary precision cal
ii  cups-client 1.4.8-2  Common UNIX Printing System(tm) - 
ii  cups-common 1.4.8-2  Common UNIX Printing System(tm) - 
ii  cups-ppdc   1.4.8-2  Common UNIX Printing System(tm) - 
ii  debconf [debconf-2.0]   1.5.41   Debian configuration management sy
ii  ghostscript 9.02~dfsg-3  interpreter for the PostScript lan
ii  libacl1 2.2.51-3 Access control list shared library
ii  libavahi-client30.6.30-5 Avahi client library
ii  libavahi-common30.6.30-5 Avahi common library
ii  libc6   2.13-16  Embedded GNU C Library: Shared lib
ii  libcups21.4.8-2  Common UNIX Printing System(tm) - 
ii  libcupscgi1 1.4.8-2  Common UNIX Printing System(tm) - 
ii  libcupsdriver1  1.4.8-2  Common UNIX Printing System(tm) - 
ii  libcupsimage2   1.4.8-2  Common UNIX Printing System(tm) - 
ii  libcupsmime11.4.8-2  Common UNIX Printing System(tm) - 
ii  libcupsppdc11.4.8-2  Common UNIX Printing System(tm) - 
ii  libdbus-1-3 1.4.14-1 simple interprocess messaging syst
ii  libgcc1 1:4.6.1-6GCC support library
ii  libgnutls26 2.12.7-6 GNU TLS library - runtime library
ii  libgssapi-krb5-21.9.1+dfsg-2 MIT Kerberos runtime libraries - k
ii  libijs-0.35 0.35-7.1 IJS raster image transport protoco
ii  libkrb5-3   1.9.1+dfsg-2 MIT Kerberos runtime libraries
ii  liblcms11.19.dfsg-1  Little CMS color management librar
ii  libldap-2.4-2   2.4.25-3 OpenLDAP libraries
ii  libpam0g1.1.3-2  Pluggable Authentication Modules l
ii  libpaper1   1.1.24+nmu1  library for handling paper charact
ii  libpoppler130.16.7-2 PDF rendering library
ii  libslp1 1.2.1-7.8OpenSLP libraries
ii  libstdc++6  4.6.1-6  GNU Standard C++ Library v3
ii  libusb-0.1-42:0.1.12-18  userspace USB programming library
ii  lsb-base3.2-27   Linux Standard Base 3.2 init scrip
ii  poppler-utils   0.16.7-2 PDF utilities (based on Poppler)
ii  procps  1:3.2.8-11   /proc file system utilities
ii  ssl-cert1.0.28   simple debconf wrapper for OpenSSL
ii  ttf-freefont20100919-1   Freefont Serif, Sans and Mono True
ii  zlib1g  1:1.2.3.4.dfsg-3 compression library - runtime

Versions of packages cups recommends:
ii  avahi-daemon 0.6.30-5Avahi mDNS/DNS-SD daemon
ii  cups-driver-gutenprint   5.2.7-2 printer drivers for CUPS
ii  foomatic-filters 4.0.9-1 OpenPrinting printer support - fil
ii  ghostscript-cups 9.02~dfsg-3 

Bug#637978: cups: Please add a dpkg trigger to update PPDs on driver upgrades

2011-08-16 Thread Didier Raboud
tags 637978 + patch
thanks

Le mardi, 16 août 2011 10.14:51, Didier Raboud a écrit :
 I would like cups to implement a dpkg trigger to update it's queues' PPDs
 on driver upgrades.
 (…)
 I plan to provide a patch, soon.

Here it is, please comment.

Cheers,

-- 
OdyX
diff -Nru cups-1.4.8/debian/changelog cups-1.4.8/debian/changelog
--- cups-1.4.8/debian/changelog	2011-08-04 13:29:13.0 +0200
+++ cups-1.4.8/debian/changelog	2011-08-16 11:24:53.0 +0200
@@ -1,3 +1,11 @@
+cups (1.4.8-2.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Add a dpkg trigger to update the queues' PPDs on driver and filter
+upgrades (Closes: #637978).
+
+ -- Didier Raboud o...@debian.org  Tue, 16 Aug 2011 11:24:44 +0200
+
 cups (1.4.8-2) unstable; urgency=low
 
   * debian/control: Unbreak Maintainer: field. (Closes: #636574)
diff -Nru cups-1.4.8/debian/cups.postinst cups-1.4.8/debian/cups.postinst
--- cups-1.4.8/debian/cups.postinst	2011-08-04 13:29:13.0 +0200
+++ cups-1.4.8/debian/cups.postinst	2011-08-16 11:22:11.0 +0200
@@ -190,13 +190,13 @@
 
 # Do the following only if CUPS is running and the needed CUPS tools
 # are available
-if [ $1 = configure ]  \
+if [ $1 = configure ] || [ $1 = triggered ]  \
 	which lpstat  /dev/null 21  \
 	which lpinfo  /dev/null 21  \
 	which lpadmin  /dev/null 21  \
 LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not  /dev/null 21; then
 # Update the PPD files of all already installed print queues
-driverregexp='lsb/usr/cups-included/|drv:///sample.drv/'
+driverregexp='\.*'
 gennicknameregexp='s/,\s*\d+\.\d+[\d\.]*$//i'
 [ ! -z $gennicknameregexp ]  \
 	gennicknameregexp=; $gennicknameregexp
diff -Nru cups-1.4.8/debian/cups.triggers cups-1.4.8/debian/cups.triggers
--- cups-1.4.8/debian/cups.triggers	1970-01-01 01:00:00.0 +0100
+++ cups-1.4.8/debian/cups.triggers	2011-08-16 11:24:35.0 +0200
@@ -0,0 +1,7 @@
+# Trigger to update CUPS' queues' PPDs
+interest /usr/lib/cups/driver
+interest /usr/lib/cups/filter
+interest /usr/share/cups/model
+interest /usr/share/cups/drv
+interest /usr/share/ppd
+interest /usr/share/foomatic


Bug#637978: cups: Please add a dpkg trigger to update PPDs on driver upgrades

2011-08-16 Thread Roger Leigh
On Tue, Aug 16, 2011 at 10:14:51AM +0200, Didier Raboud wrote:
 I would like cups to implement a dpkg trigger to update it's queues' PPDs on
 driver upgrades.
 
 This task is currently implemented (and duplicated) in each printer driver, as
 a postinst. See e.g. c2esp, m2300w, foo2zjs, epson-inkjet-printer-escpr, etc.
 
 My initial take to solve this functionality duplication was the creation of a
 tiny cupsppupdate script and package (+ dh_* to include it nicely in the
 package building processes), that would be launched by each package's
 postinst. You can see this on the pkg-printing-tools initial repository:
 
   http://anonscm.debian.org/gitweb/?p=collab-maint/pkg-printing-tools.git
 
 But now I think this is not the right way to do it. As all drivers are
 supposed to be installable even in the absence of CUPS (aka Recommends), the
 script (and previously the postinst) checks for the presence and running 
 status
 of CUPS, and then goes updating files under /etc/cups/.
 
 This should IMHO be implemented on CUPS's side, as a dpkg trigger: this way,
 each time a driver would install or upgrade a file under
 /usr/lib/cups/{driver,filter}, CUPS's dpkg-trigger would schedule an update
 of its concerned queues' PPDs.
 
 This would greatly reduce the code duplication and put the responsability to
 update the CUPS queues on CUPS' shoulders instead of putting it on each
 drivers'.

Such a tool would be great.  I wrote cups-genppdupdate as part of the
gutenprint cups driver.  Feel free to borrow from it.

Note that this is something upstream have stated an interest in in
the past.  It might be worth discussing this with them directly--they
may already be working on it, or have some insight into how to
integrate this with CUPS nicely.  Ideally CUPS itself should be able
to refresh the PPDs, at least in the common case where the PPDs are
packaged.

Does your tool preserve the options stored in the PPD, or are these
lost?  When I wrote cups-genppdupdate I had to manually parse and
merge all options, but maybe CUPS does this internally now?

It's also important to deal with PPDs which don't exist on disk;
nowadays the drivers can autogenerate their associated PPDs
(see: gutenprint).  Does your tool cope with this?  I've looked
through the script, but I wasn't entirely sure.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?   http://gutenprint.sourceforge.net/
   `-GPG Public Key: 0x25BFB848   Please GPG sign your mail.


signature.asc
Description: Digital signature


Bug#637978: cups: Please add a dpkg trigger to update PPDs on driver upgrades

2011-08-16 Thread Till Kamppeter

Roger,

my postinst scripts (which OdyX uses for his trigger solution) conserve 
the default settings by replacing the PPD files using lpadmin -m. They 
also support PPDs which do not exist physically but get generated on the 
fly (listing available PPDs with lpinfo -m and requesting them with 
lpadmin -m, no direct file system access is done).


   Till



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#637978: cups: Please add a dpkg trigger to update PPDs on driver upgrades

2011-08-16 Thread Didier Raboud
Hi all, 

just a short mail summarizing the discussions we had on #ubuntu-devel 
regarding this proposal.

The current plan is:

1) externalize the current postinst code to an external program, based on the 
current cupsppdupdater code in pkg-printing-tools.
2) Have cups trigger on files under /usr/share/cups/ppd-updaters/
Those files, put there by the driver packages, will contain shell variable 
definitions: DRIVER_REGEXP and GENNICKNAME_REGEXP , which cups' postinst will 
use (when called as triggered) to launch cupsppdupdater with the correct 
parameters.
3) Migrate all drivers to stop duplicating functionality in their postinsts 
and ship a /usr/share/cups/ppd-updaters/${package} file with the correct 
variables (+ versioned Breaks against cups).

Cheers,

-- 
OdyX



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#637978: cups: Please add a dpkg trigger to update PPDs on driver upgrades

2011-08-16 Thread Didier Raboud
tags 637978 + patch
thanks

So, after some more work and thoughts, here is a new patch proposal 
(attached).

Le mardi, 16 août 2011 13.14:13, Didier Raboud a écrit :
 The current plan is:
 
 1) externalize the current postinst code to an external program, based on
 the current cupsppdupdater code in pkg-printing-tools.

Discarded, for performance reasons: keeping the code self-contained in the 
postinst allows me to save the `lpinfo -m` once for all updates.

 2) Have cups trigger on files under /usr/share/cups/ppd-updaters/
 Those files, put there by the driver packages, will contain shell variable
 definitions: DRIVER_REGEXP and GENNICKNAME_REGEXP , which cups' postinst
 will use (when called as triggered) to launch cupsppdupdater with the
 correct parameters.

Done and tested locally with one driver.

 3) Migrate all drivers to stop duplicating functionality in their postinsts
 and ship a /usr/share/cups/ppd-updaters/${package} file with the correct
 variables (+ versioned Breaks against cups).

To be done, of course.

Please comment on the attached patch; 

cheers,

-- 
OdyX
diff -Nru cups-1.5.0/debian/changelog cups-1.5.0/debian/changelog
--- cups-1.5.0/debian/changelog	2011-08-07 12:53:28.0 +0200
+++ cups-1.5.0/debian/changelog	2011-08-16 13:57:21.0 +0200
@@ -1,3 +1,11 @@
+cups (1.5.0-1.1) experimental; urgency=low
+
+  * Non-maintainer upload.
+  * Add a dpkg trigger to update the queues' PPDs on (cooperative) driver
+upgrades (Closes: #637978).
+
+ -- Didier Raboud o...@debian.org  Tue, 16 Aug 2011 13:56:00 +0200
+
 cups (1.5.0-1) experimental; urgency=low
 
   [ Till Kamppeter ]
diff -Nru cups-1.5.0/debian/cups.postinst cups-1.5.0/debian/cups.postinst
--- cups-1.5.0/debian/cups.postinst	2011-08-07 12:53:28.0 +0200
+++ cups-1.5.0/debian/cups.postinst	2011-08-16 13:51:27.0 +0200
@@ -189,45 +189,64 @@
 
 #DEBHELPER#
 
+# ppd_updater is supposed to be launched only with a running CUPS.
+ppd_updater () {
+	driverregexp=$1
+	gennicknameregexp=$2
+
+	[ ! -z $gennicknameregexp ]  \
+	gennicknameregexp=; $gennicknameregexp
+	gennicknameregexp='s/\s*\(recommended\)//'$gennicknameregexp
+	tmpfile1=`mktemp -t updateppds.XX`
+	tempfiles=$tempfiles $tmpfile1
+	grep -E $driverregexp $tmpfile0  $tmpfile1
+	cd /etc/cups/ppd
+	for ppd in *.ppd; do
+	[ -r $ppd ] || continue
+	queue=${ppd%.ppd}
+	lpstat -h /var/run/cups/cups.sock -p $queue /dev/null 21 || continue
+	nickname=`grep '\*NickName:' $ppd | cut -d '' -f 2 | perl -p -e 's/\n$//' | perl -p -e $gennicknameregexp | perl -p -e 's/(\W)/$1/g'`
+	lang=`grep '\*LanguageVersion:' $ppd | cut -d ' ' -f 2 | perl -e 'print lc()' | perl -p -e 's/[\r\n]//gs'`
+	ppdfound=0
+	englishppduri=
+	tmpfile2=`mktemp -t updateppds.XX`
+	tempfiles=$tempfiles $tmpfile2
+	cat $tmpfile1 | perl -p -e $gennicknameregexp | grep -E '^\S+\s+.*'$nickname'$' | cut -d ' ' -f 1  $tmpfile2
+	while read newppduri; do
+		[ $ppdfound = 0 ]  lpadmin -h /var/run/cups/cups.sock -p $queue -m $newppduri 2/dev/null || continue
+		newlang=`grep '\*LanguageVersion:' $ppd | cut -d ' ' -f 2 | perl -e 'print lc()' | perl -p -e 's/[\r\n]//gs'`
+		[ $newlang = $lang ]  ppdfound=1
+		[ $newlang = english ]  englishppduri=$newppduri
+	done  $tmpfile2
+	[ $ppdfound = 0 ]  [ ! -z $englishppduri ]  lpadmin -h /var/run/cups/cups.sock -p $queue -m $englishppduri 2/dev/null  ppdfound=1
+	[ $ppdfound = 1 ]  echo PPD for printer $queue updated 2
+	done
+}
+
 # Do the following only if CUPS is running and the needed CUPS tools
 # are available
-if [ $1 = configure ]  \
-	which lpstat  /dev/null 21  \
+if which lpstat  /dev/null 21  \
 	which lpinfo  /dev/null 21  \
 	which lpadmin  /dev/null 21  \
-LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not  /dev/null 21; then
-# Update the PPD files of all already installed print queues
-driverregexp='lsb/usr/cups-included/|drv:///sample.drv/'
-gennicknameregexp='s/,\s*\d+\.\d+[\d\.]*$//i'
-[ ! -z $gennicknameregexp ]  \
-	gennicknameregexp=; $gennicknameregexp
-gennicknameregexp='s/\s*\(recommended\)//'$gennicknameregexp
-tempfiles=
-trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
-tmpfile1=`mktemp -t updateppds.XX`
-tempfiles=$tempfiles $tmpfile1
-lpinfo -h /var/run/cups/cups.sock -m | grep -E $driverregexp  $tmpfile1
-cd /etc/cups/ppd
-for ppd in *.ppd; do
-	[ -r $ppd ] || continue
-	queue=${ppd%.ppd}
-	lpstat -h /var/run/cups/cups.sock -p $queue /dev/null 21 || continue
-	nickname=`grep '\*NickName:' $ppd | cut -d '' -f 2 | perl -p -e 's/\n$//' | perl -p -e $gennicknameregexp | perl -p -e 's/(\W)/$1/g'`
-	lang=`grep '\*LanguageVersion:' $ppd | cut -d ' ' -f 2 | perl -e 'print lc()' | perl -p -e 's/[\r\n]//gs'`
-	ppdfound=0
-	englishppduri=
-	tmpfile2=`mktemp -t updateppds.XX`
-	tempfiles=$tempfiles $tmpfile2
-	cat $tmpfile1 | perl -p -e $gennicknameregexp | grep -i $nickname'$'