0 | |
#!/bin/sh
|
1 | |
# postinst script for rastertosag-gdi
|
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 | |
LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
|
32 | |
# Update the PPD files of all already installed print queues
|
33 | |
driverregexp='lsb/usr/rastertosag-gdi/'
|
34 | |
gennicknameregexp=''
|
35 | |
[ ! -z "$gennicknameregexp" ] && \
|
36 | |
gennicknameregexp="; $gennicknameregexp"
|
37 | |
gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
|
38 | |
tempfiles=
|
39 | |
trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
|
40 | |
tmpfile1=`mktemp -t updateppds.XXXXXX`
|
41 | |
tempfiles="$tempfiles $tmpfile1"
|
42 | |
lpinfo -h /var/run/cups/cups.sock -m | grep -E $driverregexp > $tmpfile1
|
43 | |
cd /etc/cups/ppd
|
44 | |
for ppd in *.ppd; do
|
45 | |
[ -r "$ppd" ] || continue
|
46 | |
queue=${ppd%.ppd}
|
47 | |
lpstat -h /var/run/cups/cups.sock -p "$queue" >/dev/null 2>&1 || continue
|
48 | |
nickname=`grep '\*NickName:' "$ppd" | cut -d '"' -f 2 | perl -p -e 's/\n$//' | perl -p -e "$gennicknameregexp" | perl -p -e 's/(\W)/\\\\$1/g'`
|
49 | |
lang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
|
50 | |
ppdfound="0"
|
51 | |
englishppduri=""
|
52 | |
tmpfile2=`mktemp -t updateppds.XXXXXX`
|
53 | |
tempfiles="$tempfiles $tmpfile2"
|
54 | |
cat $tmpfile1 | perl -p -e "$gennicknameregexp" | grep -E '^\S+\s+.*'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
|
55 | |
while read newppduri; do
|
56 | |
[ "$ppdfound" = "0" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $newppduri 2>/dev/null || continue
|
57 | |
newlang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
|
58 | |
[ "$newlang" = "$lang" ] && ppdfound="1"
|
59 | |
[ "$newlang" = "english" ] && englishppduri="$newppduri"
|
60 | |
done < $tmpfile2
|
61 | |
[ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
|
62 | |
[ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
|
63 | |
done
|
64 | |
fi
|
65 | |
elif [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-remove" ] || [ "$1" = "abort-deconfigure" ]; then
|
66 | |
:
|
67 | |
else
|
68 | |
echo "postinst called with unknown argument \`$1'" >&2
|
69 | |
exit 0
|
70 | |
fi
|
71 | |
|
72 | |
|
73 | |
#DEBHELPER#
|
74 | |
exit 0
|