texlive[45870] Master/texmf-dist/scripts/texlive/fmtutil.pl: fmtutil

commits+preining at tug.org commits+preining at tug.org
Tue Nov 21 08:07:28 CET 2017


Revision: 45870
          http://tug.org/svn/texlive?view=revision&revision=45870
Author:   preining
Date:     2017-11-21 08:07:26 +0100 (Tue, 21 Nov 2017)
Log Message:
-----------
fmtutil missing/refresh part 1: factor out file naming code

Modified Paths:
--------------
    trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl

Modified: trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl	2017-11-21 01:22:25 UTC (rev 45869)
+++ trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl	2017-11-21 07:07:26 UTC (rev 45870)
@@ -516,6 +516,40 @@
   }
 }
 
+# 
 compute_format_destination
+# takes fmt/eng and returns the location where format and log files should be saved
+# return value (dump file full path, log file full path)
+sub compute_format_destination {
+  my ($fmt, $eng) = @_;
+  my $enginedir;
+  my $fmtfile = $fmt;
+  my $kpsefmt;
+  my $destdir;
+
+  if ($eng eq "mpost") {
+    $fmtfile .= ".mem" ;
+    $kpsefmt = "mp" ;
+    $enginedir = "metapost"; # the directory, not the executable
+  } elsif ($eng =~ m/^mf(lua(jit)?)?(w|-nowin)?$/) {
+    $fmtfile .= ".base" ;
+    $kpsefmt = "mf" ;
+    $enginedir = "metafont" ;
+  } else {
+    $fmtfile .= ".fmt" ;
+    $kpsefmt = "tex" ;
+    $enginedir = $eng;
+    # strip final -dev from enginedir to support engines like luatex-dev
+    $enginedir =~ s/-dev$//;
+  }
+  if ($opts{'no-engine-subdir'}) {
+    $destdir = $opts{'fmtdir'};
+  } else {
+    $destdir = "$opts{'fmtdir'}/$enginedir";
+  }
+  return($kpsefmt, $destdir, $fmtfile, "$fmt.log");
+}
+
+
 # 
 rebuild_one_format
 # takes fmt/eng and rebuilds it, irrelevant of any setting
 # return value FMT_*
@@ -529,12 +563,9 @@
   my $addargs = $alldata->{'merged'}{$fmt}{$eng}{'args'};
 
   # running parameters
-  my $enginedir;
   my $jobswitch = "-jobname=$fmt";
   my $prgswitch = "-progname=" ;
   my $recorderswitch = ($opts{'recorder'} ? "-recorder" : "");
-  my $fmtfile = $fmt;
-  my $kpsefmt;
   my $pool;
   my $tcx = "";
   my $tcxflag = "";
@@ -541,6 +572,8 @@
   my $localpool=0;
   my $texargs;
 
+  my ($kpsefmt, $destdir, $fmtfile, $logfile) = compute_format_destination($fmt, $eng);
+
   unlink glob "*.pool";
 
   # addargs processing:
@@ -557,22 +590,6 @@
   elsif ($fmt =~ m/^cont-..$/) { $prgswitch .= "context"; }
   else                         { $prgswitch .= $fmt; }
 
-  if ($eng eq "mpost") { 
-    $fmtfile .= ".mem" ; 
-    $kpsefmt = "mp" ; 
-    $enginedir = "metapost"; # the directory, not the executable
-  } elsif ($eng =~ m/^mf(lua(jit)?)?(w|-nowin)?$/) {
-    $fmtfile .= ".base" ; 
-    $kpsefmt = "mf" ; 
-    $enginedir = "metafont";
-  } else {
-    $fmtfile .= ".fmt" ; 
-    $kpsefmt = "tex" ; 
-    $enginedir = $eng;
-    # strip final -dev from enginedir to support engines like luatex-dev
-    $enginedir =~ s/-dev$//;
-  }
-  
   # check for existence of ini file before doing anything else
   if (system("kpsewhich -progname=$fmt -format=$kpsefmt $inifile >$nul 2>&1") != 0) {
     # we didn't find the ini file, skip
@@ -683,13 +700,13 @@
     return $FMT_FAILURE;
   }
 
-  if (! -f "$fmt.log") {
+  if (! -f $logfile) {
     print_deferred_error("no log file generated for $fmt/$eng, strange\n");
     return $FMT_FAILURE;
   }
 
-  open (LOGFILE, "<$fmt.log")
-    || print_deferred_warning("cannot open $fmt.log, strange: $!\n");
+  open (LOGFILE, "<$logfile")
+    || print_deferred_warning("cannot open $logfile, strange: $!\n");
   my @logfile = <LOGFILE>;
   close LOGFILE;
   if (grep(/^!/, @logfile) > 0) {
@@ -696,16 +713,10 @@
     print_deferred_error("\`$cmdline' had errors.\n");
   }
 
-  my $fulldestdir;
-  if ($opts{'no-engine-subdir'}) {
-    $fulldestdir = $opts{'fmtdir'};
-  } else {
-    $fulldestdir = "$opts{'fmtdir'}/$enginedir";
-  }
-  TeXLive::TLUtils::mkdirhier($fulldestdir);
+  TeXLive::TLUtils::mkdirhier($destdir);
   
-  if (!File::Copy::move( "$fmt.log", "$fulldestdir/$fmt.log")) {
-    print_deferred_error("Cannot move $fmt.log to $fulldestdir.\n");
+  if (!File::Copy::move( $logfile, "$destdir/$logfile")) {
+    print_deferred_error("Cannot move $logfile to $destdir.\n");
   }
   if ($opts{'recorder'}) {
     # the recorder output is used by check-fmttriggers to determine
@@ -712,12 +723,12 @@
     # package dependencies for each format.  Unfortunately omega-based
     # engines gratuitiously changed the extension from .fls to .ofl.
     my $recfile = $fmt . ($fmt =~ m/^(aleph|lamed)$/ ? ".ofl" : ".fls");
-    if (!File::Copy::move( $recfile, "$fulldestdir/$recfile")) {
-      print_deferred_error("Cannot move $recfile to $fulldestdir.\n");
+    if (!File::Copy::move( $recfile, "$destdir/$recfile")) {
+      print_deferred_error("Cannot move $recfile to $destdir.\n");
     }
   }
 
-  my $destfile = "$fulldestdir/$fmtfile";
+  my $destfile = "$destdir/$fmtfile";
   if (File::Copy::move( $fmtfile, $destfile )) {
     print_info("$destfile installed.\n");
     #



More information about the tex-live-commits mailing list