From efe91b9346bada5d48cfa99f825f6c8a81426c36 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 11 Oct 2008 00:03:30 +0000 Subject: 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 --- Master/texmf/scripts/texlive/tlmgr.pl | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'Master/texmf/scripts') 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) { -- cgit v1.2.3