3 # postinst script for the Debian GNU/Linux lilypond package
5 # by Anthony Fok <foka@gpu.srv.ualberta.ca>
6 # Initial release: Sun, 26 Oct 1997 03:23:00 -0700
7 # Last modified: Mon, 10 Nov 1997 22:26:10 -0700
12 my ($package, $pkg_name, $font_supplier, $font_typeface, $std_TEXMF, $TEXMF,
13 $TEXINPUTS, $MFINPUTS, $TFMFONTS, @fonts);
15 sub correct_opus_fonts ($$);
16 sub check_texmfcnf ();
18 sub add_fonts ($$$$@);
19 sub check_specialmap ();
24 #######################
26 #######################
28 $package = "lilypond"; # This is used for filenames! Don't change it!
29 $pkg_name = "GNU LilyPond";
31 $font_supplier = "public";
32 $font_typeface = "lilypond";
33 # @fonts = qw( dyn10 font-en-tja vette-beam );
36 $std_TEXMF = "/usr/lib/texmf"; # Debian's standard $TEXMF
37 $TEXINPUTS = "$std_TEXMF/tex/$package//";
38 $MFINPUTS = "$std_TEXMF/fonts/source/$font_supplier/$font_typeface//";
39 $TFMFONTS = "$std_TEXMF/fonts/tfm/$font_supplier/$font_typeface//";
42 #######################
44 #######################
46 #----- Fix Opus font entries in special.map (called by check_specialmap()) ---
47 # I goofed up the Opus font entries in special.map, hence this fix.
48 # Note: This is a temporary fix. Consider removing this in 1998. ^_^
50 sub correct_opus_fonts ($$) {
51 my $specialmap = $_[1];
52 my $supplier = "opustex";
53 my $typeface = "opus";
54 my @opusfonts = qw( opus opusline opusnum opussps osl );
58 if ($_[0] =~ /(^\w+\s+public\s+$typeface\n)+/m) {
59 print " Correcting old font entries ...";
60 foreach $font (@opusfonts) {
61 if (length($font) < 8) { $font .= "\t"; }
62 $entries .= "$font\t$supplier\t\t$typeface\n";
65 ($_[0] =~ s/(^\w+\s+public\s+$typeface\n)+/$entries/m)
66 or die " Can't correct font entries in $specialmap: $!";
68 system(": \${MAKETEXDIR=$TEXMF/maketex}; " .
69 "test -r \$MAKETEXDIR/maketex.site && . \$MAKETEXDIR/maketex.site; " .
70 ": \${MT_DESTROOT=$TEXMF/fonts}; " .
71 "rm -rf \$MT_DESTROOT/pk/*/public/$typeface");
80 #-------------------- Check/Modify texmf.cnf for custom teTeX installation ---
81 # Edit texmf.cnf to add search path /usr/lib/texmf
82 # for non-Debian teTeX installation
84 sub check_texmfcnf () {
87 print "\n You have a custom teTeX installation in $TEXMF.\n";
89 chop($texmfcnf = `kpsewhich cnf texmf.cnf`);
91 if ($? == 0 and $texmfcnf ne "") {
93 my $new = "$texmfcnf.new";
94 my $bak = "$texmfcnf.bak";
96 open(OLD, "< $texmfcnf") or die " Can't open $texmfcnf for reading: $!";
99 if ($filebuf = <OLD>) {
100 if ($filebuf =~ /^(TEXMFL.*)$/m) {
102 if ($line =~ /TEXMFL\s*=.*$std_TEXMF/) {
103 print " Found $std_TEXMF in \$TEXMFL. Leaving $texmfcnf untouched.\n";
105 print " Adding $std_TEXMF to \$TEXMFL, updating $texmfcnf ...";
107 $filebuf =~ s/^(TEXMFL\s*=\s*\S*)/$1,$std_TEXMF/m;
108 open(NEW, "> $new") or die "\n Can't open $new for writing: $!";
109 (print NEW $filebuf) or die "\n Can't write to $new: $!";
111 copy($texmfcnf, $bak) or die "\n Can't backup $texmfcnf: $!";
112 rename($new, $texmfcnf)
113 or ( copy($new, $texmfcnf), unlink($new) )
114 or die "\n Can't update $texmfcnf: $!";
120 warn " ** Can't read from $texmfcnf: $!\n";
121 warn " ** Please verify the content of $texmfcnf!\n";
128 warn " ** Can't find texmf.cnf!\n";
129 warn " ** Please add $std_TEXMF to \$TEXMFL in your texmf.cnf.\n";
134 #------------------------------------------------------------- Run texhash ---
137 print " Running texhash to update $TEXMF/ls-R ...\n";
139 if ( `which texhash` and -e "$TEXMF/ls-R" ) {
142 warn " Error: texhash or $TEXMF/ls-R not found!\n";
147 #---------- Add font entries to special.map (called by check_specialmap()) ---
149 sub add_fonts ($$$$@) {
150 my ($specialmap, $supplier, $typeface, $fonts) = @_[1..4];
153 foreach $font (@fonts) {
154 if (length($font) < 8) { $font .= "\t"; }
155 $entries .= "$font\t$supplier\t\t$typeface\n";
157 if ($_[0] !~ /$entries/m) {
158 ($_[0] =~ s/(^\w+\s+$supplier\s+$typeface\n)+/$entries/m)
159 or ($_[0] =~ s/(?=^beam\s+public\s+music\n)/$entries/m)
160 or die " Can't add font entries to $specialmap: $!";
167 #---------------------------------- Check special.map and add font entries ---
169 sub check_specialmap () {
171 my $specialmap = "$TEXMF/fontname/special.map";
172 my $new = "$specialmap.new";
173 my $bak = "$specialmap.bak";
175 print " Checking font entries in $specialmap ...\n";
177 open(OLD, "< $specialmap") or die " Can't open $specialmap for reading: $!";
179 if ($fontmap = <OLD>) {
180 if (correct_opus_fonts($fontmap, $specialmap) |
181 add_fonts($fontmap, $specialmap, $font_supplier, $font_typeface, @fonts))
183 print " Adding $pkg_name font entries to $specialmap ...\n";
184 open(NEW, "> $new") or die " Can't open $new for writing: $!";
185 (print NEW $fontmap) or die " Can't write to $new: $!";
187 copy($specialmap, $bak) or die " Can't backup $specialmap: $!";
188 rename($new, $specialmap)
189 or ( copy($new, $specialmap), unlink($new) )
190 or die " Can't update $specialmap: $!";
192 print " Entries okay. Leaving $specialmap untouched.\n";
197 warn " ** Can't read from $specialmap: $!\n";
198 warn " ** Please verify the content of $specialmap!\n";
208 #######################
210 #######################
212 print " Checking teTeX directory \$TEXMF ...";
214 chop($TEXMF = `kpsetool -v '\$TEXMF'`);
216 if ($? == 0 and $TEXMF ne "") {
219 warn "\n Error: kpsetool not found or \$TEXMF not set!\n";
220 warn " Assuming \$TEXMF=$std_TEXMF\n";
223 warn " ... but directory '$TEXMF' does not exist either!\n";
224 die " Please check your teTeX configuration.\n"
228 if ($TEXMF ne $std_TEXMF) {
237 print " $pkg_name configuration completed.\n";
238 print " Please read /usr/doc/$package/README.debian to get started.\n";