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

« back to all changes in this revision

Viewing changes to debian/local/make-duplex-page-sizes-default.sh

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2010-12-23 11:04:31 UTC
  • mfrom: (2.1.158 natty)
  • Revision ID: james.westby@ubuntu.com-20101223110431-ev5wz1it6b7jce51
Tags: 3.10.9-1
New Upstream Release 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
f=$1
 
3
 
 
4
echo "Renaming page sizes in $f"
 
5
 
 
6
# Correct entries for small margin paper sizes which were already there
 
7
perl -p -i -e 's:SM/:.SM/:g' $f
 
8
perl -p -i -e 's:SmallMargins:Small Margins:g' $f
 
9
 
 
10
# Find which page sizes support duplex
 
11
duplexsizes=`grep -v '^//' $f | grep CustomMedia | grep '\.Duplex' | cut -d " " -f 4 | cut -d "/" -f 1 | cut -d '"' -f 2 | perl -p -e "s/\.Duplex//" | sort | uniq`
 
12
 
 
13
# Rename CustomMedia entries: duplex sizes -> standard sizes, standard sizes ->
 
14
# small margin sizes
 
15
echo -n "  Renaming paper size definitions"
 
16
finished=0
 
17
while [ $finished = 0 ]; do
 
18
    perl -e 'my $content = join("", <>); $content =~ s:(CustomMedia\s*\")([^\s\.\/]+)(\/([^\"]+?\s+|))(\S+\"([^\n]*\n){0,4}\s*CustomMedia\s*\")(\2)(.Duplex)(\/[^\"]*?\s*)(AutoDuplex ):\1\2.SM\3Small Margins \5\7\9:smgi; print $content' $f > $f.new 2>/dev/null
 
19
    if diff $f $f.new >/dev/null 2>/dev/null; then
 
20
        rm $f.new
 
21
        echo " Done"
 
22
        finished=1
 
23
    else
 
24
        rm $f && mv $f.new $f
 
25
        echo -n "."
 
26
    fi
 
27
done
 
28
 
 
29
# Update the UIConstraints entries of the paper sizes which support duplex
 
30
for size in $duplexsizes; do
 
31
    echo -n "  Updating UI Constraints for $size:"
 
32
    perl -p -e 's/(UIConstraints\s*\"\s*\*PageSize\s+)('"$size"')(\s+\*Duplex\s*\")/\1\2.SM\3/i' $f > $f.new 2>/dev/null
 
33
    if diff $f $f.new >/dev/null 2>/dev/null; then
 
34
        rm $f.new
 
35
        echo " No changes"
 
36
        finished=1
 
37
    else
 
38
        rm $f && mv $f.new $f
 
39
        echo " Done"
 
40
    fi
 
41
done
 
42
 
 
43
# Remove remaining ".Duplex" from paper sizes in UIConstraints
 
44
perl -p -i -e 's:\.Duplex::g' $f