diff options
Diffstat (limited to 'Master/tlpkg/TeXLive/TLMedia.pm')
-rw-r--r-- | Master/tlpkg/TeXLive/TLMedia.pm | 101 |
1 files changed, 96 insertions, 5 deletions
diff --git a/Master/tlpkg/TeXLive/TLMedia.pm b/Master/tlpkg/TeXLive/TLMedia.pm index b990d7ff7fa..8c0423a7a87 100644 --- a/Master/tlpkg/TeXLive/TLMedia.pm +++ b/Master/tlpkg/TeXLive/TLMedia.pm @@ -202,15 +202,18 @@ sub install_package { # compute the return value my %ret; merge_into(\%ret, $tlpobj->make_return_hash_from_executes("enable")); + if (defined($PackageConfigInstall{$pkg})) { + info("running post install action for $pkg\n"); + &{$PostInstall{$pkg}}($totlpdb->root); + } if (!$nopostinstall) { # do the postinstallation actions - if (defined($PackageConfigInstall{$pkg})) { - info("running post install action for $pkg\n"); - &{$PostInstall{$pkg}}($totlpdb->root); - } # # Run the post installation code in the postaction tlpsrc entries - &TeXLive::TLUtils::do_postaction("install", $tlpobj); + &TeXLive::TLUtils::do_postaction("install", $tlpobj, + $totlpdb->option_file_assocs, + $totlpdb->option_desktop_integration, + $totlpdb->option_post_code); } return \%ret; } @@ -320,6 +323,94 @@ sub _install_package { } } +# +# remove_package removes a single package with all files (including the +# # tlpobj files) and the entry from the tlpdb. +sub remove_package { + my ($self, $pkg, $nopostinstall) = @_; + my $localtlpdb = $self->tlpdb; + my $tlp = $localtlpdb->get_package($pkg); + my %ret; + if (!defined($tlp)) { + tlwarn ("$pkg: package not present, cannot remove\n"); + } else { + if ($pkg =~ m/^texlive\.infra/) { + log ("Not removing $pkg, it is essential!\n"); + return; + } + # we have to chdir to $localtlpdb->root + my $Master = $localtlpdb->root; + chdir ($Master) || die "chdir($Master) failed: $!"; + my @files = $tlp->all_files; + # also remove the .tlpobj file + push @files, "tlpkg/tlpobj/$pkg.tlpobj"; + # and the ones from src/doc splitting + if (-r "tlpkg/tlpobj/$pkg.source.tlpobj") { + push @files, "tlpkg/tlpobj/$pkg.source.tlpobj"; + } + if (-r "tlpkg/tlpobj/$pkg.doc.tlpobj") { + push @files, "tlpkg/tlpobj/$pkg.doc.tlpobj"; + } + # + # 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) { + rmdir $entry; + } + $localtlpdb->remove_package($pkg); + merge_into(\%ret, $tlp->make_return_hash_from_executes("disable")); + $ret{'mktexlsr'} = 1; + # should we save at each removal??? + # advantage: the tlpdb actually reflects what is installed + # disadvantage: removing a collection calls the save routine several times + # still I consider it better that the tlpdb is in a consistent state + $localtlpdb->save; + # do the post removal actions + if (defined($PackageConfigRemove{$pkg})) { + info("running post remove action for $pkg\n"); + &{$PackageConfigRemove{$pkg}}($localtlpdb->root); + } + # + # Run the post installation code in the postaction tlpsrc entries + if (!$nopostinstall) { + &TeXLive::TLUtils::do_postaction("remove", $tlp, + $localtlpdb->option_file_assocs, + $localtlpdb->option_desktop_integration, + $localtlpdb->option_post_code); + } + } + return \%ret; +} # member access functions |