summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinhard Kotucha <reinhard.kotucha@web.de>2011-02-05 00:31:42 +0000
committerReinhard Kotucha <reinhard.kotucha@web.de>2011-02-05 00:31:42 +0000
commite9a313b2426d4212c9e1aecbbbc98aab1113ef1b (patch)
tree4f4fece7d46bef0f04c4f477920c2201baafb992
parent6dd42248aae7962d5fea0eadc73cd508638966b2 (diff)
tlpkg/dev/updmap.pl: use TeXLive::TLUtils
git-svn-id: svn://tug.org/texlive/trunk@21305 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/tlpkg/dev/updmap.pl144
1 files changed, 25 insertions, 119 deletions
diff --git a/Master/tlpkg/dev/updmap.pl b/Master/tlpkg/dev/updmap.pl
index e8e11766444..38ce18f2619 100755
--- a/Master/tlpkg/dev/updmap.pl
+++ b/Master/tlpkg/dev/updmap.pl
@@ -6,8 +6,12 @@
# Fabrice Popineau, for the Perl version.
#
###############################################################################
-$^W=1;
# $Id$
+$^W=1;
+BEGIN {
+ chomp($TEXMFROOT = `kpsewhich -var-value=TEXMFROOT`);
+ unshift (@INC, "$TEXMFROOT/tlpkg");
+}
my $svnrev = '$Revision$';
my $revision;
@@ -18,20 +22,11 @@ if ($svnrev =~ m/: ([0-9]+) /) {
}
use strict;
+use TeXLive::TLUtils qw(mkdirhier mktexupd win32);
use Getopt::Long;
$Getopt::Long::autoabbrev=0;
Getopt::Long::Configure ("bundling");
-sub win32 {
- if ($^O=~/^MSWin(32|64)$/i) {
- return 1;
- } else {
- return 0;
- }
-}
-
-my $nulldev=(win32())? 'nul':'/dev/null';
-
my $progname='updmap';
my $cnfFile;
my $cnfFileShort;
@@ -76,8 +71,8 @@ my $copy;
my $pdftexNoEnc=1;
# initialize mktexupd
-my $mktexupd=&newmktexupd();
-$mktexupd->{mustexist}(1);
+my $updLSR=&mktexupd();
+$updLSR->{mustexist}(0);
my @cfg = ();
@@ -236,6 +231,10 @@ my @fileADOBE = (
&main;
exit 0;
+###############################################################################
+# progname()
+# return the name of the program. Needed if invoked by a wrapper.
+###############################################################################
sub progname {
if (`kpsewhich --var-value=TEXMFVAR` eq `kpsewhich --var-value=TEXMFSYSVAR`) {
return 'updmap-sys';
@@ -244,97 +243,6 @@ sub progname {
}
}
-sub newmktexupd {
- my %files;
- my $mustexist=0;
-
- my $hash={
- "add" => sub {
- foreach my $file (@_) {
- $file =~ s|\\|/|g;
- $files{$file}=1;
- }
- },
- "reset" => sub {
- %files=();
- },
- "mustexist" => sub {
- $mustexist=shift;
- },
- "exec" => sub {
- # check whether files exist
- if ($mustexist) {
- foreach my $file (keys %files) {
- die "File \"$file\" doesn't exist.\n" if (! -f $file);
- }
- }
- my $TEXMFDBS;
- my @texmfdbs;
- my $delim;
-
- $TEXMFDBS=`kpsewhich --show-path="ls-R"`;
- chomp ($TEXMFDBS);
-
- $delim= (&win32())? ';' : ':';
-
- my @texmfdbs=split ($delim, "$TEXMFDBS");
- my %dbs;
-
- foreach my $path (keys %files) {
- foreach my $db (@texmfdbs) {
- $db=substr($db, -1) if ($db=~m|/$|); # strip leading /
- if (substr($path, 0, length("$db/")) eq "$db/") {
- # we appended a / because otherwise "texmf" is recognized as a
- # substring of "texmf-dist".
- my $path='./' . substr($path, length("$db/"));
- my ($dir, $file);
- $_=$path;
- ($dir, $file) = m|(.*)/(.*)|;
- $dbs{$db}{$dir}{$file}=1;
- }
- }
- }
- foreach my $db (keys %dbs) {
- if (! -f "$db" || ! -w "$db/ls-R") {
- &mkdirhier ($db);
- }
- open LSR, ">>$db/ls-R";
- foreach my $dir (keys %{$dbs{$db}}) {
- print LSR "\n$dir:\n";
- foreach my $file (keys %{$dbs{$db}{$dir}}) {
- print LSR "$file\n";
- }
- }
- close LSR;
- }
- }
- };
- return $hash;
-}
-
-###############################################################################
-# mkdirhier(directory)
-# create a directory and parent directories as needed
-###############################################################################
-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";
- }
- }
- }
-}
-
###############################################################################
# equalize_file(filename[, comment_char])
# read a file and return its processed content as a string.
@@ -607,7 +515,7 @@ sub cfgval {
###############################################################################
sub SymlinkOrCopy {
my ($dir, $src, $dest) = @_;
- if (win32() || $copy) { # always copy
+ 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 || "
@@ -723,7 +631,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;
@@ -833,8 +741,7 @@ sub initVars {
$cnfFile = "";
$cnfFileShort = "updmap.cfg";
$outputdir = "";
- $TEXMFMAIN =`kpsewhich --var-value=TEXMFMAIN`;
- chomp($TEXMFMAIN);
+ chomp($TEXMFMAIN =`kpsewhich --var-value=TEXMFMAIN`);
}
###############################################################################
@@ -872,8 +779,7 @@ sub setupOutputDir {
my $tf;
# Try TEXMFVAR tree. Use it if variable is set and $rel can
# be written.
- $tf = `kpsewhich --var-value=TEXMFVAR`;
- chomp($tf);
+ chomp($tf = `kpsewhich --var-value=TEXMFVAR`);
if ($tf) {
&mkdirhier("$tf/$rel");
if (! -w "$tf/$rel") {
@@ -909,7 +815,7 @@ sub setupCfgFile {
print("copy $original_cfg => $tf/web2c/$cnfFileShort\n") if (! $quiet);
$newcnf="$tf/web2c/$cnfFileShort";
&copyFile("$original_cfg", "$tf/web2c/$cnfFileShort");
- $mktexupd->{add}("$tf/web2c/$cnfFileShort");
+ $updLSR->{add}("$tf/web2c/$cnfFileShort");
}
}
$cnfFile = "$tf/web2c/updmap.cfg";
@@ -1023,7 +929,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);
@@ -1033,8 +939,8 @@ sub normalizeLines {
###############################################################################
# to_pdftex()
-# strip "PS_Encoding_Name ReEncodeFont" from map entries,
-# because ignored by pdftex.
+# strip "PS_Encoding_Name ReEncodeFont" from map entries because
+# they are ignored by pdftex anyway.
###############################################################################
sub to_pdftex {
my @in=@_;
@@ -1265,14 +1171,14 @@ sub mkMaps {
my $d;
$d="$dvipsoutputdir"; &wlog (" $d:\n");
foreach my $f ('builtin35.map', 'download35.map', 'psfonts_pk.map',
- 'psfonts_t1.map', 'ps2pk.map', 'psfonts.map') {
+ 'psfonts_t1.map', 'ps2pk.map', 'psfonts.map') {
dir ($d, $f, 'psfonts.map');
- $mktexupd->{add}("$d/$f");
+ $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');
- $mktexupd->{add}("$d/$f");
+ $updLSR->{add}("$d/$f");
}
close LOG;
print "\nTranscript written on \"$logfile\".\n" if (! $quiet);
@@ -1320,7 +1226,7 @@ sub main {
my $editor = undef;
$editor ||= $ENV{'EDITOR'};
$editor ||= $ENV{'VISUAL'};
- if (win32()) {
+ if (&win32) {
$editor ||= "notepad";
} else {
$editor ||= "vi";
@@ -1358,7 +1264,7 @@ sub main {
}
unlink ($bakFile);
}
- $mktexupd->{exec}() unless $nohash;
+ $updLSR->{exec}() unless $nohash;
}
__END__