~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#! /bin/sh
# postinst script for ghostscript
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#

case "$1" in
    configure)
	# /usr/bin/ps2pdf is now controlled by update-alternatives
	update-alternatives --install /usr/bin/ps2pdf \
	  ps2pdf /usr/bin/ps2pdf14 50
	update-alternatives --install /usr/bin/ps2pdf \
	  ps2pdf /usr/bin/ps2pdf12 30
	update-alternatives --install /usr/bin/ps2pdf \
	  ps2pdf /usr/bin/ps2pdf13 40

	# Make sure the substitution file for Ghostscript exists
	if ! defoma-subst check-rule ghostscript; then
	  defoma-subst new-rule ghostscript
	fi

	defoma-app -t update gs

        # 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 && \
	    lpstat -r > /dev/null 2>&1; then
	    # Update the PPD files of all already installed print queues
	    driverregexp='lsb/usr/ghostscript/'
	    gennicknameregexp=''
	    [ ! -z "$gennicknameregexp" ] && \
		gennicknameregexp="; $gennicknameregexp"
	    gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
	    tempfiles=
	    trap 'rm -f $tempfiles; exit 0' 0 1 2 13 15
	    tmpfile1=`mktemp -t updateppds.XXXXXX`
	    tempfiles="$tempfiles $tmpfile1"
	    lpinfo -m | grep -E $driverregexp > $tmpfile1
	    cd /etc/cups/ppd
	    for ppd in *.ppd; do
		[ -r "$ppd" ] || continue
		queue=${ppd%.ppd}
		lpstat -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 -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 -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
		[ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
	    done
	fi

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0