diff options
-rw-r--r-- | Master/tlpkg/etc/safer-update.diff | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Master/tlpkg/etc/safer-update.diff b/Master/tlpkg/etc/safer-update.diff new file mode 100644 index 00000000000..5cb8859aca1 --- /dev/null +++ b/Master/tlpkg/etc/safer-update.diff @@ -0,0 +1,53 @@ +Index: tlmgr.pl +=================================================================== +--- tlmgr.pl (revision 10534) ++++ tlmgr.pl (working copy) +@@ -734,10 +734,45 @@ + } + } + } else { +- print "update: $pkg (first remove old, then install new)\n"; +- merge_into(\%ret, &remove_package($pkg, $localtlpdb, 1)); ++ print "update: $pkg (install new ... "; ++ # we have to be careful hear. If we remove the package and ++ # later the install_package call which downloads fails, then ++ # we are in a rather bad shape ... ++ # ++ # We will create a list of currently contained files, and a ++ # list of files in the newer version, and do first install ++ # the new version, and if that succeeded, we will remove the ++ # files that are not present anymore in the package ++ my @oldfiles = $tlp->all_files; ++ my @newfiles = $mediatlp->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}; ++ } + merge_into(\%ret, $tlmediasrc->install_package($pkg, $localtlpdb, $opt_nodepends, 0)); +- print "update: $pkg done\n"; ++ # If we are still here, then that means that the installation ++ # has succeeded, because $tlmediasrc->_install_package dies ++ # in case of download/un-lzma/untar problems ++ # ++ print "remove old files ... "; ++ # 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; ++ } ++ print "done)\n"; + } + } + } elsif ($rev > $mediarev) { |