blob: 292990c9e9e644b3c9731d1419caf3b602db1e36 (
plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#!@SH@
#
# $NetBSD: setpapersize,v 1.10 2003/09/15 10:51:40 agc Exp $
#
# Small shell script to set the default papersize for packages
#
# Make sure we've been given an argument
if [ $# -lt 1 ]; then
@ECHO@ "Usage: setpapersize papersize"
exit 1
fi
papersize=$1
shift 1
# Make sure the argument is valid.
case $papersize in
a4|A4)
papersize=A4
dimensions="210mm x 297mm"
;;
letter|letterdj)
papersize=`@ECHO@ $papersize|@SED@ -e 's|^.|L|'`
dimensions='8.5" x 11"'
;;
Letter|Letterdj)
dimensions='8.5" x 11"'
;;
*)
@ECHO@ "Invalid paper size: $papersize"
@ECHO@ "It should be one of: A4, Letter or Letterdj"
exit 1
;;
esac
lowpaper=`@ECHO@ $papersize | @TR@ '[A-Z]' '[a-z]'`
if [ $# -eq 0 ]; then
pkgs="a2ps ddd enscript ghostscript gv magicfilter psutils";
else
pkgs=$@
fi
set $pkgs
while [ $# -gt 0 ]; do
case $1 in
a2ps)
a2psfile=@PKG_SYSCONFDIR@/a2ps-site.cfg
if [ -s "$a2psfile" ]; then
@MV@ $a2psfile $a2psfile.old
@SED@ -e 's|^Options: --medium=.*|Options: --medium='$papersize'|' $a2psfile.old > $a2psfile && @RM@ $a2psfile.old
@ECHO@ "Set $1 package default paper size to $papersize in $a2psfile"
fi
;;
ddd)
dddfile=@X11BASE@/lib/X11/app-defaults/Ddd
if [ -s "$dddfile" ]; then
@MV@ $dddfile $dddfile.old
@SED@ -e 's|@Ddd@\*paperSize:.*|@Ddd@*paperSize: '$dimensions'|' $dddfile.old > $dddfile && @RM@ $dddfile.old
@ECHO@ "Set $1 package default paper size to $papersize in $dddfile"
fi
;;
enscript)
enscriptfile=@PKG_SYSCONFDIR@/enscript.cfg
if [ -s "$enscriptfile" ]; then
@MV@ $enscriptfile $enscriptfile.old
@SED@ -e 's|^DefaultMedia:.*|DefaultMedia: '$papersize'|' $enscriptfile.old > $enscriptfile && @RM@ $enscriptfile.old
@ECHO@ "Set $1 package default paper size to $papersize in $enscriptfile"
fi
;;
ghostscript)
ghostscriptfile=`ls @LOCALBASE@/share/ghostscript/*/lib/gs_init.ps 2>/dev/null | tail -1`
if [ -s "$ghostscriptfile" ]; then
@MV@ $ghostscriptfile $ghostscriptfile.old
@SED@ -e '/^% Optionally choose a default paper size other than U.S. letter.$/N' -e 's/^\(% Optionally.*\n\)[%[:space:]]*(.*\() \/PAPERSIZE where.*\)$/\1('$lowpaper'\2/' $ghostscriptfile.old > $ghostscriptfile && @RM@ $ghostscriptfile.old
@ECHO@ "Set $1 package default paper size to $papersize in $ghostscriptfile"
fi
;;
gv)
gvfile=@X11BASE@/lib/X11/app-defaults/GV
if [ -s "$gvfile" ]; then
@MV@ $gvfile $gvfile.old
@SED@ -e 's|^GV.fallbackPageMedia:.*|GV.fallbackPageMedia: '$papersize'|' $gvfile.old > $gvfile && @RM@ $gvfile.old
@ECHO@ "Set $1 package default paper size to $papersize in $gvfile"
fi
;;
lout)
loutfile=@LOCALBASE@/share/lout/include/dsf
if [ -s "$loutfile" ]; then
@MV@ $loutfile $loutfile.old
env PAPERSIZE=$papersize @AWK@ '$1 == "named" && $2 == "@PageType" { printf(" %s %s\t\t{ %s\t%s %s # page type (width, height)\n", $1, $2, ENVIRON["PAPERSIZE"], $5, $6); next } { print $0 }' $loutfile.old > $loutfile
@ECHO@ "Set $1 package default paper size to $papersize in $loutfile"
fi
;;
magicfilter)
magicdir=@LOCALBASE@/libexec/magicfilter
if [ -s "$magicdir" ]; then
for f in $magicdir/*-filter; do
@MV@ $f $f.old
@SED@ -e 's|-sPAPERSIZE=[a-zA-Z0-9_]*|-sPAPERSIZE='$lowpaper'|' $f.old > $f && @RM@ $f.old
@CHMOD@ 555 $f
done
@ECHO@ "Set $1 package default paper size to $papersize in $magicdir/*-filter"
fi
;;
psutils)
psutilsfile=@PKG_SYSCONFDIR@/psutils.cfg
if [ -s "$psutilsfile" ]; then
@MV@ $psutilsfile $psutilsfile.old
@SED@ -e 's|^PAPERSIZE.*|PAPERSIZE='$lowpaper'|' $psutilsfile.old > $psutilsfile && @RM@ $psutilsfile.old
@ECHO@ "Set $1 package default paper size to $papersize in $psutilsfile"
fi
;;
*)
@ECHO@ "Warning: Package $1 not recognised"
;;
esac
shift 1
done
exit 0
|