diff options
author | Norbert Preining <preining@logic.at> | 2008-10-11 00:03:30 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2008-10-11 00:03:30 +0000 |
commit | efe91b9346bada5d48cfa99f825f6c8a81426c36 (patch) | |
tree | 7fe9132e357511a6fb030ea89f39f2c4c39e1519 | |
parent | 794a222d321c1f54ad3d0ccae53bfdddbb2c037e (diff) |
tlmgr: remove_package now does not remove files which are also part of other
packages, and warns if that happens
git-svn-id: svn://tug.org/texlive/trunk@10921 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index e3f17ace91d..4fdf30f7fa7 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -6,8 +6,6 @@ # or any later version. # # TODO: -# - remove_package: before removing a file check that it is not listed -# in any other package ... # - backup extensions (email from Manuel) # tlmgr option backupdir /some/fix/location # with default TLROOT/backups as default @@ -343,8 +341,37 @@ sub remove_package { if (-r "tlpkg/tlpobj/$pkg.doc.tlpobj") { push @files, "tlpkg/tlpobj/$pkg.doc.tlpobj"; } - my @removals = &removed_dirs (@files); - foreach my $entry (@files) { + # + # we want to check that a file is only listed in one package, so + # in case that a file to be removed is listed in another package + # we will warn and *not* remove it + my %allfiles; + for my $p ($localtlpdb->list_packages) { + next if ($p eq $pkg); # we have to skip the to be removed package + for my $f ($localtlpdb->get_package($p)->all_files) { + $allfiles{$f} = $p; + } + } + my @goodfiles = (); + my @badfiles = (); + for my $f (@files) { + if (defined($allfiles{$f})) { + # this file should be removed but is mentioned somewhere, too + push @badfiles, $f; + } else { + push @goodfiles, $f; + } + } + if ($#badfiles >= 0) { + # warn the user + tlwarn("The following files should be removed due to the removal of $pkg,\n"); + tlwarn("but are part of another package, too.\n"); + for my $f (@badfiles) { + tlwarn(" $f - $allfiles{$f}\n"); + } + } + my @removals = &removed_dirs (@goodfiles); + foreach my $entry (@goodfiles) { unlink $entry; } foreach my $entry (@removals) { |