summaryrefslogtreecommitdiff
path: root/Master/texmf
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2009-06-08 14:57:10 +0000
committerNorbert Preining <preining@logic.at>2009-06-08 14:57:10 +0000
commit95eb7ead780f7de930d678a7ba295b27fa6d587e (patch)
tree6d06b40304d8b7a7c3dabda132d982900c73b7ed /Master/texmf
parentde09651f8c907cf30b668e414ff9da7b1f232a6e (diff)
rework execute action handling so that it actually works, hopefully
that means that: - handle_ret_hash is renamed to handle_execute_actions - make_ret_hash_from_execute is gone and replaced by TLUtils::announce_execute_actions git-svn-id: svn://tug.org/texlive/trunk@13671 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.pl242
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl4
2 files changed, 136 insertions, 110 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl
index 0c21efda53b..9bde01ab219 100755
--- a/Master/texmf/scripts/texlive/tlmgr.pl
+++ b/Master/texmf/scripts/texlive/tlmgr.pl
@@ -69,7 +69,7 @@ use TeXLive::TLPOBJ;
use TeXLive::TLUtils;
use TeXLive::TLWinGoo;
TeXLive::TLUtils->import(qw(member info give_ctan_mirror win32 dirname
- mkdirhier merge_into copy log debug));
+ mkdirhier copy log debug));
use TeXLive::TLPaper;
@@ -295,7 +295,6 @@ execute_action($action, @ARGV);
sub execute_action {
my ($action, @argv) = @_;
- my %ret;
# we have to set @ARGV to the @argv since many of the action_* subs
# use GetOption
@@ -349,45 +348,45 @@ sub execute_action {
print "$loc\n";
finish(0);
} elsif ($action =~ m/^generate$/i) {
- merge_into(\%ret, action_generate());
+ action_generate();
} elsif ($action =~ m/^gui$/i) {
action_gui();
} elsif ($action =~ m/^arch$/i) {
- merge_into(\%ret, action_arch());
+ action_arch();
} elsif ($action =~ m/^option$/i) {
- merge_into(\%ret, action_option());
+ action_option();
finish(0);
} elsif ($action =~ m/^list$/i) {
- merge_into(\%ret, action_list());
+ action_list();
finish(0);
} elsif ($action =~ m/^check$/i) {
- merge_into(\%ret, action_check());
+ action_check();
} elsif ($action =~ m/^install$/i) {
- merge_into(\%ret, action_install());
+ action_install();
} elsif ($action =~ m/^update$/i) {
- merge_into(\%ret, action_update());
+ action_update();
} elsif ($action =~ m/^backup$/i) {
- merge_into(\%ret, action_backup());
+ action_backup();
} elsif ($action =~ m/^restore$/i) {
- merge_into(\%ret, action_restore());
+ action_restore();
} elsif ($action =~ m/^symlinks$/i) {
- merge_into(\%ret, action_symlinks());
+ action_symlinks();
finish(0);
} elsif ($action =~ m/^search$/i) {
- merge_into(\%ret, action_search());
+ action_search();
finish(0);
} elsif ($action =~ m/^show$/i) {
- merge_into(\%ret, action_show());
+ action_show();
finish(0);
} elsif ($action =~ m/^remove$/i) {
- merge_into(\%ret, action_remove());
+ action_remove();
} elsif ($action =~ /^paper$/) {
- merge_into(\%ret, action_paper());
+ action_paper();
} elsif ($action =~ m/^uninstall$/i) {
- merge_into(\%ret, action_uninstall());
+ action_uninstall();
finish(0);
} elsif ($action =~ m/^recreate-tlpdb$/i) {
- merge_into(\%ret, action_recreate_tlpdb());
+ action_recreate_tlpdb();
finish(0);
} else {
die "$0: unknown action: $action; try --help if you need it.\n";
@@ -400,7 +399,7 @@ sub execute_action {
}
# run external programs.
- my $error_count = &handle_ret_hash(%ret);
+ my $error_count = &handle_execute_actions();
# done, just in case there are 256 errors.
finish($error_count ? 1 : 0);
@@ -430,73 +429,127 @@ sub do_cmd_and_check {
# 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_ret_hash {
- my (%ret) = @_;
+sub handle_execute_actions {
+
my $errors = 0;
- if (exists $ret{'mktexlsr'}) {
+ if ($::files_changed) {
$errors += do_cmd_and_check("mktexlsr");
}
- if (exists $ret{'map'}) {
- # We run updmap-sys instead of calling our create_updmap() function
- # (as we do for formats and languages), because many users run
- # updmap themselves (not using our local cfg feature), since that's
- # 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'}}) {
- $errors += do_cmd_and_check("updmap-sys --nomkmap --nohash --$m");
+ #
+ # maps handling
+ # if enabled and disabled -> do nothing
+ # if only enabled -> enable it
+ # if only disabled -> disable it
+ {
+ my %do_enable;
+ my %do_disable;
+ my $run_full = 0;
+ for my $m (keys %{$::execute_actions{'enable'}{'maps'}}) {
+ $run_full = 1;
+ $do_enable{$m} = 1;
+ }
+ for my $m (keys %{$::execute_actions{'disable'}{'maps'}}) {
+ $run_full = 1;
+ if (defined($do_enable{$m})) {
+ # we are upgrading because it is disabled and enabled, so
+ # delete the entry in do_enable, it is already
+ delete $do_enable{$m};
+ } else {
+ # not new installed, so simply removed
+ $do_disable{$m} = 1;
+ }
}
- $errors += do_cmd_and_check("updmap-sys"); # runs mktexlsr.
+ for my $m (keys %do_disable) {
+ $errors += do_cmd_and_check("updmap-sys --nomkmap --nohash --disable $m");
+ }
+ for my $m (keys %do_enable) {
+ my $str = "updmap-sys --nomkmap --nohash --enable " .
+ $::execute_actions{'enable'}{'maps'}{$m} . "=$m";
+ $errors += do_cmd_and_check($str);
+ }
+ $errors += do_cmd_and_check("updmap-sys") if $run_full;
}
+
chomp(my $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`);
chomp(my $TEXMFLOCAL = `kpsewhich -var-value=TEXMFLOCAL`);
+
# format means create missing formats (because a new one was added).
# format-regenerate is used when the paper size changes. In that
# case, if option_create_formats is set, we simply want to generate
# all formats; if not, then we only want to refresh existing ones.
#
- my $opt_fmt = $localtlpdb->option_create_formats;
- if (exists $ret{'format'}) {
- info("regenerating fmtutil.cnf in $TEXMFSYSVAR\n");
- TeXLive::TLUtils::create_fmtutil($localtlpdb,
- "$TEXMFSYSVAR/web2c/fmtutil.cnf",
- "$TEXMFLOCAL/web2c/fmtutil-local.cnf");
- if ($opt_fmt && !$ret{'format-regenerate'}) {
- $errors += do_cmd_and_check("fmtutil-sys --missing");
+ {
+ my %do_enable;
+ my $do_full = 0;
+ for my $m (keys %{$::execute_actions{'enable'}{'formats'}}) {
+ $do_full = 1;
+ $do_enable{$m} = 1;
+ }
+ for my $m (keys %{$::execute_actions{'disable'}{'formats'}}) {
+ $do_full = 1;
+ }
+ my $opt_fmt = $localtlpdb->option_create_formats;
+ if ($do_full) {
+ info("regenerating fmtutil.cnf in $TEXMFSYSVAR\n");
+ TeXLive::TLUtils::create_fmtutil($localtlpdb,
+ "$TEXMFSYSVAR/web2c/fmtutil.cnf",
+ "$TEXMFLOCAL/web2c/fmtutil-local.cnf");
+ }
+ if ($opt_fmt && !$::regenerate_all_formats) {
+ for my $f (keys %do_enable) {
+ info ("(re)creating format dump $f\n");
+ $errors += do_cmd_and_check("fmtutil-sys --byfmt $f");
+ }
}
}
- #
- if (exists $ret{'format-regenerate'}) {
- my $a = $opt_fmt ? "--all" : "--refresh";
- $errors += do_cmd_and_check("fmtutil-sys $a");
- }
- if (exists $ret{'language'}) {
- for my $ext ("dat", "def") {
- my $lang = "language.$ext";
- info("regenerating $lang\n");
+ #
+ # hyphenation patterns
+ # if something has changed do the whole stuff ...
+ {
+ my $do_something = 0;
+ for my $m (keys %{$::execute_actions{'enable'}{'hyphens'}}) {
+ $do_something = 1;
+ last;
+ }
+ for my $m (keys %{$::execute_actions{'disable'}{'hyphens'}}) {
+ $do_something = 1;
+ last;
+ }
+
+ if ($do_something) {
+ for my $ext ("dat", "def") {
+ my $lang = "language.$ext";
+ info("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);
- }
+ 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";
- }
- if ($localtlpdb->option_create_formats) {
- $errors += do_cmd_and_check("fmtutil-sys --byhyphen $lang");
+ if (! TeXLive::TLUtils::win32()) {
+ # Use full path for external command, except on Windows.
+ $lang = "$TEXMFSYSVAR/tex/generic/config/$lang";
+ }
+ if ($localtlpdb->option_create_formats && !$::regenerate_all_formats) {
+ $errors += do_cmd_and_check("fmtutil-sys --byhyphen $lang");
+ }
}
}
}
+ #
+ if ($::regenerate_all_formats) {
+ $errors += do_cmd_and_check("fmtutil-sys --all");
+ }
+
return $errors;
}
@@ -540,7 +593,6 @@ sub action_remove {
# . check that no collection/scheme still depends on this package
# . remove the package
#
- my %ret;
$opts{"no-depends"} = 1 if $opts{"no-depends-at-all"};
my %already_removed;
my @more_removal;
@@ -605,21 +657,15 @@ sub action_remove {
# save the information of which packages have already been removed
# into %already_removed.
if ($tlp->category eq "Collection") {
- my %foo;
+ my $foo = 0;
info ("remove $pkg\n");
- if ($opts{"dry-run"}) {
- # we need to set $foo to something positive otherwise
- # the rest will not be run in dry_run mode
- $foo{'mktexlsr'} = 1;
- } else {
- merge_into(\%foo,
- $localtlmedia->remove_package($pkg));
+ if (!$opts{"dry-run"}) {
+ $foo = $localtlmedia->remove_package($pkg);
logpackage("remove: $pkg");
}
- if (keys %foo) {
+ if ($foo) {
# removal was successful, so the return is at least 0x0001 mktexlsr
# remove dependencies, too
- merge_into(\%ret, \%foo);
$already_removed{$pkg} = 1;
}
} else {
@@ -635,13 +681,9 @@ sub action_remove {
if (!defined($already_removed{$pkg})) {
info ("remove $pkg\n");
if (!$opts{"dry-run"}) {
- my %foo;
- merge_into(\%foo,
- $localtlmedia->remove_package($pkg));
- if (keys %foo) {
+ if ($localtlmedia->remove_package($pkg)) {
# removal was successful
logpackage("remove: $pkg");
- merge_into(\%ret, \%foo);
$already_removed{$pkg} = 1;
}
}
@@ -658,7 +700,6 @@ sub action_remove {
} else {
info("tlmgr: no packages removed.\n");
}
- return(\%ret);
}
}
@@ -670,7 +711,6 @@ sub action_remove {
# [xdvi|...|context] paper [help|papersize|--list]
#
sub action_paper {
- my %ret = ();
action_gui("config") if $opts{"gui"};
init_local_db();
@@ -694,7 +734,7 @@ sub action_paper {
tlwarn("tlmgr: expected `a4' or `letter' after paper, not $newpaper\n");
} else { # tlmgr paper {a4|letter} => do it.
- merge_into(\%ret,TeXLive::TLPaper::paper_all($texmfsysconfig,$newpaper));
+ TeXLive::TLPaper::paper_all($texmfsysconfig,$newpaper);
}
} else { # program-specific paper
@@ -708,9 +748,8 @@ sub action_paper {
# the do_paper progs check for the argument --list, so if given
# restore it to the cmd line.
unshift(@ARGV, "--list") if $opts{"list"};
- merge_into(\%ret, TeXLive::TLPaper::do_paper($prog,$texmfsysconfig,@ARGV));
+ TeXLive::TLPaper::do_paper($prog,$texmfsysconfig,@ARGV);
}
- return \%ret;
}
@@ -806,7 +845,6 @@ sub action_show {
# SYMLINKS
#
sub action_symlinks {
- my %ret;
my $what = shift @ARGV;
if (!defined($what) || ($what !~ m/^(add|remove)$/i)) {
tlwarn("action symlinks needs one argument, either add or remove\n");
@@ -829,7 +867,6 @@ sub action_symlinks {
# SEARCH
#
sub action_search {
- my %ret;
my $r = shift @ARGV;
my $ret = "";
my $tlpdb;
@@ -879,7 +916,6 @@ sub action_restore {
# lists all revisions of pkg
# tlmgr restore --backupdir dir pkg rev
# restores pkg to revision rev
- my %ret;
# check the backup dir argument
if ($opts{"backupdir"}) {
my $ob = abs_path($opts{"backupdir"});
@@ -955,20 +991,20 @@ sub action_restore {
# first remove the package, then reinstall it
# this way we get rid of useless files
$opts{"backupdir"} = abs_path($opts{"backupdir"});
- merge_into(\%ret, $localtlmedia->remove_package($pkg));
+ $localtlmedia->remove_package($pkg);
TeXLive::TLMedia->_install_package("$opts{'backupdir'}/${pkg}.r${rev}.tar.xz" , [] ,$localtlpdb);
logpackage("restore: $pkg ($rev)");
# now we have to read the .tlpobj file and add it to the DB
my $tlpobj = TeXLive::TLPOBJ->new;
$tlpobj->from_file($localtlpdb->root . "/tlpkg/tlpobj/$pkg.tlpobj");
$localtlpdb->add_tlpobj($tlpobj);
- merge_into(\%ret, $localtlpdb->get_package($pkg)->make_return_hash_from_executes("enable"));
+ TeXLive::TLUtils::announce_execute_actions("enable",
+ $localtlpdb->get_package($pkg));
$localtlpdb->save;
}
} else {
print "revision $rev for $pkg is not present in $opts{'backupdir'}\n";
}
- return \%ret;
}
sub action_backup {
@@ -1048,7 +1084,6 @@ sub action_backup {
}
}
- my %ret;
my @todo;
if ($opts{"all"}) {
@todo = $localtlpdb->list_packages;
@@ -1072,7 +1107,6 @@ sub action_backup {
}
}
}
- return(\%ret);
}
#
@@ -1204,7 +1238,6 @@ sub action_update {
}
init_local_db(1);
$opts{"no-depends"} = 1 if $opts{"no-depends-at-all"};
- my %ret;
init_tlmedia();
info("update: dry run, no changes will be made\n") if $opts{"dry-run"};
@@ -1513,7 +1546,7 @@ sub action_update {
# package updates
if ($opts{"all"} and
!($opts{"dry-run"} or $opts{"list"} or $opts{"no-remove"})) {
- merge_into(\%ret, $localtlmedia->remove_package($p));
+ $localtlmedia->remove_package($p);
logpackage("remove: $p");
}
}
@@ -1535,10 +1568,8 @@ sub action_update {
}
$currnr++;
next if ($opts{"dry-run"} || $opts{"list"});
- my $foo = $tlmediasrc->install_package($pkg, $localtlpdb);
- if (ref $foo) {
+ if ($tlmediasrc->install_package($pkg, $localtlpdb)) {
# installation succeeded because we got a reference
- merge_into (\%ret, $foo);
logpackage("auto-install new: $pkg ($mediarev)");
$nrupdated++;
} else {
@@ -1616,11 +1647,9 @@ sub action_update {
#
# the remove_package should also remove empty dirs in case
# a dir is changed into a file
- merge_into(\%ret, $localtlmedia->remove_package($pkg));
- my $foo = $tlmediasrc->install_package($pkg, $localtlpdb);
- if (ref $foo) {
+ $localtlmedia->remove_package($pkg);
+ if ($tlmediasrc->install_package($pkg, $localtlpdb)) {
# installation succeeded because we got a reference
- merge_into (\%ret, $foo);
logpackage("update: $pkg ($rev -> $mediarev)");
unlink($unwind_package) if $remove_unwind_container;
} else {
@@ -1677,7 +1706,6 @@ sub action_update {
tlwarn("\nTo change the default for all future updates, run\n");
tlwarn(" tlmgr option location $TeXLiveURL\n\n");
}
- return(\%ret);
}
@@ -1717,7 +1745,6 @@ sub action_install {
init_local_db(1);
# initialize the TLMedia from $location
$opts{"no-depends"} = 1 if $opts{"no-depends-at-all"};
- my %ret;
init_tlmedia();
# check for updates to tlmgr itself, and die unless --force is given
@@ -1759,7 +1786,7 @@ sub action_install {
}
info("${re}install: $pkg\n");
if (!$opts{"dry-run"}) {
- merge_into(\%ret, $tlmediasrc->install_package($pkg, $localtlpdb));
+ $tlmediasrc->install_package($pkg, $localtlpdb);
logpackage("${re}install: $pkg");
}
}
@@ -1767,7 +1794,6 @@ sub action_install {
# stop here, don't do any postinstall actions
return(0);
}
- return(\%ret);
}
sub action_list {
@@ -2001,7 +2027,6 @@ sub action_arch {
if ($opts{"gui"}) {
action_gui("arch");
}
- my %ret;
my $what = shift @ARGV;
init_local_db(1);
info("arch: dry run, no changes will be made\n") if $opts{"dry-run"};
@@ -2051,7 +2076,7 @@ sub action_arch {
info("Installing $pkg.$a\n");
} else {
info("install: $pkg.$a\n");
- merge_into(\%ret, $tlmediasrc->install_package("$pkg.$a", $localtlpdb));
+ $tlmediasrc->install_package("$pkg.$a", $localtlpdb);
}
}
}
@@ -2060,11 +2085,11 @@ sub action_arch {
if (TeXLive::TLUtils::member('win32', @todoarchs)) {
# install the necessary w32 stuff
info("install: tlperl.win32\n");
- merge_into (\%ret, $tlmediasrc->install_package("tlperl.win32", $localtlpdb));
+ $tlmediasrc->install_package("tlperl.win32", $localtlpdb);
info("install: tlgs.win32\n");
- merge_into (\%ret, $tlmediasrc->install_package("tlgs.win32", $localtlpdb));
+ $tlmediasrc->install_package("tlgs.win32", $localtlpdb);
info("install: tlpsv.win32\n");
- merge_into (\%ret, $tlmediasrc->install_package("tlpsv.win32", $localtlpdb));
+ $tlmediasrc->install_package("tlpsv.win32", $localtlpdb);
}
# update the option_archs list of installed archs
my @larchs = $localtlpdb->option_available_architectures;
@@ -2074,7 +2099,6 @@ sub action_arch {
} else {
die "Unknown option for arch: $what";
}
- return(\%ret);
}
diff --git a/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl b/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl
index a9d9b95443a..89835da02e8 100755
--- a/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl
+++ b/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl
@@ -218,7 +218,9 @@ init_hooks();
info(___("loadtlpdbwait") . "\n");
-our $localtlpdb = TeXLive::TLPDB->new ("root" => "$Master");
+our $localtlmedia = TeXLive::TLMedia->new ( $Master );
+die("cannot setup TLMedia in $Master") unless (defined($localtlmedia));
+$localtlpdb = $localtlmedia->tlpdb;
die("cannot find tlpdb!") unless (defined($localtlpdb));
our @alllocalpackages = setup_list(0,$localtlpdb->list_packages);