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

commits+karl at tug.org commits+karl at tug.org
Tue Nov 12 00:16:13 CET 2019


Revision: 52741
          http://tug.org/svn/texlive?view=revision&revision=52741
Author:   karl
Date:     2019-11-12 00:16:13 +0100 (Tue, 12 Nov 2019)
Log Message:
-----------
(rebuild_one_format): copy log file even if
fmtutil cmd failed, so it's available for inspection.
Other wording/syntax changes.

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	2019-11-11 23:12:53 UTC (rev 52740)
+++ trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl	2019-11-11 23:16:13 UTC (rev 52741)
@@ -162,7 +162,7 @@
     $opts{'user'} = 1;
 
     GetOptions ( "help" => \$opts{'help'}, "version" => \$opts{'version'} )
-        or die "Unknown option in mktexfmt command line arguments\n";
+      || die "$prg: Unknown option in mktexfmt command line arguments.\n";
     if ($ARGV[0]) {
       if ($ARGV[0] =~ m/^(.*)\.(fmt|mem|base?)$/) {
         $opts{'byfmt'} = $1;
@@ -447,12 +447,12 @@
   for (@deferred_stdout) { print $stdo $_; }
   for (@deferred_stderr) { print STDERR $_; }
   #
-  print_info("Disabled formats: $disabled\n")        if ($disabled);
-  print_info("Successfully rebuilt formats: $suc\n") if ($suc);
-  print_info("Not selected formats: $nobuild\n")     if ($nobuild);
-  print_info("Not available formats: $notavail\n")   if ($notavail);
-  print_info("Failed to build: $err (@err)\n")       if ($err);
-  print_info("Total formats: $total\n");
+  print_info("disabled formats: $disabled\n")        if ($disabled);
+  print_info("successfully rebuilt formats: $suc\n") if ($suc);
+  print_info("not selected formats: $nobuild\n")     if ($nobuild);
+  print_info("not available formats: $notavail\n")   if ($notavail);
+  print_info("failed to build: $err (@err)\n")       if ($err);
+  print_info("total formats: $total\n");
   chdir($thisdir) || warn "chdir($thisdir) failed: $!";
   if (win32()) {
     # try to remove the tmpdir with all files
@@ -516,7 +516,7 @@
     }
   }
   if ($doit) {
-    return rebuild_one_format($fmt, $eng, $kpsefmt, $destdir, $fmtfile, $logfile);
+    return rebuild_one_format($fmt,$eng,$kpsefmt,$destdir,$fmtfile,$logfile);
   } else {
     return $FMT_NOTSELECTED;
   }
@@ -523,8 +523,9 @@
 }
 
 # 
 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)
