~ubuntu-branches/ubuntu/raring/hplip/raring

« back to all changes in this revision

Viewing changes to debian/hplip-cups.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2009-12-14 20:08:44 UTC
  • mfrom: (2.1.118 lucid)
  • Revision ID: james.westby@ubuntu.com-20091214200844-z8qhqwgppbu3t7ze
Tags: 3.9.10-4
KBSD patch from KiBi (Closes: #560796)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
        if which lpstat > /dev/null 2>&1 && \
32
32
            which lpinfo > /dev/null 2>&1 && \
33
33
            which lpadmin > /dev/null 2>&1 && \
34
 
            lpstat -r > /dev/null 2>&1; then
 
34
            LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
35
35
            # Update the PPD files of all already installed print queues
36
 
            driverregexp='drv:///hpcups.drv/'
37
 
            gennicknameregexp='s/,?\s*hpcups\s+[\d\.]+.*$//'
 
36
            driverregexp='drv:///hpcups.drv/|lsb/usr/hplip/HP/HP-Fax.*-hpcups'
 
37
            gennicknameregexp='s/,?(\s*hpijs,?|,)\s*[\d\.]+[a-zA-Z]*\s*$//; s/\s*(Foomatic\/|)(hpijs)(\s*\S+|)$//i; s/,?\s*hpcups,?\s+[\d\.]+[a-zA-Z]*\s*$//; s/\s*(Foomatic\/|)(hpcups)(\s*\S+|)$//i; s/\s*Series$//i; s/(HP\s+)PhotoSmart(\s+)/\1PS\2/i; s/(HP\s+)DeskJet(\s+)/\1DJ\2/i; s/(HP\s+)Color\s*(LaserJet|LJ)(\s+)/\1CLJ\3/i; s/(HP\s+)LaserJet(\s+)/\1LJ\2/i; s/(HP\s+)OfficeJet(\s+)/\1OJ\2/i; s/(HP\s+)Business\s*InkJet(\s+)/\1BIJ\2/i; s/(HP\s+)DesignJet(\s+)/\1DESIGNJ\2/i; s/(HP\s+)Printer\s*Scanner\s*Copier(\s+)/\1PSC\2/i; s/(HP\s+)Color\s*InkJet\s*Printer\s+/\1/i; s/\s+(zjs|zxs|pcl3)//i'
38
38
            [ ! -z "$gennicknameregexp" ] && \
39
39
                gennicknameregexp="; $gennicknameregexp"
40
40
            gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
41
41
            tempfiles=
42
 
            trap 'rm -f $tempfiles; exit 0' 0 1 2 13 15
 
42
            trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
43
43
            tmpfile1=`mktemp -t updateppds.XXXXXX`
44
44
            tempfiles="$tempfiles $tmpfile1"
45
 
            lpinfo -m | grep -E $driverregexp > $tmpfile1
 
45
            lpinfo -h /var/run/cups/cups.sock -m | grep -E $driverregexp > $tmpfile1
46
46
            cd /etc/cups/ppd
47
47
            for ppd in *.ppd; do
48
48
                [ -r "$ppd" ] || continue
49
49
                queue=${ppd%.ppd}
50
 
                lpstat -p "$queue" >/dev/null 2>&1 || continue
 
50
                lpstat -h /var/run/cups/cups.sock -p "$queue" >/dev/null 2>&1 || continue
51
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
52
                lang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
53
53
                ppdfound="0"
54
54
                englishppduri=""
55
55
                tmpfile2=`mktemp -t updateppds.XXXXXX`
56
56
                tempfiles="$tempfiles $tmpfile2"
57
 
                cat $tmpfile1 | perl -p -e "$gennicknameregexp" | grep -E '^\S+\s+.*'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
 
57
                cat $tmpfile1 | perl -p -e "$gennicknameregexp; s/\s*$/\n/" | grep -E '\b'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
58
58
                while read newppduri; do
59
 
                    [ "$ppdfound" = "0" ] && lpadmin -p "$queue" -m $newppduri 2>/dev/null || continue
 
59
                    [ "$ppdfound" = "0" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $newppduri 2>/dev/null || continue
60
60
                    newlang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
61
61
                    [ "$newlang" = "$lang" ] && ppdfound="1"
62
62
                    [ "$newlang" = "english" ] && englishppduri="$newppduri"
63
63
                done < $tmpfile2
64
 
                [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
 
64
                [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
65
65
                [ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
66
66
            done
67
67
        fi