summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2011-09-09 06:17:44 +0000
committerNorbert Preining <preining@logic.at>2011-09-09 06:17:44 +0000
commitdd128d98b6f709f58353571fb961ff9bee6a59d8 (patch)
treeedce10d8eb8065b596bb374a7a7af680b5a03b12 /Master
parent1f61ab5c8cc9e296d8b82c9f7b54967cab7d7628 (diff)
multi-updmap: make --dry-run functional as real --dry-run, hopefully
git-svn-id: svn://tug.org/texlive/trunk@23883 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/tlpkg/dev/multi-updmap.pl143
1 files changed, 64 insertions, 79 deletions
diff --git a/Master/tlpkg/dev/multi-updmap.pl b/Master/tlpkg/dev/multi-updmap.pl
index 5fb820a5ced..df3aff556dc 100644
--- a/Master/tlpkg/dev/multi-updmap.pl
+++ b/Master/tlpkg/dev/multi-updmap.pl
@@ -13,8 +13,6 @@
# Anyone may freely use, modify, and/or distribute this file, without
# limitation.
#
-# TODO
-# - implement a decent --dry-run
my $TEXMFROOT;
@@ -216,6 +214,11 @@ sub main {
my $cmd;
if ($opts{'edit'}) {
+ if ($opts{"dry-run"}) {
+ printf STDERR "No, are you joking, you want to edit with --dry-run?\n";
+ printf STDERR "Not doing that, bye bye!\n";
+ exit 1;
+ }
# it's not a good idea to edit updmap.cfg manually these days,
# but for compatibility we'll silently keep the option.
$cmd = 'edit';
@@ -280,7 +283,7 @@ sub main {
if (!$opts{'nohash'}) {
print "$prg: Updating ls-R files.\n" if !$opts{'quiet'};
- $updLSR->{exec}();
+ $updLSR->{exec}() unless $opts{"dry-run"};
}
}
@@ -309,7 +312,7 @@ sub getFonts {
} else {
print "undefined fonts for $k in $m ?!?!?\n";
}
- print LOG "$k\n";
+ print LOG "$k\n" unless $opts{'dry-run'};
}
}
}
@@ -324,6 +327,7 @@ sub getFonts {
#
sub writeLines {
my ($fname, @lines) = @_;
+ return if $opts{"dry-run"};
map { ($_ !~ m/\n$/ ? s/$/\n/ : $_ ) } @lines;
open FILE, ">$fname" or die "$prg: can't write lines to $fname: $!";
print FILE @lines;
@@ -367,7 +371,7 @@ sub setupSymlinks {
} else {
$src = "psfonts_pk.map";
}
- unlink "$dvipsoutputdir/psfonts.map";
+ unlink "$dvipsoutputdir/psfonts.map" unless $opts{"dry-run"};
push @link, &SymlinkOrCopy("$dvipsoutputdir", "$src", "psfonts.map");
if ($pdftexDownloadBase14) {
@@ -375,7 +379,7 @@ sub setupSymlinks {
} else {
$src = "pdftex_ndl14.map";
}
- unlink "$pdftexoutputdir/pdftex.map";
+ unlink "$pdftexoutputdir/pdftex.map" unless $opts{"dry-run"};
push @link, &SymlinkOrCopy("$pdftexoutputdir", "$src", "pdftex.map");
%link = @link;
return \%link;
@@ -387,6 +391,7 @@ sub setupSymlinks {
#
sub SymlinkOrCopy {
my ($dir, $src, $dest) = @_;
+ return ($src, $dest) if $opts{"dry-run"};
if (&win32 || $opts{'copy'}) { # always copy
&copyFile("$dir/$src", "$dir/$dest");
} else { # symlink if supported by fs, copy otherwise
@@ -581,8 +586,9 @@ sub transLW35 {
sub mkMaps {
my $logfile;
+ $logfile = "$TEXMFVAR/web2c/updmap.log";
+
if (! $opts{'dry-run'}) {
- $logfile = "$TEXMFVAR/web2c/updmap.log";
mkdirhier("$TEXMFVAR/web2c");
open LOG, ">$logfile"
or die "$prg: Can't open log file \"$logfile\": $!";
@@ -593,21 +599,13 @@ sub mkMaps {
print LOG " $_\n";
}
}
- sub wlog () {
+ sub print_and_log {
my $str=shift;
- if ($opts{'dry-run'}) {
- print $str;
- } else {
- print $str if !$opts{'quiet'};
- print LOG $str;
- }
+ print $str if !$opts{'quiet'};
+ print LOG $str unless $opts{'dry-run'};
}
- sub newline() {
- if ($opts{'dry-run'}) {
- print "\n";
- } else {
- print LOG "\n";
- }
+ sub only_log {
+ print LOG shift unless $opts{'dry-run'};
}
sub get_cfg {
my ($v, $def, $opt) = @_;
@@ -633,8 +631,7 @@ sub mkMaps {
my ($pdftexDownloadBase14, $pdftexDownloadBase14_origin) =
get_cfg('pdftexDownloadBase14', 1);
- &wlog ("\n$prg "
- . ($opts{'dry-run'} ? "would create" : "is creating") . " new map files"
+ print_and_log ("\n$prg is creating new map files"
. "\nusing the following configuration:"
. "\n LW35 font names : "
. "$mode ($mode_origin)"
@@ -651,21 +648,15 @@ sub mkMaps {
. " ($pdftexDownloadBase14_origin)"
. "\n\n");
- &wlog ("Scanning for LW35 support files");
+ print_and_log ("Scanning for LW35 support files");
my $dvips35 = $alldata->{'maps'}{"dvips35.map"}{'fullpath'};
my $pdftex35 = $alldata->{'maps'}{"pdftex35.map"}{'fullpath'};
my $ps2pk35 = $alldata->{'maps'}{"ps2pk35.map"}{'fullpath'};
my $LW35 = "\n$dvips35\n$pdftex35\n$ps2pk35\n\n";
- if ($opts{'dry-run'}) {
- print $LW35;
- } else {
- print LOG $LW35;
- }
- printf " [%3d files]\n", 3 unless ($opts{'quiet'} || $opts{'dry-run'});
-
- &wlog ("Scanning for MixedMap entries");
- &newline;
+ only_log ($LW35);
+ print_and_log (" [ 3 files]\n");
+ print_and_log ("Scanning for MixedMap entries");
my @mixedmaps;
my @notmixedmaps;
for my $m (keys %{$alldata->{'maps'}}) {
@@ -677,55 +668,43 @@ sub mkMaps {
push @notmixedmaps, $m
if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "Map");
}
-
@mixedmaps = sort @mixedmaps;
@notmixedmaps = sort @notmixedmaps;
-
+ only_log("\n");
foreach my $line (sort @mixedmaps) {
- if ($opts{'dry-run'}) {
- print "$line\n";
- } else {
- print LOG "$line\n";
- }
+ only_log("$line\n");
}
- &newline;
- printf " [%3d files]\n", scalar @mixedmaps
- unless ($opts{'quiet'} || $opts{'dry-run'});
+ only_log("\n");
+ print_and_log (sprintf(" [%3d files]\n", scalar @mixedmaps));
- &wlog ("Scanning for Map entries");
- &newline();
+ print_and_log ("Scanning for Map entries");
foreach my $line (@notmixedmaps) {
- if ($opts{'dry-run'}) {
- print "$line\n";
- } else {
- print LOG "$line\n";
- }
+ only_log("$line\n");
}
- &newline;
- printf " [%3d files]\n\n", scalar @notmixedmaps
- unless ($opts{'quiet'} || $opts{'dry-run'});
-
- exit (0) if ($opts{'dry-run'});
+ only_log("\n");
+ print_and_log (sprintf(" [%3d files]\n\n", scalar @notmixedmaps));
# Create psfonts_t1.map, psfonts_pk.map, ps2pk.map and pdftex.map:
my $dvipsoutputdir = $opts{'dvipsoutputdir'};
my $pdftexoutputdir = $opts{'pdftexoutputdir'};
- for my $file ("$dvipsoutputdir/download35.map",
- "$dvipsoutputdir/builtin35.map",
- "$dvipsoutputdir/psfonts_t1.map",
- "$dvipsoutputdir/psfonts_pk.map",
- "$pdftexoutputdir/pdftex_dl14.map",
- "$pdftexoutputdir/pdftex_ndl14.map",
- "$dvipsoutputdir/ps2pk.map") {
- open FILE, ">$file";
- print FILE "% $file:\
+ if (!$opts{'dry-run'}) {
+ for my $file ("$dvipsoutputdir/download35.map",
+ "$dvipsoutputdir/builtin35.map",
+ "$dvipsoutputdir/psfonts_t1.map",
+ "$dvipsoutputdir/psfonts_pk.map",
+ "$pdftexoutputdir/pdftex_dl14.map",
+ "$pdftexoutputdir/pdftex_ndl14.map",
+ "$dvipsoutputdir/ps2pk.map") {
+ open FILE, ">$file";
+ print FILE "% $file:\
% maintained by updmap[-sys] (multi).\
% Don't change this file directly. Use updmap[-sys] instead.\
% See the updmap documentation.\
% A log of the run that created this file is available here:\
% $logfile\
";
- close FILE;
+ close FILE;
+ }
}
print "Generating output for ps2pk...\n" if !$opts{'quiet'};
@@ -803,7 +782,7 @@ sub mkMaps {
my $link = &setupSymlinks($dvipsPreferOutline, $dvipsoutputdir, $pdftexDownloadBase14, $pdftexoutputdir);
- &wlog ("\nFiles generated:\n");
+ print_and_log ("\nFiles generated:\n");
sub dir {
my ($d, $f, $target)=@_;
our $link;
@@ -813,38 +792,41 @@ sub mkMaps {
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);
+ print_and_log ($date);
if (-l "$d/$f") {
my $lnk=sprintf " -> %s\n", readlink ("$d/$f");
- &wlog ($lnk);
+ print_and_log ($lnk);
} elsif ($f eq $target) {
if (&files_are_identical("$d/$f", "$d/$link->{$target}")) {
- &wlog (" = $link->{$target}\n");
+ print_and_log (" = $link->{$target}\n");
} else {
- &wlog (" = ?????\n"); # This shouldn't happen.
+ print_and_log (" = ?????\n"); # This shouldn't happen.
}
} else {
- &wlog ("\n");
+ print_and_log ("\n");
}
} else {
print STDERR "Warning: File $d/$f doesn't exist.\n";
- print LOG "Warning: File $d/$f doesn't exist.\n";
+ print LOG "Warning: File $d/$f doesn't exist.\n"
+ unless $opts{'dry-run'};
}
}
my $d;
- $d="$dvipsoutputdir"; &wlog (" $d:\n");
+ $d = "$dvipsoutputdir";
+ print_and_log(" $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");
+ $updLSR->{add}("$d/$f") unless $opts{'dry-run'};
}
- $d="$pdftexoutputdir"; &wlog (" $d:\n");
+ $d = "$pdftexoutputdir";
+ print_and_log(" $d:\n");
foreach my $f ('pdftex_dl14.map', 'pdftex_ndl14.map', 'pdftex.map') {
dir ($d, $f, 'pdftex.map');
- $updLSR->{add}("$d/$f");
+ $updLSR->{add}("$d/$f") unless $opts{'dry-run'};
}
- close LOG;
+ close LOG unless $opts{'dry-run'};
print "\nTranscript written on \"$logfile\".\n" if !$opts{'quiet'};
}
@@ -912,9 +894,11 @@ sub setupOutputDir {
}
}
my $od = $opts{$driver . "outputdir"};
- &mkdirhier($od);
- if (! -w $od) {
- die "$prg: Directory \"$od\" isn't writable: $!";
+ if (!$opts{"dry-run"}) {
+ &mkdirhier($od);
+ if (! -w $od) {
+ die "$prg: Directory \"$od\" isn't writable: $!";
+ }
}
print "$driver output dir: \"$od\"\n" if !$opts{'quiet'};
return $od;
@@ -1027,6 +1011,7 @@ sub disable_map {
# returns 1 if actually saved due to changes
sub save_updmap {
my $fn = shift;
+ return if $opts{'dry-run'};
my %upd = %{$alldata->{'updmap'}{$fn}};
if ($upd{'changed'}) {
open (FN, ">$fn") || die "$prg: can't write to $fn: $!";