+# takes fmt/eng and returns the locations where format and log files
+# should be saved, that is, a list: (dump file full path, log file full path)
+# 
 sub compute_format_destination {
   my ($fmt, $eng) = @_;
   my $enginedir;
@@ -557,11 +558,12 @@
 
 
 # 
 rebuild_one_format
-# takes fmt/eng and rebuilds it, irrelevant of any setting
+# takes fmt/eng and rebuilds it, irrelevant of any setting;
+# copies generated log file
 # return value FMT_*
 #
 sub rebuild_one_format {
-  my ($fmt, $eng, $kpsefmt, $destdir, $fmtfile, $logfile) = @_;
+  my ($fmt,$eng,$kpsefmt,$destdir,$fmtfile,$logfile) = @_;
   print_info("--- remaking $fmt with $eng\n");
 
   # get variables
@@ -575,7 +577,7 @@
   my $pool;
   my $tcx = "";
   my $tcxflag = "";
-  my $localpool=0;
+  my $localpool = 0;
   my $texargs;
 
   unlink glob "*.pool";
@@ -624,7 +626,7 @@
     $texargs = $addargs;
   }
   if ($pool) {
-    chomp ( my $poolfile = `kpsewhich -progname=$eng $pool.poo 2>$nul` );
+    chomp (my $poolfile = `kpsewhich -progname=$eng $pool.poo 2>$nul`);
     if ($poolfile && -f $poolfile) {
       print_verbose("attempting to create localized format "
                     . "using pool=$pool and tcx=$tcx.\n");
@@ -656,7 +658,7 @@
         ",$opts{'no-error-if-no-engine'}," =~ m/,$eng,/) {
       return $FMT_NOTAVAIL;
     } else {
-      print_deferred_error("not building $fmt due to missing engine $eng.\n");
+      print_deferred_error("not building $fmt due to missing engine: $eng\n");
       return $FMT_FAILURE;
     }
   }
@@ -675,19 +677,35 @@
     $cmdline .= " >&2" if $mktexfmtMode;
     $cmdline .= " <$nul";
     my $retval = system($cmdline);
+    
+    # report error if it failed.
     if ($retval != 0) {
       $retval /= 256 if ($retval > 0);
-      print_deferred_error("running \`$cmdline' return status $retval\n");
-      #
-      # original shell script did *not* check the return value
-      # we keep this behavior, but add an option --strict that
-      # errors out on all failures.
-      if ($opts{'strict'}) {
-        print_deferred_error("return error due to options --strict\n");
-        return $FMT_FAILURE;
-      }
+      print_deferred_error("running \`$cmdline' return status: $retval\n");
     }
 
+    # Copy the log file after the program is run, so that the log file
+    # is available to inspect even on failure. So we need the dest dir tree.
+    TeXLive::TLUtils::mkdirhier($destdir);
+    #
+    # Here and in the following we use copy instead of move
+    # to make sure that in SElinux enabled cases the rules of
+    # the destination directory are applied.
+    # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900580
+    if (File::Copy::copy($logfile, "$destdir/$logfile")) {
+      print_info("log file copied to: $destdir/$logfile\n");
+    } else {
+      print_deferred_error("cannot copy log $logfile to: $destdir\n");
+    }
+
+    # original shell script did *not* check the return value
+    # we keep this behavior, but add an option --strict that
+    # errors out on all failures.
+    if ($retval != 0 && $opts{'strict'}) {
+      print_deferred_error("returning error due to option --strict\n");
+      return $FMT_FAILURE;
+    }
+
     if ($localpool) {
       if ($texpool) {
         $ENV{'TEXPOOL'} = $texpool;
@@ -695,7 +713,6 @@
         delete $ENV{'TEXPOOL'};
       }
     }
-
   }
 
   # check and install of fmt and log files
@@ -717,27 +734,18 @@
     print_deferred_error("\`$cmdline' had errors.\n");
   }
 
-  TeXLive::TLUtils::mkdirhier($destdir);
-  
-  # here and in the following we use copy instead of move
-  # to make sure that in SElinux enabled cases the rules of
-  # the destination directory are applied.]
-  # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900580
-  if (!File::Copy::copy( $logfile, "$destdir/$logfile")) {
-    print_deferred_error("Cannot copy $logfile to $destdir.\n");
-  }
   if ($opts{'recorder'}) {
-    # the recorder output is used by check-fmttriggers to determine
+    # the recorder output is used by tl-check-fmttriggers to determine
     # 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::copy( $recfile, "$destdir/$recfile")) {
-      print_deferred_error("Cannot copy $recfile to $destdir.\n");
+    if (!File::Copy::copy($recfile, "$destdir/$recfile")) {
+      print_deferred_error("cannot copy recorder $recfile to: $destdir\n");
     }
   }
 
   my $destfile = "$destdir/$fmtfile";
-  if (File::Copy::copy( $fmtfile, $destfile )) {
+  if (File::Copy::copy($fmtfile, $destfile )) {
     print_info("$destfile installed.\n");
     #
     # original fmtutil.sh did some magic trick for mplib-luatex.mem
@@ -784,10 +792,10 @@
     return $FMT_SUCCESS;
 
   } else {
-    print_deferred_error("Cannot copy $fmtfile to $destfile.\n");
+    print_deferred_error("cannot copy format $fmtfile to: $destfile\n");
     if (-f $destfile) {
       # remove the empty file possibly left over if near-full file system.
-      print_verbose("Removing partial file after copy failure: $destfile\n");
+      print_verbose("removing partial file after copy failure: $destfile\n");
       unlink($destfile)
         || print_deferred_error("unlink($destfile) failed: $!\n");
     }
@@ -1032,7 +1040,7 @@
     my @tmp;
     for my $f (@{$opts{'cnffile'}}) {
       if (! -f $f) {
-        die "$prg: Config file \"$f\" not found.";
+        die "$prg: Config file \"$f\" not found";
       }
       push @tmp, (win32() ? lc($f) : $f);
     }



More information about the tex-live-commits mailing list