summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2015-06-15 00:00:21 +0000
committerNorbert Preining <preining@logic.at>2015-06-15 00:00:21 +0000
commitc7c5f41fdb3a0f90beb334970fa385bcb33e43f7 (patch)
treee05b4a28675c4c2bb7254c91c23f3ef3d6ed5369 /Master/texmf-dist
parent9c9c9e3293bf5c7dcb873197bd7efdab74f015c3 (diff)
fmtutil: add save_fmtutil function, get enablefmt working
git-svn-id: svn://tug.org/texlive/trunk@37539 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/fmtutil.pl70
1 files changed, 67 insertions, 3 deletions
diff --git a/Master/texmf-dist/scripts/texlive/fmtutil.pl b/Master/texmf-dist/scripts/texlive/fmtutil.pl
index b8b73efe3f2..4650d82a9ca 100755
--- a/Master/texmf-dist/scripts/texlive/fmtutil.pl
+++ b/Master/texmf-dist/scripts/texlive/fmtutil.pl
@@ -669,10 +669,10 @@ sub enable_disable_format_engine {
}
$alldata->{'fmtutil'}{$tc}{'formats'}{$fmt}{$eng}{'status'} = $mode;
$alldata->{'fmtutil'}{$tc}{'formats'}{$fmt}{$eng}{'line'} = -1;
- $alldata->{'fmtutil'}{$tc}{'formats'}{$fmt}{$eng}{'changed'} = 1;
+ $alldata->{'fmtutil'}{$tc}{'changed'} = 1;
$alldata->{'merged'}{$fmt}{$eng}{'status'} = $mode;
$alldata->{'merged'}{$fmt}{$eng}{'origin'} = $tc;
- dump_data();
+ # dump_data();
return save_fmtutil($tc);
}
} else {
@@ -755,8 +755,11 @@ sub read_fmtutil_files {
my (@l) = @_;
for my $l (@l) { read_fmtutil_file($l); }
# in case the changes_config is a new one read it in and initialize it here
+ # the file might be already readable but not in ls-R so not found by
+ # kpsewhich. That means we need to check that it is readable and whether
+ # the lines entry is already defined
my $cc = $alldata->{'changes_config'};
- if (! -r $cc) {
+ if ((! -r $cc) || (!$alldata->{'fmtutil'}{$cc}{'lines'}) ) {
$alldata->{'fmtutil'}{$cc}{'lines'} = [ ];
}
#
@@ -965,6 +968,67 @@ sub determine_config_files {
+# returns 1 if actually saved due to changes
+sub save_fmtutil {
+ my $fn = shift;
+ return if $opts{'dry-run'};
+ my %fmtf = %{$alldata->{'fmtutil'}{$fn}};
+ if ($fmtf{'changed'}) {
+ TeXLive::TLUtils::mkdirhier(dirname($fn));
+ open (FN, ">$fn") || die "$prg: can't write to $fn: $!";
+ my @lines = @{$fmtf{'lines'}};
+ if (!@lines) {
+ print "Creating new config file $fn\n";
+ # update lsR database
+ $updLSR->add($fn);
+ $updLSR->exec();
+ $updLSR->reset();
+ }
+ # collect the lines with data
+ my %line_to_fmt;
+ my @add_fmt;
+ if (defined($fmtf{'formats'})) {
+ for my $f (keys %{$fmtf{'formats'}}) {
+ for my $e (keys %{$fmtf{'formats'}{$f}}) {
+ if ($fmtf{'formats'}{$f}{$e}{'line'} == -1) {
+ push @add_fmt, [ $f, $e ];
+ } else {
+ $line_to_fmt{$fmtf{'formats'}{$f}{$e}{'line'}} = [ $f, $e ];
+ }
+ }
+ }
+ }
+ for my $i (0..$#lines) {
+ if (defined($line_to_fmt{$i})) {
+ my $f = $line_to_fmt{$i}->[0];
+ my $e = $line_to_fmt{$i}->[1];
+ my $mode = $fmtf{'formats'}{$f}{$e}{'status'};
+ my $args = $fmtf{'formats'}{$f}{$e}{'args'};
+ my $hyph = $fmtf{'formats'}{$f}{$e}{'hyphen'};
+ my $p = ($mode eq 'disabled' ? "#! " : "");
+ print FN "$p$f $e $hyph $args\n";
+ } else {
+ print FN "$lines[$i]\n";
+ }
+ }
+ # add the new settings and maps
+ for my $m (@add_fmt) {
+ my $f = $m->[0];
+ my $e = $m->[1];
+ my $mode = $fmtf{'formats'}{$f}{$e}{'status'};
+ my $args = $fmtf{'formats'}{$f}{$e}{'args'};
+ my $hyph = $fmtf{'formats'}{$f}{$e}{'hyphen'};
+ my $p = ($mode eq 'disabled' ? "#! " : "");
+ print FN "$p$f $e $hyph $args\n";
+ }
+ close(FN) || warn("$prg: Cannot close file handle for $fn: $!");
+ delete $alldata->{'fmtutil'}{$fn}{'changed'};
+ return 1;
+ }
+ return 0;
+}
+
+
#
# $HOME and sudo and updmap-sys horror
# some instances of sudo do not reset $HOME to the home of root