From 15f554902e0d3fd0d8ed695458d290e26aa546fd Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 3 Jan 2010 04:04:57 +0000 Subject: support overriding updmap.cfg settings in updmap-local.cfg git-svn-id: svn://tug.org/texlive/trunk@16583 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLUtils.pm | 89 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 4 deletions(-) (limited to 'Master/tlpkg/TeXLive/TLUtils.pm') diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index 7e87a5c6f9f..aebf0203b80 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -2382,10 +2382,90 @@ sub create_fmtutil { sub create_updmap { my ($tlpdb,$dest,$localconf) = @_; - my @lines = $tlpdb->updmap_cfg_lines( - get_disabled_local_configs($localconf, '#')); - _create_config_files($tlpdb, "texmf/web2c/updmap-hdr.cfg", $dest, - $localconf, 0, '#', \@lines); + my @tlpdblines = $tlpdb->updmap_cfg_lines( + get_disabled_local_configs($localconf, '#')); + # we do not use _create_config_files here because we want to + # parse the $localconf file for the five options in updmap.cfg + #_create_config_files($tlpdb, "texmf/web2c/updmap-hdr.cfg", $dest, + # $localconf, 0, '#', \@tlpdblines); + my $headfile = "texmf/web2c/updmap-hdr.cfg"; + my $root = $tlpdb->root; + my @lines; + my @localconflines; + my %configs; + if (-r "$localconf") { + # + # this should be done more intelligently, but for now only add those + # lines without any duplication check ... + open FOO, "<$localconf" + or die "strange, -r ok but cannot open $localconf: $!"; + my @bla = ; + close(FOO); + for my $l (@bla) { + my ($k, $v, @rest) = split(' ', $l); + if (check_updmap_config_value($k, $v, $localconf)) { + $configs{$k} = $v; + } else { + push @localconflines, $l; + } + } + } + # + # read the -hdr file and replace the options if given in the local + # config file + open(INFILE,"<$root/$headfile") or die("Cannot open $root/$headfile"); + for my $l () { + my ($k, $v, @rest) = split(' ', $l); + if (check_updmap_config_value($k, $v, "$root/$headfile")) { + if (defined($configs{$k})) { + push @lines, "$k $configs{$k}\n"; + } else { + push @lines, $l; + } + } else { + push @lines, $l; + } + } + close (INFILE); + + # add the lines from the tlpdb + push @lines, @tlpdblines; + + # add additional local config lines + push @lines, @localconflines; + + if ($#lines >= 0) { + open(OUTFILE,">$dest") + or die("Cannot open $dest for writing: $!"); + + printf OUTFILE "# Generated by %s on %s\n", "$0", scalar localtime; + print OUTFILE @lines; + close(OUTFILE) || warn "close(>$dest) failed: $!"; + } +} + +sub check_updmap_config_value { + my ($k, $v, $f) = @_; + return 0 if !defined($k); + return 0 if !defined($v); + if (member( $k, qw/dvipsPreferOutline dvipsDownloadBase35 + pdftexDownloadBase14 dvipdfmDownloadBase14/)) { + if ($v eq "true" || $v eq "false") { + return 1; + } else { + tlwarn("Unknown setting for $k in $f: $v\n"); + return 0; + } + } elsif ($k eq "LW35") { + if (member($v, qw/URW URWkb ADOBE ADOBEkb/)) { + return 1; + } else { + tlwarn("Unknown setting for LW35 in $f: $v\n"); + return 0; + } + } else { + return 0; + } } sub create_language_dat { @@ -2423,6 +2503,7 @@ sub _create_config_files { open FOO, "<$localconf" or die "strange, -r ok but cannot open $localconf: $!"; my @tmp = ; + close (FOO); push @lines, @tmp; } if (@postlines) { -- cgit v1.2.3