summaryrefslogtreecommitdiff
path: root/Master/texmf
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-05-28 16:21:55 +0000
committerKarl Berry <karl@freefriends.org>2011-05-28 16:21:55 +0000
commit17e3eae9f693475468e090c55f106c423ec825e3 (patch)
treed4bf7e5b69f279c73af727f4fda06990b4b4a087 /Master/texmf
parent6f5e1eb0cdd9cd391acef2c72629225245cb675f (diff)
update to new version
git-svn-id: svn://tug.org/texlive/trunk@22640 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rwxr-xr-xMaster/texmf/scripts/tetex/updmap.pl888
1 files changed, 473 insertions, 415 deletions
diff --git a/Master/texmf/scripts/tetex/updmap.pl b/Master/texmf/scripts/tetex/updmap.pl
index 3b8a8a9e7c9..407bac9e082 100755
--- a/Master/texmf/scripts/tetex/updmap.pl
+++ b/Master/texmf/scripts/tetex/updmap.pl
@@ -1,58 +1,49 @@
-#!/usr/bin/env perl
+#! /usr/bin/env perl
###############################################################################
# updmap: utility to maintain map files for outline fonts.
#
-# Thomas Esser, (C) 2002. Public domain.
+# Thomas Esser, (C) 2002.
# Fabrice Popineau, for the Perl version.
-#
-# Commands:
-# --edit edit config file
-# --help show help message
-#
-# Options:
-# --cnffile file specify configuration file
-# --dvipsoutputdir directory specify output directory (dvips syntax)
-# --pdftexoutputdir directory specify output directory (pdftex syntax)
-# --dvipdfmoutputdir directory specify output directory (dvipdfm syntax)
-# --outputdir directory specify output directory (for all files)
-# --quiet reduce verbosity
-###############################################################################
-#$^W=1;
-
-require "newgetopt.pl";
-use strict;
-
-# my $IsWin32 = ($^O =~ /MSWin32/i);
+# Anyone may freely use, modify, and/or distribute this file, without
+# limitation.
+###############################################################################
+# $Id: updmap.pl 21946 2011-04-04 00:16:58Z karl $
+BEGIN {
+ $^W=1;
+ chomp($TEXMFROOT = `kpsewhich -var-value=TEXMFROOT`);
+ unshift (@INC, "$TEXMFROOT/tlpkg");
+}
-# if ($IsWin32) {
-# use Win32::Registry;
-# use Win32::API;
-# }
+my $version = '$Id: updmap.pl 21946 2011-04-04 00:16:58Z karl $';
+use strict;
+use TeXLive::TLUtils qw(mkdirhier mktexupd win32);
+use Getopt::Long;
+$Getopt::Long::autoabbrev=0;
+Getopt::Long::Configure ("bundling");
-my $progname;
+my $progname='updmap';
my $cnfFile;
my $cnfFileShort;
my $outputdir;
my $dvipsoutputdir;
my $pdftexoutputdir;
-my $dvipdfmoutputdir;
my $quiet;
-my $texhashEnabled;
-my $mkmapEnabled;
+my $nohash;
+my $nomkmap;
-my %enableItem = ();
+my $enableItem;
my %setOption = ();
my @showoptions = ();
my @disableItem = ();
my $listmaps;
-my $needsCleanup;
+my $listavailablemaps;
+my $syncwithtrees;
my $verbose;
-my $debug;
my $opt_edit;
my $opt_help;
-
+my $dry_run;
my $TEXMFMAIN;
my $TEXMFVAR;
@@ -60,14 +51,25 @@ my $mode;
my $dvipsPreferOutline;
my $dvipsDownloadBase35;
my $pdftexDownloadBase14;
-my $dvipdfmDownloadBase14;
my $dvips35;
my $pdftex35;
-my $dvipdfm35;
my $ps2pk35;
-my @cfg = ( );
+my $newcnf;
+my %link;
+my %maps;
+my @missing;
+my $writelog = 0;
+my $cache = 0; # don't change!
+my $copy;
+my $pdftexStripEnc=1;
+
+# initialize mktexupd
+my $updLSR=&mktexupd();
+$updLSR->{mustexist}(0);
+
+my @cfg = ();
my @psADOBE = (
's/ URWGothicL-Demi / AvantGarde-Demi /x',
@@ -190,7 +192,7 @@ my @fileADOBE = (
's/\buagko8a.pfb\b/agwo____.pfb/x',
's/\bubkd8a.pfb\b/bkd_____.pfb/x',
's/\bubkdi8a.pfb\b/bkdi____.pfb/x',
- 's/\bubkl8a.pfb\b/bkl_____.pfb/x',
+ 's/\bubkl8a.pfb\b/bkl_____.pfb/x',
's/\bubkli8a.pfb\b/bkli____.pfb/x',
's/\bucrb8a.pfb\b/cob_____.pfb/x',
's/\bucrbo8a.pfb\b/cobo____.pfb/x',
@@ -222,61 +224,26 @@ my @fileADOBE = (
);
&main;
-
exit 0;
-# if ($IsWin32) {
-
-# sub GetTempPath {
-# my $GetTempPath = new Win32::API('kernel32', 'GetTempPath', 'NP', 'N');
-# if(not defined $GetTempPath) {
-# die "Can't import API GetTempPath: $!\n";
-# }
-# my $lpBuffer = " " x 260;
-
-# $GetTempPath->Call(80, $lpBuffer);
-# }
-
-# sub ShellExecute {
-# my ($command, $file) = @_;
-# my $ShellExecute = new Win32::API('shell32', 'ShellExecute', 'NPPPPN', 'N');
-# if(not defined $ShellExecute) {
-# die "Can't import API ShellExecute: $!\n";
-# }
-# $ShellExecute->Call(0, $command, $file, '', '', 0);
-# }
-
-# sub GetHomeDir {
-# my $home = $ENV{'HOME'};
-# # Should check for CSIDL_...
-# return $home;
-# }
-# }
-
-
###############################################################################
-# mkdirhier(directory)
-# create a directory and parent directories as needed
+# progname()
+# return the name of the program. Needed if invoked by a wrapper.
###############################################################################
-sub mkdirhier {
- my $tree=shift;
- my $mode=shift;
- my $subdir;
-
- return if (-d $tree);
- my @dirs=split /\//, $tree;
- foreach my $dir (@dirs) {
- $subdir .= ("$dir" . "/");
- unless (-d $subdir) {
- if (defined $mode) {
- mkdir ("$subdir", $mode) or die "Can't mkdir '$subdir': $!.\n";
- } else {
- mkdir "$subdir" or die "Can't mkdir '$subdir': $!.\n";
- }
- }
+sub progname {
+ if (`kpsewhich --var-value=TEXMFVAR` eq `kpsewhich --var-value=TEXMFSYSVAR`) {
+ return 'updmap-sys';
+ } else {
+ return 'updmap';
}
}
+# return program name + version string.
+sub version {
+ my $ret = sprintf "%s version %s", &progname(), $version;
+ return $ret;
+}
+
###############################################################################
# equalize_file(filename[, comment_char])
# read a file and return its processed content as a string.
@@ -301,7 +268,6 @@ sub equalize_file {
return join('X', sort(@temp));
}
-
###############################################################################
# files_are_different(file_A, file_B[, comment_char])
# compare two equalized files.
@@ -318,7 +284,6 @@ sub files_are_different {
return $retval;
}
-
###############################################################################
# files_are_equal(file_A, file_B[, comment_char])
# compare two equalized files. Same as files_are_different() with
@@ -328,6 +293,25 @@ sub files_are_equal {
return (&files_are_different (@_))? 0:1;
}
+###############################################################################
+# files_are_identical(file_A, file_B)
+# compare two files. Same as cmp(1).
+###############################################################################
+sub files_are_identical {
+ my $file_A=shift;
+ my $file_B=shift;
+ my $retval=0;
+
+ open IN, "$file_A";
+ my $A=(<IN>);
+ close IN;
+ open IN, "$file_B";
+ my $B=(<IN>);
+ close IN;
+
+ $retval=1 if ($A eq $B);
+ return $retval;
+}
###############################################################################
# getLines()
@@ -337,9 +321,26 @@ sub getLines {
my @lines = ();
foreach my $fname (@_) {
next if (! $fname);
- open FILE, "<$fname" or die "can't get lines from $fname: $!";
- push @lines, <FILE>;
- close FILE;
+ if (! exists $maps{"$fname"}) {
+ open FILE, "<$fname" or die "can't get lines from $fname: $!";
+ my @file=<FILE>;
+ close FILE;
+ if ($writelog) {
+ print LOG ("\n$fname:\n");
+ foreach my $line (@file) {
+ next if $line =~ /^\s*%/; # comment
+ next if $line =~ /^\s*#/; # comment
+ next if $line =~ /^\s*$/; # empty line
+ my $tfm;
+ ($tfm)=split ' ', $line;
+ print LOG "$tfm\n";
+ }
+ }
+ $maps{"$fname"} = [ @file ] if ($cache);
+ push @lines, @file;
+ } else {
+ push @lines, @{$maps{"$fname"}};
+ }
}
chomp @lines;
return @lines;
@@ -363,6 +364,9 @@ sub writeLines {
###############################################################################
sub copyFile {
my ($src, $dst) = @_;
+ my $dir;
+ ($dir=$dst)=~s/(.*)\/.*/$1/;
+ mkdirhier $dir;
$src eq $dst && return "can't copy $src to itself!\n";
@@ -379,74 +383,74 @@ sub copyFile {
}
###############################################################################
-# start_redirection(), stop_redirection()
-# redirects stdout and stderr to log file (possibly "nul")
-###############################################################################
-sub start_redirection {
- my ($log) = @_;
-
- # start redirection if asked
- if ($log) {
- open(SO, ">&STDOUT");
- open(SE, ">&STDERR");
-
- close(STDOUT);
- close(STDERR);
-
- open(STDOUT, ">$log");
- open(STDERR,">&STDOUT");
-
- select(STDERR); $| = 1;
- select(STDOUT); $| = 1;
- }
-}
-
-sub stop_redirection {
- close(STDOUT);
- close(STDERR);
- open(STDOUT, ">&SO");
- open(STDERR, ">&SE");
-}
-
-###############################################################################
# help()
# display help message and exit
###############################################################################
sub help {
- print "Usage: $0 [option] ... [command]\n";
- print "\n";
- print "Valid options:\n";
- print " --cnffile file specify configuration file\n";
- print " --dvipsoutputdir directory specify output directory (dvips syntax)\n";
- print " --pdftexoutputdir directory specify output directory (pdftex syntax)\n";
- print " --dvipdfmoutputdir directory specify output directory (dvipdfm syntax)\n";
- print " --outputdir directory specify output directory (for all files)\n";
- print " --nohash do not run texhash\n";
- print " --nomkmap do not recreate map files\n";
- print " --quiet reduce verbosity\n";
- print "\n";
- print "Valid commands:\n";
- print " --edit edit updmap.cfg file\n";
- print " --help show this message\n";
- print " --showoptions item show alternatives for options\n";
- print " --setoption option=value set option where option is one\n";
- print " of dvipsPreferOutline, LW35, dvipsDownloadBase35\n";
- print " or pdftexDownloadBase14\n";
- print " --enable maptype=mapfile add or enable a Map or MixedMap\n";
- print " --disable mapfile disable Map or MixedMap for mapfile\n";
- print " --listmaps list all active and inactive maps\n";
+ my $progname=&progname();
+ my $usage= <<"EOF";
+Usage: $progname [option] ... [command]
+
+Update the default font map files used by pdftex, dvips, and dvipdfm, as
+determined by updmap.cfg (the one returned by running "kpsewhich
+updmap.cfg").
+
+Among other things, these font map files are used to determine which
+fonts should be used as bitmaps and which as outlines, and to determine
+which fonts are included in the output.
+
+By default, the TeX filename database is also rebuilt (with mktexlsr).
+
+Valid options:
+ --cnffile FILE read FILE for the updmap configuration
+ --dvipsoutputdir DIR specify output directory (dvips syntax)
+ --pdftexoutputdir DIR specify output directory (pdftex syntax)
+ --outputdir DIR specify output directory (for all files)
+ --copy cp generic files rather than using symlinks
+ --nomkmap do not recreate map files
+ --nohash do not run texhash
+ -n, --dry-run only show the configuration, no output
+ --quiet reduce verbosity
+
+Valid commands:
+ --help show this message
+ --edit edit updmap.cfg file
+ --showoptions ITEM show alternatives for options
+ --setoption OPTION VALUE set option, where OPTION is one of:
+ dvipsPreferOutline, LW35, dvipsDownloadBase35,
+ or pdftexDownloadBase14
+ --setoption OPTION=VALUE see above, just different syntax
+ --enable MAPTYPE MAPFILE add "MAPTYPE MAPFILE" to updmap.cfg,
+ where MAPTYPE is either Map or MixedMap
+ --enable Map=MAPFILE add \"Map MAPFILE\" to updmap.cfg
+ --enable MixedMap=MAPFILE add \"MixedMap MAPFILE\" to updmap.cfg
+ --disable MAPFILE disable MAPFILE, whether Map or MixedMap
+ --syncwithtrees entries with unavailable map files will be
+ disabled in the config file
+ --listmaps list all active and inactive maps
+ --listavailablemaps same as --listmaps, but without
+ unavailable map files
+
+Explanation of the map types: the (only) difference between Map and
+MixedMap is that MixedMap entries are not added to psfonts_pk.map. The
+purpose is to help users with printers that render Type 1 outline fonts
+worse than mode-tuned Type 1 bitmap fonts. So MixedMap is used for
+fonts that are available as both Type 1 and Metafont.
+
+To see the precise locations of the various files that will be read and
+written, run updmap -n.
+
+For step-by-step instructions on making new fonts known to TeX, see
+http://tug.org/fonts/fontinstall.html.
+
+Report bugs to: tex-k\@tug.org
+TeX Live home page: <http://tug.org/texlive/>
+EOF
+;
+ print $usage;
exit 0;
}
-###############################################################################
-# abort(errmsg)
-# print `errmsg' to stderr and exit with error code 1
-###############################################################################
-sub abort {
- my ($msg) = @_;
- print STDERR "$progname: $msg\n";
- exit 1;
-}
###############################################################################
# cfgval(variable)
@@ -464,12 +468,11 @@ sub cfgval {
for my $line (@cfg) {
if ($line =~ m/^\s*${variable}[\s=]+(.*)\s*$/) {
$value = $1;
- print "$variable => " . $value . "\n";
if ($value =~ m/^(true|yes|t|y|1)$/) {
- $value = 1;
+ $value = 1;
}
elsif ($value =~ m/^(false|no|f|n|0)$/) {
- $value = 0;
+ $value = 0;
}
last;
}
@@ -478,19 +481,35 @@ sub cfgval {
}
###############################################################################
+# SymlinkOrCopy(dir, src, dest)
+# create symlinks if possible, otherwise copy files
+###############################################################################
+sub SymlinkOrCopy {
+ my ($dir, $src, $dest) = @_;
+ if (&win32 || $copy) { # always copy
+ &copyFile("$dir/$src", "$dir/$dest");
+ } else { # symlink if supported by fs, copy otherwise
+ system("cd \"$dir\" && ln -s $src $dest 2>/dev/null || "
+ . "cp -p \"$dir/$src\" \"$dir/$dest\"");
+ }
+ # remember for "Files generated" in &mkMaps.
+ $link{"$dest"}="$src";
+}
+
+###############################################################################
# setupSymlinks()
# set symlink for psfonts.map according to dvipsPreferOutline variable
###############################################################################
sub setupSymlinks {
my $src;
- if ($dvipsPreferOutline ) {
+ if ($dvipsPreferOutline) {
$src = "psfonts_t1.map";
} else {
$src = "psfonts_pk.map";
}
unlink "$dvipsoutputdir/psfonts.map";
- &copyFile("$dvipsoutputdir/$src", "$dvipsoutputdir/psfonts.map");
+ &SymlinkOrCopy("$dvipsoutputdir", "$src", "psfonts.map");
if ($pdftexDownloadBase14) {
$src = "pdftex_dl14.map";
@@ -498,15 +517,7 @@ sub setupSymlinks {
$src = "pdftex_ndl14.map";
}
unlink "$pdftexoutputdir/pdftex.map";
- &copyFile("$pdftexoutputdir/$src", "$pdftexoutputdir/pdftex.map");
-
- if ($dvipdfmDownloadBase14) {
- $src = "dvipdfm_dl14.map";
- } else {
- $src = "dvipdfm_ndl14.map";
- }
- unlink "$dvipdfmoutputdir/dvipdfm.map";
- &copyFile("$dvipdfmoutputdir/$src", "$dvipdfmoutputdir/dvipdfm.map");
+ &SymlinkOrCopy("$pdftexoutputdir", "$src", "pdftex.map");
}
###############################################################################
@@ -542,13 +553,10 @@ sub transLW35 {
# apply kpsewhich with format 'web2c files'
###############################################################################
sub locateWeb2c {
-
my @files = @_;
-
return @files if ($#files < 0);
@files = split (/\n/, `kpsewhich --format="web2c files" @files`);
-
if (wantarray) {
return @files;
}
@@ -562,13 +570,18 @@ sub locateWeb2c {
# apply kpsewhich with format 'dvips config'
###############################################################################
sub locateMap {
- my @files = @_;
+ my @maps = @_;
+ my @files;
- chomp @files;
- return @files if ($#files < 0);
+ chomp @maps;
+ return @maps if ($#maps < 0);
- @files = `kpsewhich --format=map @files`;
+ @files = `kpsewhich --format=map @maps`;
chomp @files;
+
+ foreach my $map (@maps) {
+ push @missing, $map if (! grep /\/$map$/, @files);
+ }
if (wantarray) {
return @files;
}
@@ -589,7 +602,7 @@ sub catMaps {
my @maps = grep { $_ =~ m/$map/ } @cfg;
map{
$_ =~ s/\#.*//;
- $_ =~ s/\s*([^\s]*)\s*([^\s]*)/\2/;
+ $_ =~ s/\s*([^\s]*)\s*([^\s]*)/$2/;
} @maps;
@maps = sort(@maps);
@maps = grep { ++$count{$_} < 2; } @maps;
@@ -627,22 +640,19 @@ sub setOption {
my ($opt, $val) = @_;
if ($opt eq "LW35") {
- if ($val !~ m/^(URWkb|URW|ADOBE|ADOBEkb)$/) {
- printf STDERR "invalid value $val for option $opt\n";
- exit 1;
- }
+ if ($val !~ m/^(URWkb|URW|ADOBE|ADOBEkb)$/) {
+ die "Invalid value $val for option $opt.\n";
+ }
}
- elsif ($opt =~ m/^(dvipsPreferOutline|dvipsDownloadBase35|pdftexDownloadBase14|dvipdfmDownloadBase14)$/) {
+ elsif ($opt =~
+ m/^(dvipsPreferOutline|dvipsDownloadBase35|pdftexDownloadBase14)$/) {
if ($val !~ m/^(true|false)$/) {
- printf STDERR "invalid value $val for option $opt\n";
- exit 1;
+ die "invalid value $val for option $opt.\n";
}
}
else {
- printf STDERR "unsupported option $opt\n";
- exit 1;
+ die "Unsupported option $opt.\n";
}
-
&configReplace("$cnfFile", "^" . "$opt" . "\\s", "$opt $val");
}
@@ -654,8 +664,7 @@ sub enableMap {
my ($type, $map) = @_;
if ($type !~ m/^(Map|MixedMap)$/) {
- printf STDERR "invalid mapType $type\n";
- exit 1;
+ die "updmap: Invalid mapType $type\n";
}
# a map can only have one type, so we carefully disable everything
# about map here:
@@ -671,14 +680,13 @@ sub enableMap {
###############################################################################
sub disableMap {
my ($map) = @_;
- my %count = ( );
+ my %count = ();
my $type;
my @mapType = grep {
my @fields = split;
- if ($fields[0] =~ /^(MixedMap|Map)$/
- and $fields[1] eq $map
- and ++$count{$fields[0]}) {
+ if ($fields[0] and $fields[0] =~ /^(MixedMap|Map)$/
+ and $fields[1] eq $map and ++$count{$fields[0]}) {
$_ = $fields[0];
}
else {
@@ -697,30 +705,14 @@ sub disableMap {
###############################################################################
sub initVars {
$progname="updmap";
-
$quiet = 0;
- $texhashEnabled = 1;
- $mkmapEnabled = 1;
+ $nohash = 0;
+ $nomkmap = 0;
$verbose = 1;
- $needsCleanup = 0;
-
$cnfFile = "";
$cnfFileShort = "updmap.cfg";
$outputdir = "";
- $TEXMFMAIN =`kpsewhich --expand-var="\$TEXMFMAIN"`;
- chomp($TEXMFMAIN);
- # tmpdir=${TMP-/tmp}/$progname.$$
- # tmp1=$tmpdir/a
- # tmp2=$tmpdir/b
- # tmp3=$tmpdir/c
-}
-
-###############################################################################
-# setupTmpDir()
-# set up a temp directory and a trap to remove it
-###############################################################################
-sub setupTmpDir {
-
+ chomp($TEXMFMAIN =`kpsewhich --var-value=TEXMFMAIN`);
}
###############################################################################
@@ -728,20 +720,19 @@ sub setupTmpDir {
# show Options for an item
###############################################################################
sub showOptions {
-
foreach my $item (@_) {
if ($item eq "LW35") {
print "URWkb URW ADOBE ADOBEkb\n";
}
- elsif ($item =~ m/(dvipsPreferOutline|pdftexDownloadBase14|dvipdfmDownloadBase14|dvipsDownloadBase35)/) {
+ elsif ($item =~
+ m/(dvipsPreferOutline|pdftexDownloadBase14|dvipsDownloadBase35)/) {
print "true false\n";
}
else {
- print "Unknown item \"$item\". Choose one of LW35, dvipsPreferOutline, dvipsDownloadBase35, pdftexDownloadBase14 or dvipdfmDownloadBase14\n";
-# exit 1;
+ print "Unknown item \"$item\". Choose one of LW35, dvipsPreferOutline,\n"
+ . " dvipsDownloadBase35, or pdftexDownloadBase14\n";
}
}
-
exit 0
}
@@ -758,53 +749,24 @@ sub setupOutputDir {
my $rel = "fonts/map/$driver/updmap";
my $tf;
# Try TEXMFVAR tree. Use it if variable is set and $rel can
- # be written. Copy config file if it does not exist there.
- if ($^O=~/^MSWin(32|64)$/) {
- $tf = `kpsewhich --expand-var="\$TEXMFVAR"`;
- } else {
- $tf = `kpsewhich --expand-var="\\\$TEXMFVAR"`;
- }
- chomp($tf);
+ # be written.
+ chomp($tf = `kpsewhich --var-value=TEXMFVAR`);
if ($tf) {
&mkdirhier("$tf/$rel");
- # system("$TEXMFMAIN/web2c/mktexdir \"$tf/$rel\"");
- if (! -d "$tf/$rel" || ! -w "$tf/$rel") {
- # forget about TEXMFVAR tree...
- $tf = "";
+ if (! -w "$tf/$rel") {
+ die "Directory \"$tf/$rel\" isn't writable.\n";
}
}
-
- # Try something relative to config file, fall back to $TEXMFMAIN.
- if (! $tf) {
- $tf = $cnfFile;
- if ($tf =~ m@/web2c/[^/]*$@) {
- $tf =~ s@/web2c/[^/]*$@@;
- }
- else {
- $tf = "";
- }
- $tf = $TEXMFMAIN if (! $tf);
- }
-
$od = "$tf/$rel";
}
-
- # No need to call mktexdir !
- # system("$TEXMFMAIN/bin/win32/mktexdir \"$od\"");
&mkdirhier($od);
- &abort("output directory `$od' does not exist\n") if (! -d $od);
- &abort("output directory `$od' is not writable\n") if (! -w $od);
- print "using $driver output directory `$od'\n";
-
+ print "$driver output dir: \"$od\"\n" if (! $quiet);
return $od;
}
sub setupDestDir {
-
$dvipsoutputdir = &setupOutputDir($dvipsoutputdir, "dvips");
$pdftexoutputdir = &setupOutputDir($pdftexoutputdir, "pdftex");
- $dvipdfmoutputdir = &setupOutputDir($dvipdfmoutputdir, "dvipdfm");
-
}
###############################################################################
@@ -812,81 +774,74 @@ sub setupDestDir {
# find config file if none specified on cmd line.
###############################################################################
sub setupCfgFile {
-
if (! $cnfFile) {
- my $tf = `kpsewhich -expand-var="\$TEXMFVAR"`;
+ my $tf = `kpsewhich --var-value=TEXMFCONFIG`;
chomp($tf);
if ($tf && ! -f "$tf/web2c/$cnfFileShort") {
&mkdirhier("$tf/web2c") if (! -d "$tf/web2c");
-# &start_redirection("nul");
-# system("mktexdir $tf/web2c");
-# &stop_redirection;
if (-d "$tf/web2c" && -w "$tf/web2c") {
- unlink "$tf/web2c/$cnfFileShort";
- &copyFile("$TEXMFMAIN/web2c/$cnfFileShort", "$tf/web2c/$cnfFileShort");
- &start_redirection("nul");
- system("mktexupd $tf/web2c $cnfFileShort");
- &stop_redirection;
+ unlink "$tf/web2c/$cnfFileShort";
+ my $original_cfg=`kpsewhich updmap.cfg`;
+ chomp($original_cfg);
+ print("copy $original_cfg => $tf/web2c/$cnfFileShort\n") if (! $quiet);
+ $newcnf="$tf/web2c/$cnfFileShort";
+ &copyFile("$original_cfg", "$tf/web2c/$cnfFileShort");
+ $updLSR->{add}("$tf/web2c/$cnfFileShort");
}
}
-
- $cnfFile = &locateWeb2c("updmap.cfg");
+ $cnfFile = "$tf/web2c/updmap.cfg";
if ($cnfFile) {
- print "using config file $cnfFile\n" if (! $quiet);
+ print "Config file: \"$cnfFile\"\n" if (! $quiet);
}
else {
- &abort("config file updmap.cfg not found");
+ die "Config file updmap.cfg not found.\n";
}
}
}
-
###############################################################################
# processOptions()
# process cmd line options
###############################################################################
sub processOptions {
-
- unless (&NGetOpt ("quiet" => \$quiet,
- "cnffile=s" => \$cnfFile,
- "outputdir=s" => \$outputdir,
- "dvipsoutputdir=s" => \$dvipsoutputdir,
- "pdftexoutputdir=s" => \$pdftexoutputdir,
- "dvipdfmoutputdir=s" => \$dvipdfmoutputdir,
- "setoption=s" => \%setOption,
- "enable=s" => \%enableItem,
- "disable=s" => \@disableItem,
- "edit" => \$opt_edit,
- "listmaps" => \$listmaps,
- "showoptions=s" => \@showoptions,
- "hash!" => \$texhashEnabled,
- "mkmap!" => \$mkmapEnabled,
- "verbose" => \$verbose,
- "debug" => \$debug,
- "help" => \$opt_help)) {
- print STDERR "Try `$0 --help'";
- exit 1;
+ unless (&GetOptions (
+ "q|quiet" => \$quiet,
+ "cnffile=s" => \$cnfFile,
+ "outputdir=s" => \$outputdir,
+ "dvipsoutputdir=s" => \$dvipsoutputdir,
+ "pdftexoutputdir=s" => \$pdftexoutputdir,
+ "setoption=s" => \%setOption,
+ "enable=s" => \$enableItem,
+ "disable=s" => \@disableItem,
+ "e|edit" => \$opt_edit,
+ "l|listmaps" => \$listmaps,
+ "listavailablemaps" => \$listavailablemaps,
+ "syncwithtrees" => \$syncwithtrees,
+ "showoptions=s" => \@showoptions,
+ "nohash" => \$nohash,
+ "nomkmap" => \$nomkmap,
+ "version" => sub { print &version() . "\n"; exit(0) },
+
+ "n|dry-run" => \$dry_run,
+ "copy" => \$copy,
+ "h|help" => \$opt_help)) {
+ my $progname=&progname();
+ die "Try \"$progname --help\".\n";
}
if ($outputdir) {
$dvipsoutputdir = $outputdir if (! $dvipsoutputdir);
$pdftexoutputdir = $outputdir if (! $pdftexoutputdir);
- $dvipdfmoutputdir = $outputdir if (! $dvipdfmoutputdir);
}
if ($cnfFile && ! -f $cnfFile) {
- &abort("config file `$cnfFile' not found");
+ die "Config file \"$cnfFile\" not found.\n";
}
-
if ($dvipsoutputdir && ! -d $dvipsoutputdir) {
- &abort("dvips output directory `$dvipsoutputdir' not found");
+ &mkdirhier ($dvipsoutputdir);
}
if ($pdftexoutputdir && ! -d $pdftexoutputdir) {
- &abort("pdftex output directory `$pdftexoutputdir' not found");
- }
- if ($dvipdfmoutputdir && ! -d $dvipdfmoutputdir) {
- &abort("dvipdfm output directory `$dvipdfmoutputdir' not found");
+ &mkdirhier ($pdftexoutputdir);
}
-
}
###############################################################################
@@ -894,11 +849,42 @@ sub processOptions {
# list all maps mentioned in the config file
###############################################################################
sub listMaps {
+ my $what=shift;
+ my @mapfiles;
+ my @paths;
+
my @lines = grep {
- $_ =~ m/^(\#! *)?(Mixed)?Map/
+ if ($what eq 'sync') {
+ $_ =~ m/^(Mixed)?Map/
+ } else {
+ $_ =~ m/^(\#! *)?(Mixed)?Map/
+ }
} &getLines($cnfFile);
- map { print "$_\n"; } @lines;
-# &writeLines("con", @lines);
+
+ if ($what eq 'list') {
+ # --listmaps
+ map { print "$_\n"; } @lines;
+ } else {
+ @mapfiles=grep { $_ =~ s/^(\#! *)?(Mixed)?Map\s+// } @lines;
+ @paths=&locateMap(@mapfiles);
+
+ if ($what eq 'avail') {
+ # --listavailablemaps
+ map {
+ my $entry="$_";
+ # print "$entry\n" if (grep { $_ =~ m/\/$entry/ } @paths);
+ } @lines;
+ } elsif ($what eq 'sync') {
+ # --syncwithtrees
+ map {
+ my $entry="$_";
+ unless (grep { $_ =~ m/$entry/ } @paths) {
+ &disableMap($entry);
+ print " $entry disabled\n" if (! $quiet);
+ }
+ } @lines;
+ }
+ }
}
###############################################################################
@@ -915,7 +901,7 @@ sub normalizeLines {
@lines = grep { $_ !~ m/^\s*$/x } @lines;
map { $_ =~ s/\s$//x ;
$_ =~ s/\s*\"\s*/ \" /gx;
- $_ =~ s/\" ([^\"]*) \"/\"\1\"/gx;
+ $_ =~ s/\" ([^\"]*) \"/\"$1\"/gx;
} @lines;
@lines = grep {++$count{$_} < 2 } (sort @lines);
@@ -924,43 +910,22 @@ sub normalizeLines {
}
###############################################################################
-# dvips2dvipdfm()
-# reads from stdin, writes to stdout. It transforms "dvips"-like syntax into
-# "dvipdfm"-like syntax. It is a very ugly hack.
+# to_pdftex()
+# strip "PS_Encoding_Name ReEncodeFont" from map entries because
+# they are ignored by pdftex anyway.
###############################################################################
-sub dvips2dvipdfm {
- my @lines = @_;
-
- map {
- $_ =~ s@$@ %@;
- $_ =~ s@^(([^ ]*).*)@\1\2@;
- $_ =~ s@(.*<\[* *([^ ]*)\.enc(.*))@\1 \2@;
- $_ = (m/%[^ ]*$/x ? "$_ default" : $_) ;
- $_ =~ s@(.*<<* *([^ ]*)\.pf[ab].*)@\1 \2@;
- if (m/%[^ ]* [^ ]*$/x) { $_ =~ s@( ([^ ]*).*)$@\1 \2@; }
- $_ =~ s@(.* ([\.0-9-][\.0-9-]*) *ExtendFont.*)@\1 -e \2@;
- $_ =~ s@(.* ([\.0-9-][\.0-9-]*) *SlantFont.*)@\1 -s \2@;
- $_ =~ s@.*%@@ ;
- } @lines;
-
- map {
- my @elts = split (' ', $_);
- if ($elts[0] eq $elts[2]
- && $elts[1] eq "default") {
- $elts[1] = '';
- $elts[2] = '';
- };
- $_ = join ' ',@elts;
- } @lines;
-
- map {
- if (/^(cm|eu|la|lc|line|msam|xy)/) {
- $_ .= " -r" ;
- $_ =~ s/(fmex[789]) -r/\1/;
+sub to_pdftex {
+ return unless $pdftexStripEnc;
+ my @in = @_;
+ my @out;
+ foreach my $line (@in) {
+ if ($line =~ /^(.*\s+)(\S+\s+ReEncodeFont\s)(.*)/) {
+ $line = "$1$3";
+ $line =~ s/\s+\"\s+\"\s+/ /;
}
- } @lines;
-
- return @lines;
+ push @out, $line;
+ }
+ return @out;
}
###############################################################################
@@ -969,6 +934,38 @@ sub dvips2dvipdfm {
###############################################################################
sub mkMaps {
my @lines;
+ my $logfile;
+
+ $cache=1;
+
+ if (! $dry_run) {
+ my $TEXMFVAR=`kpsewhich --var-value=TEXMFVAR`;
+ chomp($TEXMFVAR);
+ $logfile="$TEXMFVAR/web2c/updmap.log";
+ mkdirhier "$TEXMFVAR/web2c";
+ open LOG, ">$logfile"
+ or die "Can't open \"$logfile\"";
+ $writelog=1;
+ print LOG &version() . "\n";
+ printf LOG "%s\n\n", scalar localtime();
+ print LOG "Using config file \"$cnfFile\".\n";
+ }
+ sub wlog () {
+ my $str=shift;
+ if ($dry_run) {
+ print $str;
+ } else {
+ print $str if (! $quiet);
+ print LOG $str;
+ }
+ }
+ sub newline() {
+ if ($dry_run) {
+ print "\n";
+ } else {
+ print LOG "\n";
+ }
+ }
$mode = &cfgval("LW35");
$mode = "URWkb" unless (defined $mode);
@@ -977,37 +974,75 @@ sub mkMaps {
$dvipsPreferOutline = 1 unless (defined $dvipsPreferOutline);
$dvipsDownloadBase35 = &cfgval("dvipsDownloadBase35");
- $dvipsDownloadBase35 = 0 unless (defined $dvipsDownloadBase35);
+ $dvipsDownloadBase35 = 1 unless (defined $dvipsDownloadBase35);
$pdftexDownloadBase14 = &cfgval("pdftexDownloadBase14");
- $pdftexDownloadBase14 = 0 unless (defined $pdftexDownloadBase14);
-
- $dvipdfmDownloadBase14 = &cfgval("dvipdfmDownloadBase14");
- $dvipdfmDownloadBase14 = 0 unless (defined $dvipdfmDownloadBase14);
-
- if (! $quiet) {
- print "\
-updmap is creating new map files using the following configuration:\
-\
- config file : " . ($cnfFile ? "true" : "false") ."\
- prefer outlines : " . ($dvipsPreferOutline ? "true" : "false") ."\
- texhash enabled : " . ($texhashEnabled ? "true" : "false") ."\
- download standard fonts (dvips) : " . ($dvipsDownloadBase35 ? "true" : "false") ."\
- download standard fonts (pdftex) : " . ($pdftexDownloadBase14 ? "true" : "false") . "\
- download standard fonts (dvipdfm): " . ($dvipdfmDownloadBase14 ? "true" : "false") . "\
-"
- };
-
- print "Scanning for LW35 support files\n" if (! $quiet);
+ $pdftexDownloadBase14 = 1 unless (defined $pdftexDownloadBase14);
+
+ &wlog ("\nupdmap is creating new map files " .
+ "using the following configuration:" .
+ "\n LW35 font names : " .
+ $mode .
+ "\n prefer outlines : " .
+ ($dvipsPreferOutline ? "true" : "false") .
+ "\n texhash enabled : " .
+ ($nohash ? "false" : "true") .
+ "\n download standard fonts (dvips) : " .
+ ($dvipsDownloadBase35 ? "true" : "false") .
+ "\n download standard fonts (pdftex) : " .
+ ($pdftexDownloadBase14 ? "true" : "false") .
+ "\n\n");
+
+ &wlog ("Scanning for LW35 support files");
$dvips35 = &locateMap("dvips35.map");
$pdftex35 = &locateMap("pdftex35.map");
- $dvipdfm35 = &locateMap("dvipdfm35.map");
$ps2pk35 = &locateMap("ps2pk35.map");
+ my $LW35="\n$dvips35\n$pdftex35\n$ps2pk35\n\n";
+ if ($dry_run) {
+ print $LW35;
+ } else {
+ print LOG $LW35;
+ }
+ printf " [%3d files]\n", 3 unless ($quiet || $dry_run);
- print "Scanning for MixedMap entries\n" if (! $quiet);
+ &wlog ("Scanning for MixedMap entries");
+ &newline;
my @tmp1 = &catMaps('^MixedMap');
- print "Scanning for Map entries\n" if (! $quiet);
+ foreach my $line (@tmp1) {
+ if ($dry_run) {
+ print "$line\n";
+ } else {
+ print LOG "$line\n";
+ }
+ }
+ &newline;
+ printf " [%3d files]\n", scalar @tmp1
+ unless ($quiet || $dry_run);
+
+ &wlog ("Scanning for Map entries");
+ &newline();
my @tmp2 = &catMaps('^Map');
+ foreach my $line (@tmp2) {
+ if ($dry_run) {
+ print "$line\n";
+ } else {
+ print LOG "$line\n";
+ }
+ }
+ &newline;
+ printf " [%3d files]\n\n", scalar @tmp2
+ unless ($quiet || $dry_run);
+
+ if (@missing > 0) {
+ print STDERR "\nERROR: The following map file(s) couldn't be found:\n\t";
+ print STDERR join(' ', @missing);
+ my $progname=&progname();
+ print STDERR "\n\n\tDid you run mktexlsr?\n\n" .
+ "\tYou can delete non-existent map entries using the command\n".
+ "\n\t $progname --syncwithtrees\n\n";
+ exit (1);
+ }
+ exit(0) if $dry_run;
# Create psfonts_t1.map, psfonts_pk.map, ps2pk.map and pdftex.map:
for my $file ("$dvipsoutputdir/download35.map",
@@ -1016,51 +1051,54 @@ updmap is creating new map files using the following configuration:\
"$dvipsoutputdir/psfonts_pk.map",
"$pdftexoutputdir/pdftex_dl14.map",
"$pdftexoutputdir/pdftex_ndl14.map",
- "$dvipdfmoutputdir/dvipdfm_dl14.map",
- "$dvipdfmoutputdir/dvipdfm_ndl14.map",
"$dvipsoutputdir/ps2pk.map") {
open FILE, ">$file";
- print FILE "% $file: maintained by the script updmap.\
-% Don't change this file directly. Edit texmf/web2c/$cnfFileShort\
-% and run updmap to recreate this file.\
+ print FILE "% $file:\
+% maintained by updmap[-sys].\
+% Don't change this file directly. Use updmap[-sys] instead.\
+% See texmf/web2c/$cnfFileShort and the updmap documentation.\
+% A log of the run that created this file is available here:\
+% $logfile\
";
close FILE;
}
-# print "$dvips35 $pdftex35 $dvipdfm35 $ps2pk35 @tmp1 @tmp2\n";
-
+ print "Generating output for ps2pk...\n" if (! $quiet);
my @ps2pk_map = &transLW35($ps2pk35);
push @ps2pk_map, &getLines(@tmp1);
push @ps2pk_map, &getLines(@tmp2);
- &writeLines(">$dvipsoutputdir/ps2pk.map", &normalizeLines(@ps2pk_map));
+ &writeLines(">$dvipsoutputdir/ps2pk.map",
+ &normalizeLines(@ps2pk_map));
+ print "Generating output for dvips...\n" if (! $quiet);
my @download35_map = &transLW35($ps2pk35);
- &writeLines(">$dvipsoutputdir/download35.map", &normalizeLines(@download35_map));
+ &writeLines(">$dvipsoutputdir/download35.map",
+ &normalizeLines(@download35_map));
+
my @builtin35_map = &transLW35($dvips35);
- &writeLines(">$dvipsoutputdir/builtin35.map", &normalizeLines(@builtin35_map));
+ &writeLines(">$dvipsoutputdir/builtin35.map",
+ &normalizeLines(@builtin35_map));
my $dftdvips = ($dvipsDownloadBase35 ? $ps2pk35 : $dvips35);
my @psfonts_t1_map = &transLW35($dftdvips);
push @psfonts_t1_map, &getLines(@tmp1);
push @psfonts_t1_map, &getLines(@tmp2);
- &writeLines(">$dvipsoutputdir/psfonts_t1.map", &normalizeLines(@psfonts_t1_map));
+ &writeLines(">$dvipsoutputdir/psfonts_t1.map",
+ &normalizeLines(@psfonts_t1_map));
my @psfonts_pk_map = &transLW35($dftdvips);
push @psfonts_pk_map, &getLines(@tmp2);
- &writeLines(">$dvipsoutputdir/psfonts_pk.map", &normalizeLines(@psfonts_pk_map));
+ &writeLines(">$dvipsoutputdir/psfonts_pk.map",
+ &normalizeLines(@psfonts_pk_map));
+ print "Generating output for pdftex...\n" if (! $quiet);
# remove PaintType due to Sebastian's request
my @tmp3 = &transLW35($pdftex35);
push @tmp3, &getLines(@tmp1);
push @tmp3, &getLines(@tmp2);
@tmp3 = grep { $_ !~ m/(^%|PaintType)/ } @tmp3;
- my @tmp6 = &transLW35($dvipdfm35);
- push @tmp6, &getLines(@tmp1);
- push @tmp6, &getLines(@tmp2);
- @tmp6 = grep { $_ !~ m/(^%|PaintType)/ } @tmp6;
-
my @tmp7 = &transLW35($ps2pk35);
push @tmp7, &getLines(@tmp1);
push @tmp7, &getLines(@tmp2);
@@ -1068,48 +1106,58 @@ updmap is creating new map files using the following configuration:\
my @pdftex_ndl14_map = @tmp3;
@pdftex_ndl14_map = &normalizeLines(@pdftex_ndl14_map);
+ @pdftex_ndl14_map = &to_pdftex(@pdftex_ndl14_map);
&writeLines(">$pdftexoutputdir/pdftex_ndl14.map", @pdftex_ndl14_map);
my @pdftex_dl14_map = @tmp7;
@pdftex_dl14_map = &normalizeLines(@pdftex_dl14_map);
+ @pdftex_dl14_map = &to_pdftex(@pdftex_dl14_map);
&writeLines(">$pdftexoutputdir/pdftex_dl14.map", @pdftex_dl14_map);
- my @dvipdfm_dl14_map = @tmp7;
- @dvipdfm_dl14_map = &normalizeLines(&dvips2dvipdfm(&normalizeLines(@dvipdfm_dl14_map)));
- &writeLines(">$dvipdfmoutputdir/dvipdfm_dl14.map", @dvipdfm_dl14_map);
-
- my @dvipdfm_ndl14_map = @tmp6;
- @dvipdfm_ndl14_map = &normalizeLines(&dvips2dvipdfm(&normalizeLines(@dvipdfm_ndl14_map)));
- &writeLines(">$dvipdfmoutputdir/dvipdfm_ndl14.map", @dvipdfm_ndl14_map);
-
&setupSymlinks;
- if ($texhashEnabled) {
- my $cmd = "mktexlsr";
- &start_redirection("nul") if ($quiet);
- system($cmd);
- &stop_redirection if ($quiet);
- }
-
- if (! $quiet) {
- print STDOUT "Files generated:\n";
- for my $f ("$dvipsoutputdir/download35.map",
- "$dvipsoutputdir/builtin35.map",
- "$dvipsoutputdir/psfonts_t1.map",
- "$dvipsoutputdir/psfonts_pk.map",
- "$pdftexoutputdir/pdftex_dl14.map",
- "$pdftexoutputdir/pdftex_ndl14.map",
- "$dvipdfmoutputdir/dvipdfm_dl14.map",
- "$dvipdfmoutputdir/dvipdfm_ndl14.map",
- "$dvipsoutputdir/ps2pk.map") {
- if (-e $f) {
- my @stat=stat($f);
- printf "%7d %s %s\n", $stat[7], scalar (localtime $stat[9]), $f;
+ &wlog ("\nFiles generated:\n");
+ sub dir {
+ my ($d, $f, $target)=@_;
+ if (-e "$d/$f") {
+ my @stat=lstat("$d/$f");
+ my ($s,$m,$h,$D,$M,$Y)=localtime($stat[9]);
+ my $timestamp=sprintf ("%04d-%02d-%02d %02d:%02d:%02d",
+ $Y+1900, $M+1, $D, $h, $m, $s);
+ my $date=sprintf "%12d %s %s", $stat[7], $timestamp, $f;
+ &wlog ($date);
+
+ if (-l "$d/$f") {
+ my $lnk=sprintf " -> %s\n", readlink ("$d/$f");
+ &wlog ($lnk);
+ } elsif ($f eq $target) {
+ if (&files_are_identical("$d/$f", "$d/$link{$target}")) {
+ &wlog (" = $link{$target}\n");
+ } else {
+ &wlog (" = ?????\n"); # This shouldn't happen.
+ }
} else {
- print STDERR "Warning: File $f doesn't exist.\n";
- }
+ &wlog ("\n");
+ }
+ } else {
+ print STDERR "Warning: File $d/$f doesn't exist.\n";
+ print LOG "Warning: File $d/$f doesn't exist.\n";
}
}
+ my $d;
+ $d="$dvipsoutputdir"; &wlog (" $d:\n");
+ foreach my $f ('builtin35.map', 'download35.map', 'psfonts_pk.map',
+ 'psfonts_t1.map', 'ps2pk.map', 'psfonts.map') {
+ dir ($d, $f, 'psfonts.map');
+ $updLSR->{add}("$d/$f");
+ }
+ $d="$pdftexoutputdir"; &wlog (" $d:\n");
+ foreach my $f ('pdftex_dl14.map', 'pdftex_ndl14.map', 'pdftex.map') {
+ dir ($d, $f, 'pdftex.map');
+ $updLSR->{add}("$d/$f");
+ }
+ close LOG;
+ print "\nTranscript written on \"$logfile\".\n" if (! $quiet);
}
###############################################################################
@@ -1117,7 +1165,6 @@ updmap is creating new map files using the following configuration:\
# execution starts here
###############################################################################
sub main {
-
&initVars;
&processOptions;
@@ -1131,7 +1178,15 @@ sub main {
&setupCfgFile;
if ($listmaps) {
- &listMaps;
+ &listMaps ('list');
+ exit 0;
+ }
+ if ($listavailablemaps) {
+ &listMaps ('avail');
+ exit 0;
+ }
+ if ($syncwithtrees) {
+ &listMaps ('sync');
exit 0;
}
@@ -1142,24 +1197,29 @@ sub main {
my $cmd = '';
if ($opt_edit) {
- my $editor = `kpsewhich --expand-var \$TEXEDIT`;
- chomp($editor);
- $editor = "notepad" if ($editor eq "");
+ my $editor = undef;
+ $editor ||= $ENV{'EDITOR'};
+ $editor ||= $ENV{'VISUAL'};
+ if (&win32) {
+ $editor ||= "notepad";
+ } else {
+ $editor ||= "vi";
+ }
$cmd = 'edit';
system("$editor $cnfFile");
}
-
elsif (keys %setOption) {
$cmd = 'setOption';
foreach my $m (keys %setOption) {
&setOption ($m, $setOption{$m});
}
}
-
- elsif (keys %enableItem) {
+ elsif ($enableItem) {
$cmd = 'enableMap';
- foreach my $m (keys %enableItem) {
- &enableMap($m, $enableItem{$m});
+ if ($enableItem=~/=/) {
+ &enableMap(split('=', $enableItem));
+ } else {
+ &enableMap($enableItem, shift @ARGV);
}
}
elsif (@disableItem) {
@@ -1168,19 +1228,17 @@ sub main {
&disableMap($m);
}
}
-
if ($cmd and &files_are_equal($bakFile, $cnfFile)) {
print "$cnfFile unchanged. Map files not recreated.\n" unless ($quiet);
}
else {
- if ($mkmapEnabled) {
+ if (! $nomkmap) {
&setupDestDir;
&mkMaps;
}
- # &cleanup;
unlink ($bakFile);
}
-
+ $updLSR->{exec}() unless $nohash;
}
__END__