summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-11-12 18:13:17 +0000
committerNorbert Preining <preining@logic.at>2008-11-12 18:13:17 +0000
commit23e9dce80571144ff416d0af618a44ae1a861389 (patch)
tree7a0ea66b76b3cc937c004ad2c2fd5839796c6919 /Master
parent443ccf6c03f09d4fe0ec58690c8398a7e02adacb (diff)
fix tlmgr remove logic not to remove tooooo many packages
git-svn-id: svn://tug.org/texlive/trunk@11268 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.pl36
1 files changed, 34 insertions, 2 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl
index ef2e669b65f..a2a123a37e7 100755
--- a/Master/texmf/scripts/texlive/tlmgr.pl
+++ b/Master/texmf/scripts/texlive/tlmgr.pl
@@ -474,10 +474,44 @@ sub action_remove {
init_local_db();
info("remove: dry run, no changes will be made\n") if $opt_dry;
my @packs = @ARGV;
+ #
+ # we have to be carefull not to remove too many packages. The idea is
+ # as follows:
+ # - let A be the set of all packages to be removed from the cmd line
+ # - let A* be the set of A with all dependencies expanded
+ # - let B be the set of all packages
+ # - let C = B \ A*, ie the set of all packages without those packages
+ # in the set of A*
+ # - let C* be the set of C with all dependencies expanded
+ # - let D = A* \ C*, ie the set of all packages to be removed (A*)
+ # without all the package that are still needed (C*)
+ # - remove all package in D
+ # - for any package in A (not in A*, in A, ie on the cmd line) that is
+ # also in C* (so a package that was asked for to be removed on the
+ # cmd line, but it isn't because someone else asks for it), warn the
+ # user that it is still needed
+ #
# remove all .ARCH dependencies, too, unless $opt_reallynodepends
@packs = $localtlpdb->expand_dependencies("-only-arch", $localtlpdb, @packs) unless $opt_reallynodepends;
# remove deps unless $opt_nodepends
@packs = $localtlpdb->expand_dependencies("-no-collections", $localtlpdb, @packs) unless $opt_nodepends;
+ my %allpacks;
+ for my $p ($localtlpdb->list_packages) { $allpacks{$p} = 1; }
+ for my $p (@packs) { delete($allpacks{$p}); }
+ my @neededpacks = $localtlpdb->expand_dependencies($localtlpdb, keys %allpacks);
+ my %packs;
+ my %origpacks;
+ for my $p (@ARGV) { $origpacks{$p} = 1; }
+ for my $p (@packs) { $packs{$p} = 1; }
+ for my $p (@neededpacks) {
+ delete($packs{$p});
+ if (defined($origpacks{$p})) {
+ my @needed = $localtlpdb->needed_by($p);
+ tlwarn("not removing $p, is is still needed by " .
+ join(" ", @needed) . "\n");
+ }
+ }
+ @packs = keys %packs;
foreach my $pkg (sort @packs) {
my $tlp = $localtlpdb->get_package($pkg);
next if defined($already_removed{$pkg});
@@ -489,8 +523,6 @@ sub action_remove {
# save the information of which packages have already been removed
# into %already_removed.
if ($tlp->category eq "Collection") {
- # for collections we also remove all dependencies which are
- # not Collections or Schemes
my %foo;
info ("remove $pkg\n");
if ($opt_dry) {