From 1f61ab5c8cc9e296d8b82c9f7b54967cab7d7628 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 9 Sep 2011 05:47:44 +0000 Subject: multi-updmap: - allow multiple --enable and --disable and work on all at once - fix some errors in the logic of enabling and disabling maps git-svn-id: svn://tug.org/texlive/trunk@23882 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/dev/multi-updmap.pl | 63 ++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 31 deletions(-) (limited to 'Master') diff --git a/Master/tlpkg/dev/multi-updmap.pl b/Master/tlpkg/dev/multi-updmap.pl index 3eaf858438e..5fb820a5ced 100644 --- a/Master/tlpkg/dev/multi-updmap.pl +++ b/Master/tlpkg/dev/multi-updmap.pl @@ -14,8 +14,6 @@ # limitation. # # TODO -# - either work on all enable and disable options together, or disallow -# specifying both! # - implement a decent --dry-run my $TEXMFROOT; @@ -234,16 +232,9 @@ sub main { } elsif ($opts{'setoption'}) { $cmd = 'setOption'; $changed = setOptions (@{$opts{'setoption'}}); - } elsif ($opts{'enable'}) { + } elsif ($opts{'enable'} || $opts{'disable'}) { $cmd = 'enableMap'; - for my $l (@{$opts{'enable'}}) { - $changed ||= enableMap(split('=', $l)); - } - } elsif ($opts{'disable'}) { - $cmd = 'disableMap'; - for my $m (@{$opts{'disable'}}) { - $changed ||= disableMap($m); - } + $changed ||= enable_disable_maps(@{$opts{'enable'}}, @{$opts{'disable'}}); } # what does this? @@ -950,27 +941,42 @@ sub setOptions { return save_updmap($alldata->{'changes_config'}); } -sub enableMap { - my ($type, $map) = @_; - +sub enable_disable_maps { + my (@what) = @_; my $tc = $alldata->{'changes_config'}; - - die "$prg: invalid mapType $type" if ($type !~ m/^(Map|MixedMap)$/); die "$prg: top config file $tc has not been read." if (!defined($alldata->{'updmap'}{$tc})); + my $changed = 0; + for my $w (@what) { + if ($w =~ m/=/) { + # this is --enable MapType=MapName + my ($type, $map) = split ('=', $w); + enable_map($tc, $type, $map); + } else { + # this is --disable MapName + disable_map($tc, $w); + } + } + return save_updmap($tc); +} + +sub enable_map { + my ($tc, $type, $map) = @_; + + die "$prg: invalid mapType $type" if ($type !~ m/^(Map|MixedMap)$/); if (defined($alldata->{'updmap'}{$tc}{'maps'}{$map})) { # the map data has already been read in, no special precautions necessary if (($alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} eq "enabled") && ($alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} eq $type)) { # nothing to do here ... be happy! - return 0; + return; } else { $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "enabled"; $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} = $type; $alldata->{'maps'}{$map}{'origin'} = $tc; + $alldata->{'maps'}{$map}{'status'} = "enabled"; $alldata->{'updmap'}{$tc}{'changed'} = 1; - return save_updmap($tc); } } else { # add a new map file! @@ -979,46 +985,41 @@ sub enableMap { $alldata->{'updmap'}{$tc}{'maps'}{$map}{'line'} = -1; $alldata->{'updmap'}{$tc}{'changed'} = 1; $alldata->{'maps'}{$map}{'origin'} = $tc; - return save_updmap($tc); + $alldata->{'maps'}{$map}{'status'} = "enabled"; } } -sub disableMap { - my $map = shift; - - my $tc = $alldata->{'changes_config'}; - - die "$prg: top config file $tc has not been read." - if (!defined($alldata->{'updmap'}{$tc})); +sub disable_map { + my ($tc, $map) = @_; if (defined($alldata->{'updmap'}{$tc}{'maps'}{$map})) { # the map data has already been read in, no special precautions necessary if ($alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} eq "disabled") { # nothing to do here ... be happy! - return 0; } else { $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "disabled"; + $alldata->{'maps'}{$map}{'origin'} = $tc; + $alldata->{'maps'}{$map}{'status'} = "disabled"; $alldata->{'updmap'}{$tc}{'changed'} = 1; - return save_updmap($tc); } } else { # disable a Map type that might be activated in a lower ranked updmap.cfg if (!defined($alldata->{'maps'}{$map})) { warning("Map is not present anywhere, why should I disable it?\n"); - return 0; + return; } my $orig = $alldata->{'maps'}{$map}{'origin'}; # add a new entry to the top level where we disable it # copy over the type from the last entry $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} = $alldata->{'updmap'}{$orig}{'maps'}{$map}{'type'}; - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "enabled"; + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "disabled"; $alldata->{'updmap'}{$tc}{'maps'}{$map}{'line'} = -1; # rewrite the origin $alldata->{'maps'}{$map}{'origin'} = $tc; + $alldata->{'maps'}{$map}{'status'} = "disabled"; # go on for writing $alldata->{'updmap'}{$tc}{'changed'} = 1; - return save_updmap($tc); } } -- cgit v1.2.3