summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2011-09-09 05:47:44 +0000
committerNorbert Preining <preining@logic.at>2011-09-09 05:47:44 +0000
commit1f61ab5c8cc9e296d8b82c9f7b54967cab7d7628 (patch)
tree184e0979488b6bf6e61a65ad2cae408b5d2b9293 /Master
parent427f461ad77c4c41d9b7bbac351660fe31d09908 (diff)
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
Diffstat (limited to 'Master')
-rw-r--r--Master/tlpkg/dev/multi-updmap.pl63
1 files changed, 32 insertions, 31 deletions
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);
}
}