diff options
author | Karl Berry <karl@freefriends.org> | 2021-07-25 18:05:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-07-25 18:05:31 +0000 |
commit | 67bab1444fb849ae3225b5674bba43ecc68c0f83 (patch) | |
tree | 5db5041df05d573f8e272a98c7a6435d6bc9b6c0 | |
parent | 4605c296898dc8fa29423271a085e2b6ed97eb77 (diff) |
make --dry-run drier
git-svn-id: svn://tug.org/texlive/trunk@60056 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/texmf-dist/scripts/texlive/fmtutil.pl | 34 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tl-check-fmtshare | 2 |
2 files changed, 24 insertions, 12 deletions
diff --git a/Master/texmf-dist/scripts/texlive/fmtutil.pl b/Master/texmf-dist/scripts/texlive/fmtutil.pl index 710d1fae740..ba00242710d 100755 --- a/Master/texmf-dist/scripts/texlive/fmtutil.pl +++ b/Master/texmf-dist/scripts/texlive/fmtutil.pl @@ -432,12 +432,14 @@ sub callback_build_formats { # # 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 @@ sub rebuild_one_format { # 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 @@ sub rebuild_one_format { } } + # 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 @@ sub determine_config_files { # 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)); diff --git a/Master/tlpkg/bin/tl-check-fmtshare b/Master/tlpkg/bin/tl-check-fmtshare index 341e7857aa9..d522a22c248 100755 --- a/Master/tlpkg/bin/tl-check-fmtshare +++ b/Master/tlpkg/bin/tl-check-fmtshare @@ -163,7 +163,7 @@ mkfmt () 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 |