summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-09-10 15:36:50 +0000
committerNorbert Preining <preining@logic.at>2008-09-10 15:36:50 +0000
commit5f4b06b3e5b3cc0edf3a983932e4395d09885b1f (patch)
treea8563042614654f194f1b83f0c34ecb2baf987c9
parent7cd1e6b087e10419341fb6fb7dea2eb2446e9db0 (diff)
update safer-update.diff to also make the restore function safer
git-svn-id: svn://tug.org/texlive/trunk@10543 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/tlpkg/etc/safer-update.diff97
1 files changed, 93 insertions, 4 deletions
diff --git a/Master/tlpkg/etc/safer-update.diff b/Master/tlpkg/etc/safer-update.diff
index 816c8c266ea..4c600720f14 100644
--- a/Master/tlpkg/etc/safer-update.diff
+++ b/Master/tlpkg/etc/safer-update.diff
@@ -1,8 +1,57 @@
-Index: tlmgr.pl
+Index: texmf/scripts/texlive/tlmgr.pl
===================================================================
---- tlmgr.pl (revision 10534)
-+++ tlmgr.pl (working copy)
-@@ -734,10 +734,45 @@
+--- texmf/scripts/texlive/tlmgr.pl (revision 10534)
++++ texmf/scripts/texlive/tlmgr.pl (working copy)
+@@ -541,15 +541,44 @@
+ print "Restoring $pkg, $rev from $opt_backupdir/${pkg}.r${rev}.tar.lzma\n";
+ if (!$opt_dry) {
+ init_local_db(1);
+- # first remove the package, then reinstall it
+- # this way we get rid of useless files
+- # force the deinstallation since we will reinstall it
++ # get the files of the current package
++ my $tlp = $localtlpdb->get_package($pkg);
++ my @oldfiles;
++ my @newfiles;
++ if (!defined($tlp)) {
++ @oldfiles = ();
++ } else {
++ @oldfiles = $tlp->all_files;
++ }
++ # install the backup package
+ $opt_backupdir = abs_path($opt_backupdir);
+- merge_into(\%ret, &remove_package($pkg, $localtlpdb, 1));
+ TeXLive::TLMedia->_install_package("$opt_backupdir/${pkg}.r${rev}.tar.lzma" , [] ,$localtlpdb);
+ # now we have to read the .tlpobj file and add it to the DB
+ my $tlpobj = TeXLive::TLPOBJ->new;
+ $tlpobj->from_file($localtlpdb->root . "/tlpkg/tlpobj/$pkg.tlpobj");
++ @newfiles = $tlpobj->all_files;
++ my %removefiles = ();
++ # we create an array with key of all the old files, and then
++ # remove all key/value pairs for files occurring in the new
++ # files list. The remaining files should be removed.
++ for my $f (@oldfiles) {
++ $removefiles{$f} = 1;
++ }
++ for my $f (@newfiles) {
++ delete $removefiles{$f};
++ }
++ # we have to chdir to $localtlpdb->root
++ my $Master = $localtlpdb->root;
++ chdir ($Master) || die "chdir($Master) failed: $!";
++ my @files = keys %removefiles;
++ my @removals = &removed_dirs (@files);
++ foreach my $entry (@files) {
++ unlink $entry;
++ }
++ foreach my $entry (@removals) {
++ rmdir $entry;
++ }
++ # add the new tlpobj, overwriting the old one
+ $localtlpdb->add_tlpobj($tlpobj);
+ $ret = $localtlpdb->get_package($pkg)->make_return_hash_from_executes("enable");
+ $localtlpdb->save;
+@@ -734,10 +763,45 @@
}
}
} else {
@@ -51,3 +100,43 @@ Index: tlmgr.pl
}
}
} elsif ($rev > $mediarev) {
+@@ -790,6 +854,7 @@
+ print "install: $pkg\n";
+ } else {
+ # install the packages and run postinstall actions (that is the 0)
++ info("install: $pkg\n");
+ merge_into(\%ret, $tlmediasrc->install_package($pkg, $localtlpdb, $opt_nodepends, 0));
+ }
+ }
+@@ -943,6 +1008,7 @@
+ if ($opt_dry) {
+ print "Installing $pkg.$a\n";
+ } else {
++ info("install: $pkg.$a\n");
+ merge_into(\%ret, $tlmediasrc->install_package("$pkg.$a", $localtlpdb, 0, 0));
+ }
+ }
+@@ -951,8 +1017,11 @@
+ }
+ if (TeXLive::TLUtils::member('win32', @todoarchs)) {
+ # install the necessary win32 stuff
++ info("install: bin-tlperl.win32\n");
+ merge_into (\%ret, $tlmediasrc->install_package("bin-tlperl.win32", $localtlpdb, 1, 0));
++ info("install: bin-tlgs.win32\n");
+ merge_into (\%ret, $tlmediasrc->install_package("bin-tlgs.win32", $localtlpdb, 1, 0));
++ info("install: bin-tlpsv.win32\n");
+ merge_into (\%ret, $tlmediasrc->install_package("bin-tlpsv.win32", $localtlpdb, 1, 0));
+ }
+ # update the option_archs list of installed archs
+Index: tlpkg/TeXLive/TLMedia.pm
+===================================================================
+--- tlpkg/TeXLive/TLMedia.pm (revision 10538)
++++ tlpkg/TeXLive/TLMedia.pm (working copy)
+@@ -117,7 +117,6 @@
+ # even if opt_doc is false
+ $real_opt_doc = 1;
+ }
+- info("install: $pkg\n");
+ foreach my $h (@::install_packages_hook) {
+ &$h("install: $package");
+ }