diff options
author | Norbert Preining <preining@logic.at> | 2009-05-10 22:28:28 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2009-05-10 22:28:28 +0000 |
commit | fd7bb5c1f100d4dc13efa56620e7d534d2f4fd2e (patch) | |
tree | c7f9c13c5560cd2a01aa58bfbd88d11f308fd0ae | |
parent | 7f5bb8e941c9261ede147fdf1628436cdb539a44 (diff) |
various changes:
- use run_cmd in tlmgr that captures output and return value
- show output of GUI/config screen buttons in log window and not in
a separate window
git-svn-id: svn://tug.org/texlive/branches/branch2009-dev@13034 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 38 | ||||
-rw-r--r-- | Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl | 24 | ||||
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl | 52 |
3 files changed, 44 insertions, 70 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index be5e5ef94a1..fab861a322a 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -38,7 +38,7 @@ BEGIN { $mydir =~ s,/[^/]*$,,; my $kpsewhichname; if (!$^O =~ /^MSWin/i) { - $ENV{"PATH"} = "$mydir:$ENV{PATH}"; + $ENV{"PATH"} = "$mydir;$ENV{PATH}"; $kpsewhichname = "kpsewhich.exe"; } else { $kpsewhichname = "kpsewhich"; @@ -408,6 +408,21 @@ sub execute_action { + +sub do_cmd_and_check { + my $cmd = shift; + info("running $cmd ... "); + my ($out, $ret) = TeXLive::TLUtils::run_cmd("$cmd 2>&1"); + if ($ret == 0) { + info("done\n"); + log("Output of $cmd:\n$out\n"); + } else { + info("\n"); + tlwarn("$cmd failed (status $ret), output:\n$out\n"); + } + 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. @@ -420,8 +435,7 @@ sub handle_ret_hash { my $errors = 0; if (exists $ret{'mktexlsr'}) { - info("running mktexlsr\n"); - $errors += system("mktexlsr"); + $errors += do_cmd_and_check("mktexlsr"); } if (exists $ret{'map'}) { @@ -431,12 +445,9 @@ sub handle_ret_hash { # been the documented way to add fonts for many years. If we called # create_updmap, such user maps would be lost. foreach my $m (@{$ret{'map'}}) { - my $cmd = "updmap-sys --nomkmap --nohash --$m"; - info("running $cmd\n"); - $errors += system($cmd); + $errors += do_cmd_and_check("updmap-sys --nomkmap --nohash --$m"); } - info("running updmap-sys once more\n"); - $errors += system("updmap-sys"); # runs mktexlsr. + $errors += do_cmd_and_check("updmap-sys"); # runs mktexlsr. } chomp(my $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`); @@ -454,15 +465,13 @@ sub handle_ret_hash { "$TEXMFSYSVAR/web2c/fmtutil.cnf", "$TEXMFLOCAL/web2c/fmtutil-local.cnf"); if ($opt_fmt && !$ret{'format-regenerate'}) { - info("running fmtutil-sys --missing\n"); - $errors += system("fmtutil-sys", "--missing"); + $errors += do_cmd_and_check("fmtutil-sys --missing"); } } # if (exists $ret{'format-regenerate'}) { my $a = $opt_fmt ? "--all" : "--refresh"; - info("running fmtutil-sys $a to regenerate formats\n"); - $errors += system("fmtutil-sys", $a); + $errors += do_cmd_and_check("fmtutil-sys $a"); } if (exists $ret{'language'}) { @@ -483,13 +492,12 @@ sub handle_ret_hash { $lang = "$TEXMFSYSVAR/tex/generic/config/$lang"; } if ($localtlpdb->option_create_formats) { - info("running fmtutil-sys --byhyphen $lang\n"); - $errors += system("fmtutil-sys", "--byhyphen", $lang); + $errors += do_cmd_and_check("fmtutil-sys --byhyphen $lang"); } } } - return $errors / 256; # we were accumulating wait statuses + return $errors; } diff --git a/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl b/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl index cc3d4d85f19..bc910bad907 100644 --- a/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl +++ b/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl @@ -159,11 +159,29 @@ my $back_config_act = $lower->Labelframe(-text => ___"actions"); $back_config_act->Button(-text => ___"reinitlsr", - -command => sub { run_program_show_output("mktexlsr"); })->pack(-expand => 1, -fill => "x", -padx => "2m", -pady => "2m"); + -command => sub { + $mw->Busy(-recurse => 1); + info("Running mktexlsr, this may take some time ...\n"); + info(`mktexlsr 2>&1`); + $mw->Unbusy; + })->pack(-expand => 1, -fill => "x", + -padx => "2m", -pady => "2m"); $back_config_act->Button(-text => ___"recreateformats", - -command => sub { run_program_show_output("fmtutil-sys --all"); })->pack(-expand => 1, -fill => "x", -padx => "2m", -pady => "2m"); + -command => sub { + $mw->Busy(-recurse => 1); + info("Running fmtutil-sys --all, this may take some time ...\n"); + info(`fmtutil-sys --all 2>&1`); + $mw->Unbusy; + })->pack(-expand => 1, -fill => "x", + -padx => "2m", -pady => "2m"); $back_config_act->Button(-text => ___"updatemaps", - -command => sub { run_program_show_output("updmap-sys"); })->pack(-expand => 1, -fill => "x", -padx => "2m", -pady => "2m"); + -command => sub { + $mw->Busy(-recurse => 1); + info("Running updmap-sys, this may take some time ...\n"); + info(`updmap-sys 2>&1`); + $mw->Unbusy; + })->pack(-expand => 1, -fill => "x", + -padx => "2m", -pady => "2m"); $back_config_act->pack(-side => 'right', -fill => "both", -padx => "2m", -pady => "2m", -expand => 1, -ipadx => "2m", -ipady => "2m"); diff --git a/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl b/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl index 7d2db397caf..a9d9b95443a 100755 --- a/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl +++ b/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl @@ -398,58 +398,6 @@ sub set_text_win { $w->see("0.0"); } -sub run_program_show_output { - my $td = $mw->Toplevel(-title => ___"tlmgr process"); - $td->transient($mw); - $td->grab(); - my $tf = $td->Scrolled("ROText", -width => 80, - -height => 10, - -wrap => "none", - -scrollbars => "ose" - )->pack(-expand => 1, -fill => "both"); - my $ok = $td->Button(-text => ___"ok", -padx => "3m", -pady => "3m", - -command => sub { $td->destroy; }); - # start the installation, read the output - $mw->update; - $::sww->update; - # - # ok, that stupid perl for windows does not have fork, why? no idea - # we have to deal with that - if ($^O=~/^MSWin(32|64)$/i) { - $tf->insert("end", ___("starting") . " @_\n\n" . ___"maytaketime"); - $mw->update; - $::sww->update; - my $ret = `@_`; - $tf->insert("end", "$ret\n\n" . ___("completed") . "\n"); - $tf->see("end"); - $ok->pack; - $mw->update; - $::sww->update; - } else { - my $pid = open(KID_TO_READ, "-|"); - if ($pid) { # parent - while (<KID_TO_READ>) { - $tf->insert("end",$_); - $tf->see("end"); - $mw->update; - $::sww->update; - } - close(KID_TO_READ) || warn "kid exited $?"; - $tf->insert("end","\n\nCOMPLETED\n"); - $tf->see("end"); - $ok->pack; - } else { #kid - # do not buffer lines ... - $| = 1; - open STDERR, '>&STDOUT'; - print ___("starting") . " @_\n"; - exec(@_) - || die "can't exec program: $!"; - # NOTREACHED - } - } -} - sub install_selected_packages { if (@_) { my @args = qw/install/; |