[Foo2zjs-commits] r258 - trunk/foo2zjs_20100728dfsg/debian
Luca Capello
gismo at alioth.debian.org
Fri Feb 18 14:39:19 UTC 2011
Author: gismo
Date: 2011-02-18 14:39:15 +0000 (Fri, 18 Feb 2011)
New Revision: 258
Modified:
trunk/foo2zjs_20100728dfsg/debian/changelog
trunk/foo2zjs_20100728dfsg/debian/control
trunk/foo2zjs_20100728dfsg/debian/foo2zjs.postinst
Log:
debian/foo2zjs.postinst: update the PPD files for existing queues
Modified: trunk/foo2zjs_20100728dfsg/debian/changelog
===================================================================
--- trunk/foo2zjs_20100728dfsg/debian/changelog 2011-02-18 14:24:52 UTC (rev 257)
+++ trunk/foo2zjs_20100728dfsg/debian/changelog 2011-02-18 14:39:15 UTC (rev 258)
@@ -37,6 +37,12 @@
[ Steve Langasek ]
* Merge from Ubuntu maverick.
+ * debian/control:
+ + Add dependency on cups and cups-client to ensure that automatic
+ update of the PPDs of existing print queues works.
+ * debian/foo2zjs.postinst:
+ + Automatically update the PPD files for existing queues to the
+ versions supplied with this package.
* debian/patches/30-udev-rules.dpatch:
+ Add udev rule for HP Laserjet P1505n.
Modified: trunk/foo2zjs_20100728dfsg/debian/control
===================================================================
--- trunk/foo2zjs_20100728dfsg/debian/control 2011-02-18 14:24:52 UTC (rev 257)
+++ trunk/foo2zjs_20100728dfsg/debian/control 2011-02-18 14:39:15 UTC (rev 258)
@@ -11,7 +11,7 @@
Package: foo2zjs
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, foomatic-filters, dc
+Depends: ${shlibs:Depends}, ${misc:Depends}, foomatic-filters, dc, cups, cups-client
Recommends: foomatic-db-engine, wget, unzip
Suggests: psutils, hannah-foo2zjs, tk8.4, tix
Breaks: udev (<< 136-1)
Modified: trunk/foo2zjs_20100728dfsg/debian/foo2zjs.postinst
===================================================================
--- trunk/foo2zjs_20100728dfsg/debian/foo2zjs.postinst 2011-02-18 14:24:52 UTC (rev 257)
+++ trunk/foo2zjs_20100728dfsg/debian/foo2zjs.postinst 2011-02-18 14:39:15 UTC (rev 258)
@@ -3,9 +3,49 @@
set -e
if [ "$1" = configure ]; then
- if ls /usr/share/foo2zjs/firmware/*.dl >/dev/null 2>/dev/null; then
- mv /usr/share/foo2zjs/firmware/*.dl /lib/firmware/hp/ 2>/dev/null
- fi
+ # Move user-downloaded firmware files
+ if ls /usr/share/foo2zjs/firmware/*.dl >/dev/null 2>/dev/null; then
+ mv /usr/share/foo2zjs/firmware/*.dl /lib/firmware/hp/ 2>/dev/null
+ fi
+ # Do the following only if CUPS is running and the needed CUPS tools
+ # are available
+ if which lpstat > /dev/null 2>&1 && \
+ which lpinfo > /dev/null 2>&1 && \
+ which lpadmin > /dev/null 2>&1 && \
+ LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
+ # Update the PPD files of all already installed print queues
+ driverregexp='lsb/usr/foo2zjs/'
+ gennicknameregexp='s/-z\d\b//'
+ [ ! -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.XXXXXX`
+ 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 2>&1 || 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.XXXXXX`
+ 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
+ fi
fi
#DEBHELPER#
More information about the Foo2zjs-commits
mailing list