From b07703c29723a38ba270bfe830e2ea7e74e6f472 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 28 Jul 2009 19:09:44 +0000 Subject: work on --self and restart git-svn-id: svn://tug.org/texlive/trunk@14481 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf/scripts/texlive/tlmgr.pl | 59 ++++++++++++++++++++++++----------- Master/tlpkg/TeXLive/TLConfig.pm | 23 ++++++-------- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index 822d53086d1..26cfa77fbae 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -187,6 +187,10 @@ sub main { } } } + + # save command line options for later restart, if necessary + @::SAVEDARGV = @ARGV; + TeXLive::TLUtils::process_logging_options(); GetOptions(\%opts, keys(%optarg)) or pod2usage(2); @@ -1518,7 +1522,7 @@ sub action_update { @pretodo = $localtlpdb->list_packages if ($opts{"all"}); # filter out win32 special packages for my $p (@pretodo) { - push(@todo, $p) if ($p !~ m/$WinSpecialUpdatePackagesRegexp/); + push(@todo, $p) if ($p !~ m/$CriticalPackagesRegexp/); } } # don't do anything if we have been invoced in a strange way @@ -1536,8 +1540,8 @@ sub action_update { # # we first collect the list of packages to be actually updated or installed - my @updated; - my @w32_updated; # win32 special packages that need the updater batch script + my %updated; + my %w32_updated; # win32 special packages that need the updater batch script my @new; my @addlines; @@ -1593,10 +1597,10 @@ sub action_update { my $mediarev = $mediatlp->revision; if ($rev < $mediarev) { # w32 specials are treated as other packages for --list - if (win32() && !$opts{"list"} && ($pkg =~ m/$WinSpecialUpdatePackagesRegexp/)) { - push @w32_updated, $pkg; + if (win32() && !$opts{"list"} && ($pkg =~ m/$CriticalPackagesRegexp/)) { + $w32_updated{$pkg} = 0; # will be changed to one on successful update } else { - push @updated, $pkg; + $updated{$pkg} = 0; # will be changed to one on successful update } } elsif ($rev > $mediarev) { if ($::machinereadable) { @@ -1608,10 +1612,11 @@ sub action_update { } } } + my @updated = sort keys %updated; for my $i (sort @new) { debug("$i new package\n"); } - for my $i (sort @updated) { + for my $i (@updated) { debug("$i upd package\n"); } @@ -1741,7 +1746,7 @@ sub action_update { my @inst_packs; my @inst_colls; my @inst_schemes; - for my $pkg (sort @updated) { + for my $pkg (@updated) { # we do name checking here, not to load all tlpobj again and again if ($pkg =~ m/^scheme-/) { push @inst_schemes, $pkg; @@ -1773,6 +1778,7 @@ sub action_update { } else { info("$pkg: local: $rev, source: $mediarev (update)\n"); } + $updated{$pkg} = 1; next; } @@ -1796,6 +1802,7 @@ sub action_update { $currnr++; if ($opts{"dry-run"}) { info("\n") unless $::machinereadable; + $updated{$pkg} = 1; next; } else { info(" ... ") unless $::machinereadable; # more to come @@ -1827,6 +1834,8 @@ sub action_update { # installation succeeded because we got a reference logpackage("update: $pkg ($rev -> $mediarev)"); unlink($unwind_package) if $remove_unwind_container; + # remember successful update + $update{$pkg} = 1; } else { # install_package returned a scalar, so error. # now in fact we should do some cleanup, removing files and @@ -1869,25 +1878,39 @@ sub action_update { print "end-of-updates\n" if $::machinereadable; - my @rerun_tlmgr_argv; - # only when we are not dry-running we restart the program - if ($other_updates_asked_for && !$opts{"dry-run"}) { - if ($opts{"all"}) { - push @rerun_tlmgr_argv, "update", "--all"; - } else { - push @rerun_tlmgr_argv, "update", @ARGV; + # + # check that if updates to the critical packages are present all of + # them have been successfully updated + my $infra_update_present = 0; + my $infra_update_done = 1; + for my $pkg (@CriticalPackagesList) { + if (defined($updated{$pkg})) { + $infra_update_present = 1; + $infra_update_done &&= $pdated{$pkg}; } } + + my $restart_tlmgr = 0; + # only when we are not dry-running we restart the program + if ($infra_update_present && $infra_update_done && + $other_updates_asked_for && !$opts{"dry-run"}) { + # weed out the --self argument from the saved arguments + @::SAVEDARGV = grep {!m;^--self$;} @::SAVEDARGV;; + @::SAVEDARGV = grep {!m;^-self$;} @::SAVEDARGV;; + $restart_tlmgr = 1; + } + if (win32() && !$opts{"list"} && @w32_updated) { info("Preparing TeX Live infrastructure update...\n"); - my $ret = write_w32_updater("@rerun_tlmgr_argv", @w32_updated); + my $ret = write_w32_updater($restart_tlmgr, @w32_updated); tlwarn ("Aborting infrastructure update.\n") if ($ret); } # temporarily disable tlmgr restart after infra update (needs more work) - if (0 && !win32() && @rerun_tlmgr_argv) { + if (!win32() && $restart_tlmgr) { info ("Restarting tlmgr to complete update ...\n"); - exec("tlmgr", @rerun_tlmgr_argv); + debug("restarting tlmgr @::SAVEDARGV\n"); + exec("tlmgr", @::SAVEDARGV); die "Cannot restart tlmgr, please retry updating."; } diff --git a/Master/tlpkg/TeXLive/TLConfig.pm b/Master/tlpkg/TeXLive/TLConfig.pm index d7c6039c8c3..bcf73275a1d 100644 --- a/Master/tlpkg/TeXLive/TLConfig.pm +++ b/Master/tlpkg/TeXLive/TLConfig.pm @@ -26,8 +26,8 @@ BEGIN { $TeXLiveServerURL $TeXLiveServerPath $TeXLiveURL - $WinSpecialUpdatePackagesRegexp @CriticalPackagesList + $CriticalPackagesRegexp @AllowedConfigOptions $WindowsMainMenuName $RelocPrefix @@ -80,14 +80,12 @@ our $TeXLiveURL = "$TeXLiveServerURL/$TeXLiveServerPath"; our $RelocTree = "texmf-dist"; our $RelocPrefix = "RELOC"; -our $WinSpecialUpdatePackagesRegexp = - '^(texlive\.infra|tlperl\.win32$)'; - - - our @CriticalPackagesList = qw/texlive.infra/; -push(@CriticalPackagesList, "tlperl.win32") if ($^O=~/^MSWin(32|64)$/i); - +our $CriticalPackagesRegexp = '^(texlive\.infra)'; +if ($^O=~/^MSWin(32|64)$/i) { + push(@CriticalPackagesList, "tlperl.win32"); + $CriticalPackagesRegexp = '^(texlive\.infra|tlperl\.win32$)'; +} our @AllowedConfigOptions = qw/ available_architectures @@ -244,15 +242,12 @@ The defaults are respectively, C and CI, where I specifies the TeX Live release version, such as C or C<2008>. -=item C<$TeXLive::TLConfig::WinSpecialUpdatePackagesRegexp> - -A regexp matching all those packages which cannot be normally updated -because they contain files which are open during the update process. - =item C<@TeXLive::TLConfig::CriticalPackagesList> +=item C<@TeXLive::TLConfig::CriticalPackagesRegexp> A list of all those packages which we do not update regularly -since they are too central, currently only texlive.infra. +since they are too central, currently only texlive.infra (and tlperl.win32 +for Windows). =item C<@TeXLive::TLConfig::AllowedConfigOptions> -- cgit v1.2.3