diff options
author | Karl Berry <karl@freefriends.org> | 2024-01-27 22:48:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-01-27 22:48:16 +0000 |
commit | 9513319f6e942568566a4e53e084a28786639d6a (patch) | |
tree | a505e13f032ec74a92ebdd0e95e08fca2e4acb2c | |
parent | f60374274cc104e16e252feb7bb910faff4b1a04 (diff) |
TLUtils.pm (run_cmd_with_log),
(update_context_cache): new fns, mostly taken from install-tl.
Hopefully to be used by tlmgr.
install-tl (run_postinst_cmd): call run_cmd_with_log.
(create_welcome): play with newlines, en passant.
git-svn-id: svn://tug.org/texlive/trunk@69614 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/install-tl | 49 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 89 |
2 files changed, 100 insertions, 38 deletions
diff --git a/Master/install-tl b/Master/install-tl index 1c53a8304c5..d59b4d8dc42 100755 --- a/Master/install-tl +++ b/Master/install-tl @@ -1161,21 +1161,8 @@ sub do_installation { sub run_postinst_cmd { my ($cmd) = @_; - - info ("running $cmd ..."); - my ($out,$ret) = TeXLive::TLUtils::run_cmd ("$cmd 2>&1"); - if ($ret == 0) { - info ("done\n"); - } else { - info ("failed\n"); - tlwarn ("$0: $cmd failed (status $ret): $!\n"); - $ret = 1; # be sure we don't overflow the sum on anything crazy - } - log ($out); - - return $ret; -} # run_postinst_cmd - + &TeXLive::TLUtils::run_cmd_with_log ($cmd, \&log); +} # # Make texmf.cnf, backup directory, cleanups, path setting, and @@ -1351,22 +1338,15 @@ operations might be disturbed.\n\n"; } } - # lmtx/context setup. The story here is that in 2023, the lmtx binary - # for x86_64-linux was too new to run on the system where we build TL. - # (luametatex: /lib64/libm.so.6: version `GLIBC_2.23' not found) - # So we have to try running it to see it succeeds, not just test for - # the program's existence. And since it exits nonzero given no args, - # we have to specify --version. Hope it keeps working like that ... - my $lmtx = "$plat_bindir/luametatex$progext"; + # lmtx/context cache setup, relegated to a common subroutine + # that tlmgr can also call. if (exists($install{"context"}) && $install{"context"} == 1 - && !exists $ENV{"TEXLIVE_INSTALL_NO_CONTEXT_CACHE"} - && TeXLive::TLUtils::system_ok("$lmtx --version") - ) { - info("setting up ConTeXt cache: "); - $errcount += run_postinst_cmd("mtxrun --generate"); - $errcount += run_postinst_cmd("context --luatex --generate"); + && !exists $ENV{"TEXLIVE_INSTALL_NO_CONTEXT_CACHE"}) { + $errcount += + TeXLive::TLUtils::update_context_cache($plat_bindir, $progext, + \&run_postinst_cmd); } else { - debug("skipped ConTeXt cache setup\n"); + debug("skipped ConTeXt cache setup, not installed or told not to\n"); } # all formats option @@ -2832,21 +2812,18 @@ EOF # Create a welcome message. sub create_welcome { @::welcome_arr = (); - push @::welcome_arr, "\n"; push @::welcome_arr, __("Welcome to TeX Live!"); - push @::welcome_arr, "\n"; - push @::welcome_arr, __( - "See %s/index.html for links to documentation.\nThe TeX Live web site (https://tug.org/texlive/) contains any updates and corrections. TeX Live is a joint project of the TeX user groups around the world; please consider supporting it by joining the group best for you. The list of groups is available on the web at https://tug.org/usergroups.html.", - $::vars{'TEXDIR'}); + push @::welcome_arr, __("See %s/index.html for links to documentation.\n", + $::vars{'TEXDIR'}); + push @::welcome_arr, __("The TeX Live web site (https://tug.org/texlive/) provides all updates\nand corrections. TeX Live is a joint project of the TeX user groups\naround the world; please consider supporting it by joining the group\nbest for you. The list of groups is available on the web\nat https://tug.org/usergroups.html.\n"); if (wndws() || ($vars{'instopt_adjustpath'} && $vars{'tlpdbopt_desktop_integration'} != 2)) { ; # don't tell them to make path adjustments on Windows, # or if they chose to "create symlinks". } else { - push @::welcome_arr, "\n"; push @::welcome_arr, __( - "Add %s/texmf-dist/doc/man to MANPATH.\nAdd %s/texmf-dist/doc/info to INFOPATH.\nMost importantly, add %s/bin/%s\nto your PATH for current and future sessions.", + "Add %s/texmf-dist/doc/man to MANPATH.\nAdd %s/texmf-dist/doc/info to INFOPATH.\nMost importantly, add %s/bin/%s\nto your PATH for current and future sessions.\n", $::vars{'TEXDIR'}, $::vars{'TEXDIR'}, $::vars{'TEXDIR'}, $::vars{'this_platform'}); } diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index 4997be204d8..7cbf7be3b53 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -41,6 +41,7 @@ C<TeXLive::TLUtils> - TeX Live infrastructure miscellany TeXLive::TLUtils::wsystem($msg,@args); TeXLive::TLUtils::xsystem(@args); TeXLive::TLUtils::run_cmd($cmd [, @envvars ]); + TeXLive::TLUtils::run_cmd_with_log($cmd, $logfn); TeXLive::TLUtils::system_pipe($prog, $infile, $outfile, $removeIn, @args); TeXLive::TLUtils::diskfree($path); TeXLive::TLUtils::get_user_home(); @@ -80,6 +81,7 @@ C<TeXLive::TLUtils> - TeX Live infrastructure miscellany TeXLive::TLUtils::time_estimate($totalsize, $donesize, $starttime) TeXLive::TLUtils::install_packages($from_tlpdb,$media,$to_tlpdb,$what,$opt_src, $opt_doc, $retry, $continue); TeXLive::TLUtils::do_postaction($how, $tlpobj, $do_fileassocs, $do_menu, $do_desktop, $do_script); + TeXLive::TLUtils::update_context_cache($plat_bindir); TeXLive::TLUtils::announce_execute_actions($how, @executes, $what); TeXLive::TLUtils::add_symlinks($root, $arch, $sys_bin, $sys_man, $sys_info); TeXLive::TLUtils::remove_symlinks($root, $arch, $sys_bin, $sys_man, $sys_info); @@ -246,6 +248,7 @@ BEGIN { &wsystem &xsystem &run_cmd + &run_cmd_with_log &system_pipe &diskfree &get_user_home @@ -769,8 +772,9 @@ sub xsystem { =item C<run_cmd($cmd, @envvars)> -Run shell command C<$cmd> and captures its output. Returns a list with CMD's -output as the first element and the return value (exit code) as second. +Run shell command C<$cmd> and captures its standard output (not standard +error). Returns a list with CMD's output as the first element and its +return value (exit code) as second. If given, C<@envvars> is a list of environment variable name / value pairs set in C<%ENV> for the call and reset to their original value (or @@ -806,6 +810,34 @@ sub run_cmd { return ($output,$retval); } +=item C<run_cmd_with_log($cmd, $logfn)> + +Run shell command C<$cmd> and captures both standard output and standard +error (as one string), passing them to C<$logfn>. The return value is +the exit status of C<$cmd>. Environment variable overrides cannot be +passed. (This is used for running special post-installation commands in +install-tl and tlmgr.) + +=cut + +sub run_cmd_with_log { + my ($cmd,$logfn) = @_; + + info ("running $cmd ..."); + my ($out,$ret) = TeXLive::TLUtils::run_cmd ("$cmd 2>&1"); + if ($ret == 0) { + info ("done\n"); + } else { + info ("failed\n"); + tlwarn ("$0: $cmd failed (status $ret): $!\n"); + $ret = 1; # be sure we don't overflow the sum on anything crazy + } + &$logfn ($out); + + return $ret; +} # run_cmd_with_log + + =item C<system_pipe($prog, $infile, $outfile, $removeIn, @extraargs)> Runs C<$prog> with C<@extraargs> redirecting stdin from C<$infile>, @@ -2198,6 +2230,10 @@ sub _do_postaction_shortcut { return 1; } +=item C<parse_into_keywords> + +=cut + sub parse_into_keywords { my ($str, @keys) = @_; my @words = quotewords('\s+', 0, $str); @@ -2222,6 +2258,55 @@ sub parse_into_keywords { return($error, %ret); } +=item C<update_context_cache($bindir,$progext,$run_postinst_cmd)> + +Run the ConTeXt cache generation commands, using C<$bindir> and +C<$progext> to check if commands can be run. Use the function reference +C<$run_postinst_cmd> to actually run the commands. The return status is +zero if all succeeded, nonzero otherwise. If the main ConTeXt program +(C<luametatex>) cannot be run at all, the return status is status. + +Functions C<info> and C<debug> are called with status reports. + +=cut + +sub update_context_cache { + my ($bindir,$progext,$run_postinst_cmd) = @_; + + my $errcount = 0; + + # The story here is that in 2023, the lmtx binary for x86_64-linux was + # too new to run on the system where we build TL. (luametatex: + # /lib64/libm.so.6: version `GLIBC_2.23' not found) So we have to try + # running it to see if it is available, not just test for the + # program's existence. And since it exits nonzero given no args, we + # have to specify --version. Hope it keeps working like that ... + # + # If lmtx is not runnable, don't consider that an error, since nothing + # can be done about it. + my $lmtx = "$bindir/luametatex$progext"; + if (TeXLive::TLUtils::system_ok("$lmtx --version")) { + info("setting up ConTeXt cache: "); + $errcount += &$run_postinst_cmd("mtxrun --generate"); + # + # If mtxrun failed, don't bother trying more. + if ($errcount == 0) { + $errcount += &$run_postinst_cmd("context --luatex --generate"); + # + # If context succeeded too, try luajittex. Missing on some platforms. + if ($errcount == 0) { + my $luajittex = "$bindir/luajittex$progext"; + if (TeXLive::TLUtils::system_ok("$luajittex --version")) { + $errcount += &$run_postinst_cmd("context --luajittex --generate"); + } else { + debug("skipped luajittex cache setup, can't run $luajittex\n"); + } + } + } + } + return $errcount; +} + =item C<announce_execute_actions($how, $tlpobj, $what)> Announces that the actions given in C<$tlpobj> should be executed |