texlive[60056] Master: make --dry-run drier

commits+karl at tug.org commits+karl at tug.org
Sun Jul 25 20:05:31 CEST 2021


Revision: 60056
          http://tug.org/svn/texlive?view=revision&revision=60056
Author:   karl
Date:     2021-07-25 20:05:31 +0200 (Sun, 25 Jul 2021)
Log Message:
-----------
make --dry-run drier

Modified Paths:
--------------
    trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl
    trunk/Master/tlpkg/bin/tl-check-fmtshare

Modified: trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl	2021-07-25 17:24:28 UTC (rev 60055)
+++ trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl	2021-07-25 18:05:31 UTC (rev 60056)
@@ -432,12 +432,14 @@
   #
   # for formats that load other formats (e.g., jadetex loads latex.fmt),
   # add the current directory to TEXFORMATS, too.  Currently unnecessary
-  # for MFBASES and MPMEMS.
+  # for MFBASES.
   $ENV{'TEXFORMATS'} ||= "";
   $ENV{'TEXFORMATS'} = "$tmpdir$sep$ENV{TEXFORMATS}";
 
-  # switch to temporary directory for format generation
-  $opts{"dry-run"} || chdir($tmpdir)
+  # switch to temporary directory for format generation; on the other hand,
+  # for -n, the tmpdir won't exist, but we don't want to find a spurious
+  # tex.fmt in the cwd. Probably won't be such things in /.
+  chdir($opts{"dry-run"} ? "/" : $tmpdir)
   || die "Cannot change to directory $tmpdir: $!";
   
   # we rebuild formats in two rounds:
@@ -797,11 +799,14 @@
     # 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 (TeXLive::TLUtils::copy("-f", $logfile, "$destdir/$logfile")) {
-      print_info("log file copied to: $destdir/$logfile\n");
+    if ($opts{"dry-run"}) {
+      print_info("would copy log file to: $destdir/$logfile\n");
     } else {
-      print_deferred_error("cannot copy log $logfile to: $destdir\n")
-        unless $opts{"dry-run"};
+      if (TeXLive::TLUtils::copy("-f", $logfile, "$destdir/$logfile")) {
+        print_info("log file copied to: $destdir/$logfile\n");
+      } else {
+        print_deferred_error("failed to copy log $logfile to: $destdir\n");
+      }
     }
 
     # original shell script did *not* check the return value
@@ -821,14 +826,21 @@
     }
   }
 
+  # if this was a dry run, we don't expect anything to have been
+  # created, so there's nothing to inspect or copy. Call it good.
+  if ($opts{"dry-run"}) {
+    print_info("dry run, so returning success: $fmtfile\n");
+    return $FMT_SUCCESS;
+  }
+
   # check and install of fmt and log files
-  if (! -f $fmtfile) {
-    print_deferred_error("\`$cmdline' failed (no $fmtfile)\n");
+  if (! -s $fmtfile) {
+    print_deferred_error("no (or empty) $fmtfile made by: $cmdline\n");
     return $FMT_FAILURE;
   }
 
   if (! -f $logfile) {
-    print_deferred_error("no log file generated for $fmt/$eng, strange\n");
+    print_deferred_error("no log file generated for: $fmt/$eng\n");
     return $FMT_FAILURE;
   }
 
@@ -1243,7 +1255,7 @@
 # returns 1 if actually saved due to changes
 sub save_fmtutil {
   my $fn = shift;
-  return if $opts{'dry-run'};
+  return 0 if $opts{'dry-run'};
   my %fmtf = %{$alldata->{'fmtutil'}{$fn}};
   if ($fmtf{'changed'}) {
     TeXLive::TLUtils::mkdirhier(dirname($fn));

Modified: trunk/Master/tlpkg/bin/tl-check-fmtshare
===================================================================
--- trunk/Master/tlpkg/bin/tl-check-fmtshare	2021-07-25 17:24:28 UTC (rev 60055)
+++ trunk/Master/tlpkg/bin/tl-check-fmtshare	2021-07-25 18:05:31 UTC (rev 60056)
@@ -163,7 +163,7 @@
   ffot=$outdir/`basename $fmt .fmt`-fmtutil.fot
   #
   echo "$0: running: $fcmd" >"$ffot"
-  if $fcmd >>"$ffot" 2>&1; then :;
+  if $fcmd >>"$ffot" 2>&1; then :; else
     echo "$0: could not get cmdline to build $fmt" >&2
     echo "$0:  fmtutil command failed: $fcmd" >&2
     echo "$0:  see transcript: $ffot" >&2



More information about the tex-live-commits mailing list.