~ubuntu-branches/ubuntu/quantal/gutenprint/quantal

« back to all changes in this revision

Viewing changes to debian/foomatic-db-gutenprint.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-08-18 14:15:24 UTC
  • Revision ID: james.westby@ubuntu.com-20090818141524-n1fo6hdpvg360wgq
Tags: 5.2.4-0ubuntu2
* debian/cups-driver-gutenprint.postinst,
  debian/foomatic-db-gutenprint.postinst: Fixed "lpstat -r" check for the
  auto update of PPDs of existing queues. "lpstat -r" exits always with
  status 0, we must check the actual output. Call lpstat, lpadmin, and
  cupsctl with "-h /var/run/cups/cups.sock" to avoid querying remote
  servers set up in /etc/cups/client.conf, and asking for passwords. 
  Thanks to Martin-Éric Racine for tracking this down and the solution!
  See Debian bug #543468. Use signal names instead of numbers for trap.
  Quiesces a lintian bashism warning.

* debian/patches/20_device-id-support.dpatch: Added IEEE-1284 device IDs
  to Gutenprint's model database, to avoid wrong driver assignments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    if which lpstat > /dev/null 2>&1 && \
31
31
        which lpinfo > /dev/null 2>&1 && \
32
32
        which lpadmin > /dev/null 2>&1 && \
33
 
        lpstat -r > /dev/null 2>&1; then
 
33
        LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
34
34
        # Update the PPD files of all already installed print queues
35
35
        driverregexp='^foomatic:\S*-gutenprint-ijs'
36
36
        gennicknameregexp='s/\.[\d\.]*$//'
38
38
            gennicknameregexp="; $gennicknameregexp"
39
39
        gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
40
40
        tempfiles=
41
 
        trap 'rm -f $tempfiles; exit 0' 0 1 2 13 15
 
41
        trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
42
42
        tmpfile1=`mktemp -t updateppds.XXXXXX`
43
43
        tempfiles="$tempfiles $tmpfile1"
44
 
        lpinfo -m | grep -E $driverregexp > $tmpfile1
 
44
        lpinfo -h /var/run/cups/cups.sock -m | grep -E $driverregexp > $tmpfile1
45
45
        cd /etc/cups/ppd
46
46
        for ppd in *.ppd; do
47
47
            [ -r "$ppd" ] || continue
48
48
            queue=${ppd%.ppd}
49
 
            lpstat -p "$queue" >/dev/null 2>&1 || continue
 
49
            lpstat -h /var/run/cups/cups.sock -p "$queue" >/dev/null 2>&1 || continue
50
50
            nickname=`grep '\*NickName:' "$ppd" | cut -d '"' -f 2 | perl -p -e 's/\n$//' | perl -p -e "$gennicknameregexp" | perl -p -e 's/(\W)/\\\\$1/g'`
51
51
            lang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
52
52
            ppdfound="0"
55
55
            tempfiles="$tempfiles $tmpfile2"
56
56
            cat $tmpfile1 | perl -p -e "$gennicknameregexp" | grep -E '^\S+\s+.*'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
57
57
            while read newppduri; do
58
 
                [ "$ppdfound" = "0" ] && lpadmin -p "$queue" -m $newppduri 2>/dev/null || continue
 
58
                [ "$ppdfound" = "0" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $newppduri 2>/dev/null || continue
59
59
                newlang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
60
60
                [ "$newlang" = "$lang" ] && ppdfound="1"
61
61
                [ "$newlang" = "english" ] && englishppduri="$newppduri"
62
62
            done < $tmpfile2
63
 
            [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
 
63
            [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
64
64
            [ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
65
65
        done
66
66
    fi