~ubuntu-branches/ubuntu/maverick/ptouch-driver/maverick

« back to all changes in this revision

Viewing changes to debian/postinst

  • Committer: Bazaar Package Importer
  • Author(s): Lars Wirzenius, Till Kamppeter, Lars Wirzenius
  • Date: 2009-11-11 17:14:44 UTC
  • Revision ID: james.westby@ubuntu.com-20091111171444-ppusibbb0hi64b0q
Tags: 1.3-0ubuntu1
[ Till Kamppeter ]
* debian/postinst: Added automatic update of PPD files of already existing
  print queues when the package is updated.
* debian/rules: Removed the Foomatic printer XML files, they are already
  contained in foomatic-db.
* debian/rules: Suppress running dh_auto_test, it runs often before the
  Makefile is created (dh bug?).
* debian/rules, debian/control: Added support for patches.
* debian/control: Set section to "text".
* debian/local/apport-hook.py, debian/rules: Added Apport hook.
* debian/patches/foomatic-data-fixes.patch: Moved the Foomatic data fixes
  into a proper patch.

[ Lars Wirzenius ]
* Initial packaging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
# postinst script for ptouch-driver
 
3
# $Id: $
 
4
#
 
5
# see: dh_installdeb(1)
 
6
 
 
7
set -e
 
8
 
 
9
# summary of how this script can be called:
 
10
#        * <postinst> `configure' <most-recently-configured-version>
 
11
#        * <old-postinst> `abort-upgrade' <new version>
 
12
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
 
13
#          <new-version>
 
14
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
 
15
#          <failed-install-package> <version> `removing'
 
16
#          <conflicting-package> <version>
 
17
# for details, see http://www.debian.org/doc/debian-policy/ or
 
18
# the debian-policy package
 
19
#
 
20
# quoting from the policy:
 
21
#     Any necessary prompting should almost always be confined to the
 
22
#     post-installation script, and should be protected with a conditional
 
23
#     so that unnecessary prompting doesn't happen if a package's
 
24
#     installation fails and the `postinst' is called with `abort-upgrade',
 
25
#     `abort-remove' or `abort-deconfigure'.
 
26
 
 
27
case "$1" in
 
28
    configure)
 
29
        # Do the following only if CUPS is running and the needed CUPS tools
 
30
        # are available
 
31
        if which lpstat > /dev/null 2>&1 && \
 
32
            which lpinfo > /dev/null 2>&1 && \
 
33
            which lpadmin > /dev/null 2>&1 && \
 
34
            LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
 
35
            # Update the PPD files of all already installed print queues
 
36
            driverregexp='^foomatic:.*-ptouch\.ppd\b'
 
37
            gennicknameregexp=''
 
38
            [ ! -z "$gennicknameregexp" ] && \
 
39
                gennicknameregexp="; $gennicknameregexp"
 
40
            gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
 
41
            tempfiles=
 
42
            trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
 
43
            tmpfile1=`mktemp -t updateppds.XXXXXX`
 
44
            tempfiles="$tempfiles $tmpfile1"
 
45
            lpinfo -h /var/run/cups/cups.sock -m | grep -E $driverregexp > $tmpfile1
 
46
            cd /etc/cups/ppd
 
47
            for ppd in *.ppd; do
 
48
                [ -r "$ppd" ] || continue
 
49
                queue=${ppd%.ppd}
 
50
                lpstat -h /var/run/cups/cups.sock -p "$queue" >/dev/null 2>&1 || continue
 
51
                nickname=`grep '\*NickName:' "$ppd" | cut -d '"' -f 2 | perl -p -e 's/\n$//' | perl -p -e "$gennicknameregexp" | perl -p -e 's/(\W)/\\\\$1/g'`
 
52
                lang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
 
53
                ppdfound="0"
 
54
                englishppduri=""
 
55
                tmpfile2=`mktemp -t updateppds.XXXXXX`
 
56
                tempfiles="$tempfiles $tmpfile2"
 
57
                cat $tmpfile1 | perl -p -e "$gennicknameregexp" | grep -E '^\S+\s+.*'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
 
58
                while read newppduri; do
 
59
                    [ "$ppdfound" = "0" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $newppduri 2>/dev/null || continue
 
60
                    newlang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
 
61
                    [ "$newlang" = "$lang" ] && ppdfound="1"
 
62
                    [ "$newlang" = "english" ] && englishppduri="$newppduri"
 
63
                done < $tmpfile2
 
64
                [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
 
65
                [ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
 
66
            done
 
67
        fi
 
68
    ;;
 
69
 
 
70
    abort-upgrade|abort-remove|abort-deconfigure)
 
71
    ;;
 
72
 
 
73
    *)
 
74
        echo "postinst called with unknown argument \`$1'" >&2
 
75
        exit 1
 
76
    ;;
 
77
esac
 
78
 
 
79
# dh_installdeb will replace this with shell code automatically
 
80
# generated by other debhelper scripts.
 
81
 
 
82
#DEBHELPER#
 
83
 
 
84
exit 0