Codebase list m2300w / debian/0.51-0ubuntu6
debian/m2300w.postinst: Added automatic updating of the PPD files of the already existing CUPS queues which use this driver. Till Kamppeter authored 16 years ago Bazaar Package Importer committed 16 years ago
2 changed file(s) with 80 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 m2300w (0.51-0ubuntu6) jaunty; urgency=low
1
2 * debian/m2300w.postinst: Added automatic updating of the PPD files of the
3 already existing CUPS queues which use this driver.
4
5 -- Till Kamppeter <till.kamppeter@gmail.com> Wed, 18 Feb 2008 10:57:50 +0100
6
07 m2300w (0.51-0ubuntu5) intrepid; urgency=low
18
29 * debian/rules: Add "*cupsFilter" line to accept PDF input data to the PPDs
0 #!/bin/sh
1 # postinst script for m2300w
2 #
3 # see: dh_installdeb(1)
4
5 set -e
6
7 # summary of how this script can be called:
8 # * <postinst> `configure' <most-recently-configured-version>
9 # * <old-postinst> `abort-upgrade' <new version>
10 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
11 # <new-version>
12 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
13 # <failed-install-package> <version> `removing'
14 # <conflicting-package> <version>
15 # for details, see http://www.debian.org/doc/debian-policy/ or
16 # the debian-policy package
17 #
18 # quoting from the policy:
19 # Any necessary prompting should almost always be confined to the
20 # post-installation script, and should be protected with a conditional
21 # so that unnecessary prompting doesn't happen if a package's
22 # installation fails and the `postinst' is called with `abort-upgrade',
23 # `abort-remove' or `abort-deconfigure'.
24
25 if [ "$1" = "configure" ]; then
26 # Do the following only if CUPS is running and the needed CUPS tools
27 # are available
28 if which lpstat > /dev/null 2>&1 && \
29 which lpinfo > /dev/null 2>&1 && \
30 which lpadmin > /dev/null 2>&1 && \
31 lpstat -r > /dev/null 2>&1; then
32 # Update the PPD files of all already installed print queues
33 driverregexp='lsb/usr/m2300w/'
34 gennicknameregexp=''
35 [ ! -z "$gennicknameregexp" ] && \
36 gennicknameregexp="; $gennicknameregexp"
37 gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
38 tempfiles=
39 trap 'rm -f $tempfiles; exit 0' 0 1 2 13 15
40 tmpfile1=`mktemp -t updateppds.XXXXXX`
41 tempfiles="$tempfiles $tmpfile1"
42 lpinfo -m | grep -E $driverregexp > $tmpfile1
43 cd /etc/cups/ppd
44 for ppd in `ls -1 *.ppd 2>/dev/null`; do
45 queue=${ppd%.ppd}
46 nickname=`grep '\*NickName:' $ppd | cut -d '"' -f 2 | perl -p -e 's/\n$//' | perl -p -e "$gennicknameregexp" | perl -p -e 's/(\W)/\\\\$1/g'`
47 lang=`grep '\*LanguageVersion:' $ppd | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
48 ppdfound="0"
49 englishppduri=""
50 tmpfile2=`mktemp -t updateppds.XXXXXX`
51 tempfiles="$tempfiles $tmpfile2"
52 cat $tmpfile1 | perl -p -e "$gennicknameregexp" | grep -E '^\S+\s+.*'"$nickname" | cut -d ' ' -f 1 > $tmpfile2
53 while read newppduri; do
54 [ "$ppdfound" = "0" ] && lpadmin -p $queue -m $newppduri
55 newlang=`grep '\*LanguageVersion:' $ppd | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
56 [ "$newlang" = "$lang" ] && ppdfound="1"
57 [ "$newlang" = "english" ] && englishppduri="$newppduri"
58 done < $tmpfile2
59 [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -p $queue -m $englishppduri && ppdfound="1"
60 [ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
61 done
62 fi
63 elif [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-remove" ] || [ "$1" = "abort-deconfigure" ]; then
64 :
65 else
66 echo "postinst called with unknown argument \`$1'" >&2
67 exit 0
68 fi
69
70
71 #DEBHELPER#
72 exit 0