summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-10-27 18:31:21 +0000
committerKarl Berry <karl@freefriends.org>2008-10-27 18:31:21 +0000
commitdd7c9a1cf1d531252cd94a046cc31f4edd4450e2 (patch)
tree5b09352002e6fba0214cec1c84a75315734d2aeb
parentf766fd30eb3886932b6d8a7f3debbf7adf20ea33 (diff)
(handle_ret_hash): move code to a new function,
and return error count; exit 1 on failure. Suggestion from cfrees, 16 Oct 2008 02:15:05. git-svn-id: svn://tug.org/texlive/trunk@11078 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.pl148
1 files changed, 84 insertions, 64 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl
index ffa8a1ab744..7f859a49860 100755
--- a/Master/texmf/scripts/texlive/tlmgr.pl
+++ b/Master/texmf/scripts/texlive/tlmgr.pl
@@ -262,73 +262,84 @@ if ($action =~ m/^_include_tlpobj$/) {
die "$0: unknown action: $action\n";
}
+# main action is done, now clean up.
-######################################
-
-# close the log file
+# close the special log file
if ($packagelogfile) {
print "tlmgr: package log updated at $packagelogfile\n" if $packagelogged;
close(PACKAGELOG);
}
-#
-# checking the %ret hash
-if (defined($ret{'mktexlsr'})) {
- print "running mktexlsr\n";
- system("mktexlsr");
-}
-my $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`;
-chomp $TEXMFSYSVAR;
-my $TEXMFLOCAL = `kpsewhich -var-value=TEXMFLOCAL`;
-chomp $TEXMFLOCAL;
-if (defined($ret{'map'})) {
- foreach my $m (@{$ret{'map'}}) {
- print "$m\n";
- system("updmap-sys --nomkmap --nohash --$m");
- }
- system("mktexlsr");
- system("updmap-sys");
-}
-if (defined($ret{'format'})) {
- print "regenerating fmtutil.cnf\n";
- TeXLive::TLUtils::create_fmtutil($localtlpdb,
- "$TEXMFSYSVAR/web2c/fmtutil.cnf",
- "$TEXMFLOCAL/web2c/fmtutil-local.cnf");
- # system("texconfig-sys", "generate", "fmtutil");
- # running fmtutil-sys only in case that at installation time the
- # option for building formats was selected
- if ($localtlpdb->option_create_formats) {
- print "running fmtutil-sys --missing\n";
- system("fmtutil-sys", "--missing");
+
+# run external programs.
+my $error_count = &handle_ret_hash(%ret);
+
+# done.
+finish($error_count ? 1 : 0); # just in case there are 256 errors.
+
+
+#
+# run external programs based on the RET hash we've accumulated.
+# We return the number of unsuccessful runs, zero if all went well.
+#
+sub handle_ret_hash
+{
+ my (%ret) = @_;
+ my $errors = 0;
+
+ if (defined($ret{'mktexlsr'})) {
+ print "running mktexlsr\n";
+ $errors += system("mktexlsr");
}
-}
-if (defined($ret{'language'})) {
- print "regenerating language.dat\n";
- TeXLive::TLUtils::create_language_dat($localtlpdb,
- "$TEXMFSYSVAR/tex/generic/config/language.dat",
- "$TEXMFLOCAL/tex/generic/config/language-local.dat");
- print "regenerating language.def\n";
- TeXLive::TLUtils::create_language_def($localtlpdb,
- "$TEXMFSYSVAR/tex/generic/config/language.def",
- "$TEXMFLOCAL/tex/generic/config/language-local.def");
- # system("texconfig-sys", "generate", "language");
- #
- # w32 fmtutil needs language.dat WITHOUT full specification
- if (TeXLive::TLUtils::win32()) {
- print "running fmtutil-sys --byhyphen language.dat\n";
- system("fmtutil-sys", "--byhyphen", "language.dat");
- print "running fmtutil-sys --byhyphen language.def\n";
- system("fmtutil-sys", "--byhyphen", "language.def");
- } else {
- print "running fmtutil-sys --byhyphen $TEXMFSYSVAR/tex/generic/config/language.dat\n";
- system("fmtutil-sys", "--byhyphen", "$TEXMFSYSVAR/tex/generic/config/language.dat");
- print "running fmtutil-sys --byhyphen $TEXMFSYSVAR/tex/generic/config/language.def\n";
- system("fmtutil-sys", "--byhyphen", "$TEXMFSYSVAR/tex/generic/config/language.def");
+
+ if (defined($ret{'map'})) {
+ foreach my $m (@{$ret{'map'}}) {
+ print "$m\n";
+ $errors += system("updmap-sys --nomkmap --nohash --$m");
+ }
+ $errors += system("mktexlsr");
+ $errors += system("updmap-sys");
}
-}
-finish(0);
+ chomp (my $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`);
+ chomp (my $TEXMFLOCAL = `kpsewhich -var-value=TEXMFLOCAL`);
+
+ if (defined($ret{'format'})) {
+ print "regenerating fmtutil.cnf\n";
+ TeXLive::TLUtils::create_fmtutil($localtlpdb,
+ "$TEXMFSYSVAR/web2c/fmtutil.cnf",
+ "$TEXMFLOCAL/web2c/fmtutil-local.cnf");
+ # run fmtutil-sys only if the option for building formats is set.
+ if ($localtlpdb->option_create_formats) {
+ print "running fmtutil-sys --missing\n";
+ $errors += system("fmtutil-sys", "--missing");
+ }
+ }
-#
+ if (defined($ret{'language'})) {
+ for my $ext ("dat", "def") {
+ my $lang = "language.$ext";
+ print "regenerating $lang\n";
+
+ my $arg1 = "$TEXMFSYSVAR/tex/generic/config/language.$ext";
+ my $arg2 = "$TEXMFLOCAL/tex/generic/config/language-local.dat";
+ if ($ext eq "dat") {
+ TeXLive::TLUtils::create_language_dat($localtlpdb, $arg1, $arg2);
+ } else {
+ TeXLive::TLUtils::create_language_def($localtlpdb, $arg1, $arg2);
+ }
+
+ if (! TeXLive::TLUtils::win32()) {
+ # Use full path for external command, except on Windows.
+ $lang = "$TEXMFSYSVAR/tex/generic/config/$lang";
+ }
+ print "running fmtutil-sys --byhyphen $lang\n";
+ $errors += system("fmtutil-sys", "--byhyphen", $lang);
+ }
+ }
+ return $errors / 256; # we were accumulating wait statuses
+}
+
+#
# remove_package removes a single package with all files (including the
# tlpobj files) and the entry from the tlpdb.
#
@@ -534,8 +545,12 @@ sub action_remove {
return;
} else {
$localtlpdb->save;
- my @foo = sort ( keys %already_removed );
- print "tlmgr: actually removed these packages: @foo\n";
+ my @foo = sort keys %already_removed;
+ if (@foo) {
+ print "tlmgr: actually removed these packages: @foo\n";
+ } else {
+ print "tlmgr: no packages removed.\n";
+ }
return(\%ret);
}
}
@@ -1929,14 +1944,19 @@ sub logpackage {
}
#
-# finish
-# evaluates only the -pause option, and then exits
+# finish # evaluates only the -pause option, and then exits.
sub finish {
- my $ret = shift;
+ my ($ret) = @_;
+
+ if ($ret > 0) {
+ print "tlmgr: exiting unsuccessfully (status $ret).\n";
+ }
+
if ($opt_pause) {
- print "Please press <ENTER> to finish process!\n";
+ print "Please press <ENTER> to exit the program.\n";
<STDIN>;
}
+
exit($ret);
}