summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-01-31 21:52:46 +0000
committerKarl Berry <karl@freefriends.org>2024-01-31 21:52:46 +0000
commit96db2749833ba6ad4cfc1fefdceaf43c14bb9219 (patch)
treeeecf2e53379afe32f0d2cb599b622c0bb836b324 /Master/texmf-dist/scripts
parent2c188c92c394cd5b32f4352801a71fe6ac1417a5 (diff)
redirect output from context cache updating to tlmgr-commands.log or
install-tl.log, not the terminal. TLPDB.pm (_post_installpackage): new fn for common post-install code, including now recording the "context-cache" action for the context package. (install_package_files): call it. (_not_virtual_install_package): call it. (install_package): explicitly return undef on failure (unrelated). TLUtils.pm (announce_execute_actions): handle context-cache action by setting the new global $::context_cache_update_needed. tlmgr.pl (handle_execute-actions): call TLUtils::update_context_cache if the global is set. (run_postinst_logcommand): new function to run the context cache commands. (logcommand_bare): write to tlmgr-commands.log with no timestamp. tlpkg/context.tlpsrc: remove postaction. tlpkg/tlpostcode/cont-cache.{cmd,sh}: remove these scripts, as now the commands are hardwired in the code, so we can redirect the output. git-svn-id: svn://tug.org/texlive/trunk@69653 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rw-r--r--Master/texmf-dist/scripts/texlive/NEWS2
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl104
2 files changed, 86 insertions, 20 deletions
diff --git a/Master/texmf-dist/scripts/texlive/NEWS b/Master/texmf-dist/scripts/texlive/NEWS
index f3ea80ea772..943e71c3a57 100644
--- a/Master/texmf-dist/scripts/texlive/NEWS
+++ b/Master/texmf-dist/scripts/texlive/NEWS
@@ -1,6 +1,8 @@
(This file public domain. Originally written by Norbert Preining and
Karl Berry, 2010.)
+<li>redirect output from context cache updates to tlmgr-commands.log.
+
<p><b>tlmgr 69413 (released 15jan24):</b>
<li>refrain from updating if the remote repository is older than the current
installation; this is checked via the texlive-scripts package revision.
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index fa98ec783ca..e1ec0d505c4 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -65,7 +65,7 @@ BEGIN {
$kpsewhichname = "kpsewhich";
}
if (-r "$bindir/$kpsewhichname") {
- # if not in bootstrapping mode => kpsewhich exists, so use it to get $Master
+ # not in bootstrapping mode => kpsewhich exists, so use it to get $Master
chomp($Master = `kpsewhich -var-value=TEXMFROOT`);
}
@@ -835,7 +835,8 @@ sub execute_action {
# run CMD with notice to the user and if exit status is nonzero, complain.
-# return exit status.
+# log output with logcommand (tlmgr-commands.log).
+# return F_OK or F_ERROR.
#
sub do_cmd_and_check {
my $cmd = shift;
@@ -851,7 +852,8 @@ sub do_cmd_and_check {
$out = "";
} elsif (wndws() && (! -r "$Master/bin/windows/luatex.dll")) {
# deal with the case where only scheme-infrastructure is installed
- # on Windows, thus no luatex.dll is available and the wrapper cannot be started
+ # on Windows, thus no luatex.dll is available and the wrapper cannot
+ # be started
tlwarn("Cannot run wrapper due to missing luatex.dll\n");
$ret = $F_OK;
$out = "";
@@ -860,27 +862,28 @@ sub do_cmd_and_check {
}
$out =~ s/\n+$//; # trailing newlines don't seem interesting
my $outmsg = "output:\n$out\n--end of output of $cmd.\n";
- if ($ret == $F_OK) {
+ if ($ret == 0) {
info("done running $cmd.\n") unless $cmd =~ /^fmtutil/;
logcommand("success, $outmsg");
ddebug("$cmd $outmsg");
- return ($F_OK);
} else {
info("\n");
tlwarn("$prg: $cmd failed (status $ret), output:\n$out\n");
logcommand("error, status: $ret, $outmsg");
- return ($F_ERROR);
+ $ret = $F_ERROR;
}
+ return $ret;
}
# run external programs (mktexlsr, updmap-sys, etc.) as specified by the
-# keys in the RET hash. We return the number of unsuccessful runs, zero
-# if all ok.
+# keys in the ::execute_actions hash. We return the number of
+# unsuccessful runs, zero if all ok.
#
# If the "map" key is specified, the value may be a reference to a list
# of map command strings to pass to updmap, e.g., "enable Map=ascii.map".
#
sub handle_execute_actions {
+ debug("starting handle_execute_actions\n");
my $errors = 0;
my $sysmode = ($opts{"usermode"} ? "-user" : "-sys");
@@ -988,7 +991,7 @@ sub handle_execute_actions {
for my $e (keys %updated_engines) {
debug ("updating formats based on $e\n");
$errors += do_cmd_and_check
- ("$fmtutil_cmd --byengine $e --no-error-if-no-format $fmtutil_args");
+ ("$fmtutil_cmd --byengine $e --no-error-if-no-format $fmtutil_args");
read_and_report_fmtutil_status_file($status_file);
unlink($status_file);
}
@@ -1007,10 +1010,10 @@ sub handle_execute_actions {
# now go back to the hyphenation patterns and regenerate formats
# based on the various language files
- # this of course will in some cases duplicate fmtutil calls,
+ # this will in some cases duplicate fmtutil calls,
# but it is much easier than actually checking which formats
# don't need to be updated
-
+ #
if ($regenerate_language) {
for my $ext ("dat", "def", "dat.lua") {
my $lang = "language.$ext";
@@ -1030,8 +1033,9 @@ sub handle_execute_actions {
# --refresh existing formats to avoid generating new ones.
if ($::regenerate_all_formats) {
info("Regenerating existing formats, this may take some time ...");
- # --refresh might already be in $invoke_fmtutil, but we don't care
- $errors += do_cmd_and_check("$fmtutil_cmd --refresh --all $fmtutil_args");
+ # --refresh might already be in $fmtutil_args, but that's ok.
+ my $args = "--refresh --all";
+ $errors += do_cmd_and_check("$fmtutil_cmd $args $fmtutil_args");
read_and_report_fmtutil_status_file($status_file);
unlink($status_file);
info("done\n");
@@ -1039,18 +1043,70 @@ sub handle_execute_actions {
}
}
+ # lmtx/context cache creation/update. This variable is set, in
+ # TLPDB::install_package, when the context package is updated or installed.
+ if (defined $::context_cache_update_needed
+ && $::context_cache_update_needed) {
+ if ($opts{"dry-run"}) {
+ debug("dry-run, skipping context cache update\n");
+ } else {
+ my $progext = ($^O =~ /^MSWin/i ? ".exe" : "");
+ $errors +=
+ TeXLive::TLUtils::update_context_cache($bindir, $progext,
+ \&run_postinst_logcommand);
+ }
+ $::context_cache_update_needed = 0;
+ }
+
# undefine the global var, otherwise in GUI mode the actions
# are accumulating
undef %::execute_actions;
+ debug("finished handle_execute_actions, errors=$errors\n");
if ($errors > 0) {
- # should we return warning here?
+ # warning might suffice sometimes, but safer to return error.
return $F_ERROR;
} else {
return $F_OK;
}
}
+# Run CMD with output logged via logcommand(). We use this for the
+# ConTeXt cache updates (above); since they are so verbose, we want the
+# output to be only in tlmgr-commands.log, not tlmgr.log or the terminal.
+#
+# This is the same result as do_cmd_and_check, which we use for the
+# other postaction commands (fmtutil, etc.); the difference is that for
+# context, we want to share the code to actually do the updates with
+# install-tl, so there is a common routine TLUtils::update_context_cache,
+# and thus we have to handle the logging differently.
+#
+# Another approach would be to move do_cmd_and_check to TLUtils and
+# have install-tl call that. Perhaps that would be cleaner, but then
+# there is tlmgr-specific stuff that would have to be conditionalized.
+# So, not great either way. Maybe someday we will merge install-tl and tlmgr.
+#
+# As a result, the logging text here surrounding the output is mostly a
+# duplicate of what's in do_cmd_and_check.
+#
+sub run_postinst_logcommand {
+ my ($cmd) = @_;
+ logpackage("command: $cmd");
+ logcommand("running $cmd");
+ my $ret = TeXLive::TLUtils::run_cmd_with_log ($cmd, \&logcommand_bare);
+ my $outmsg = "\n--end of output of $cmd";
+ if ($ret == 0) {
+ info("done running $cmd.\n") unless $cmd =~ /^fmtutil/;
+ logcommand("$outmsg (success).\n");
+ } else {
+ info("\n");
+ tlwarn("$prg: $cmd failed (status $ret), see $commandlogfile\n");
+ logcommand("$outmsg (failure, status $ret");
+ $ret = 1;
+ }
+ return $ret;
+}
+
sub read_and_report_fmtutil_status_file {
my $status_file = shift;
my $fh;
@@ -2258,7 +2314,7 @@ sub action_backup {
if ($clean_mode) {
clear_old_backups ($pkg, $opts{"backupdir"}, $opts{"clean"}, $opts{"dry-run"}, 1);
} else {
- # for now default to xz and allow overriding with env var
+ # for now default to xz and allow overriding with envvar
my $compressorextension = $Compressors{$::progs{'compressor'}}{'extension'};
my $tlp = $localtlpdb->get_package($pkg);
my $saving_verb = $opts{"dry-run"} ? "would save" : "saving";
@@ -3530,7 +3586,6 @@ sub action_update {
print "end-of-updates\n" if $::machinereadable;
- #
# check that if updates to the critical packages are present all of
# them have been successfully updated
my $infra_update_done = 1;
@@ -3926,6 +3981,7 @@ sub action_install {
if (!$opts{"dry-run"}) {
if ($remotetlpdb->install_package($pkg, $localtlpdb,
($packs{$pkg} ? $packs{$pkg} : undef) )) {
+ # installation succeeded because we got a reference
logpackage("${re}install: $pkg$tagstr");
} else {
logpackage("failed ${re}install: $pkg$tagstr");
@@ -5433,7 +5489,8 @@ sub action_recreate_tlpdb {
next if $dirent eq ".";
next if $dirent eq "..";
next unless -d "$Master/bin/$dirent";
- if (-r "$Master/bin/$dirent/kpsewhich" || -r "$Master/bin/$dirent/kpsewhich.exe") {
+ if (-r "$Master/bin/$dirent/kpsewhich"
+ || -r "$Master/bin/$dirent/kpsewhich.exe") {
push @archs, $dirent;
debug("$prg: skipping directory $Master/bin/$dirent, no kpsewhich there\n");
}
@@ -6553,7 +6610,7 @@ sub action_key {
chomp (my $TEXMFSYSCONFIG = `kpsewhich -var-value=TEXMFSYSCONFIG`);
my $local_keyring = "$Master/tlpkg/gpg/repository-keys.gpg";
if ($arg eq 'list') {
- debug("running $::gpg --list-keys\n");
+ debug("running: $::gpg --list-keys\n");
system("$::gpg --list-keys");
return $F_OK;
} elsif ($arg eq 'remove') {
@@ -7691,11 +7748,18 @@ sub logpackage {
}
sub logcommand {
if ($commandlogfile) {
- $commandslogged++;
+ $commandslogged++; # not really counting commands logged, but calls
my $tim = localtime();
print COMMANDLOG "[$tim] @_\n";
}
}
+# without the timestamp
+sub logcommand_bare {
+ if ($commandlogfile) {
+ $commandslogged++;
+ print COMMANDLOG "@_\n";
+ }
+}
# resolve relative paths from tlpdb wrt tlroot
@@ -7767,7 +7831,7 @@ sub check_for_critical_updates {
my $localrev = $tlp->revision;
my $mtlp = $mediatlpdb->get_package($pkg);
if (!defined($mtlp)) {
- debug("Very surprising, $pkg is not present in the remote tlpdb.\n");
+ debug("Surprising, $pkg not present in remote tlpdb.\n");
next;
}
my $remoterev = $mtlp->revision;