summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2009-03-18 11:48:49 +0000
committerNorbert Preining <preining@logic.at>2009-03-18 11:48:49 +0000
commit0652cd081c7679bc3accf7afc1d8bc1ec1443b8a (patch)
treeefd20c21adfe3561e0f39612cb4778a9ace01198
parent8314254e138a8b3496e70bb7d975187a95041c5d (diff)
more remove_package to TLMedia.pm, use that one in tlmgr
git-svn-id: svn://tug.org/texlive/branches/branch2009-dev@12421 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.pl103
-rw-r--r--Master/tlpkg/TeXLive/TLMedia.pm101
2 files changed, 108 insertions, 96 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl
index 72321e8f0bc..19a5cd78498 100755
--- a/Master/texmf/scripts/texlive/tlmgr.pl
+++ b/Master/texmf/scripts/texlive/tlmgr.pl
@@ -70,6 +70,7 @@ binmode(STDERR, ":utf8");
our $tlmediasrc; # media from which we install/update
our $tlmediatlpdb;
our $location; # location from which the new packages come
+our $localtlmedia; # local installation which we are munging
our $localtlpdb; # local installation which we are munging
my %options; # TL options from local tlpdb
@@ -477,91 +478,6 @@ sub handle_ret_hash {
}
-#
-# remove_package removes a single package with all files (including the
-# tlpobj files) and the entry from the tlpdb.
-#
-sub remove_package {
- my ($pkg, $localtlpdb) = @_;
- 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
- &TeXLive::TLUtils::do_postaction("remove", $tlp);
- }
- return \%ret;
-}
-
-
# REMOVE
#
# tlmgr remove foo bar baz
@@ -673,7 +589,8 @@ sub action_remove {
# the rest will not be run in dry_run mode
$foo{'mktexlsr'} = 1;
} else {
- merge_into(\%foo, &remove_package($pkg, $localtlpdb));
+ merge_into(\%foo,
+ $localtlmedia->remove_package($pkg));
logpackage("remove: $pkg");
}
if (keys %foo) {
@@ -696,7 +613,8 @@ sub action_remove {
info ("remove $pkg\n");
if (!$opts{"dry-run"}) {
my %foo;
- merge_into(\%foo, &remove_package($pkg, $localtlpdb));
+ merge_into(\%foo,
+ $localtlmedia->remove_package($pkg));
if (keys %foo) {
# removal was successful
logpackage("remove: $pkg");
@@ -1008,7 +926,7 @@ sub action_restore {
# first remove the package, then reinstall it
# this way we get rid of useless files
$opts{"backupdir"} = abs_path($opts{"backupdir"});
- merge_into(\%ret, &remove_package($pkg, $localtlpdb));
+ merge_into(\%ret, $localtlmedia->remove_package($pkg));
TeXLive::TLMedia->_install_package("$opts{'backupdir'}/${pkg}.r${rev}.tar.xz" , [] ,$localtlpdb);
logpackage("restore: $pkg ($rev)");
# now we have to read the .tlpobj file and add it to the DB
@@ -1563,7 +1481,7 @@ sub action_update {
}
}
if (!($opts{"dry-run"} or $opts{"list"} or $opts{"no-remove"})) {
- merge_into(\%ret, &remove_package($p, $localtlpdb));
+ merge_into(\%ret, $localtlmedia->remove_package($p));
logpackage("remove: $p");
}
}
@@ -1666,7 +1584,7 @@ sub action_update {
#
# the remove_package should also remove empty dirs in case
# a dir is changed into a file
- merge_into(\%ret, &remove_package($pkg, $localtlpdb));
+ merge_into(\%ret, $localtlmedia->remove_package($pkg));
my $foo = $tlmediasrc->install_package($pkg, $localtlpdb);
if (ref $foo) {
# installation succeeded because we got a reference
@@ -2495,8 +2413,11 @@ sub init_local_db {
# if the localtlpdb is already defined do simply return here already
# to make sure that the settings in the local tlpdb do not overwrite
# stuff changed via the GUI
+ return if defined $localtlmedia;
return if defined $localtlpdb;
- $localtlpdb = TeXLive::TLPDB->new ("root" => $Master);
+ $localtlmedia = TeXLive::TLMedia->new ("root" => $Master );
+ die("cannot setup TLMedia in $Master") unless (defined($localtlmedia));
+ $localtlpdb = $localtlmedia->tlpdb;
die("cannot find tlpdb in $Master") unless (defined($localtlpdb));
# setup the programs, for w32 we need the shipped wget/xz etc, so we
# pass the location of these files to setup_programs.
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