summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2017-05-10 04:44:02 +0000
committerNorbert Preining <preining@logic.at>2017-05-10 04:44:02 +0000
commitbae3d114dbc0fdea3ccc6018b98f65dec709c26d (patch)
tree73c0bdad66cce52bb9d90127267b67ccac329839 /Master
parentd83ac58de956453fcb161c2860f8f8cc080a5848 (diff)
backup pkgs in action_remove, allow for --backup etc in remove
git-svn-id: svn://tug.org/texlive/trunk@44275 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl62
1 files changed, 48 insertions, 14 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index 1ac5e16ae8a..1c073b7c17d 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -274,6 +274,8 @@ my %action_specification = (
},
"remove" => {
"options" => {
+ "backup" => 1,
+ "backupdir" => "=s",
"dry-run|n" => 1,
"force" => 1,
"no-depends" => 1,
@@ -1011,8 +1013,28 @@ sub action_include_tlpobj {
# will absolutely only install foo bar baz not even taking .ARCH into
# account
#
+
+sub backup_and_remove_package {
+ my ($pkg, $autobackup) = @_;
+ my $tlp = $localtlpdb->get_package($pkg);
+ if (!defined($tlp)) {
+ info("$pkg: package not present, cannot remove\n");
+ return($F_WARNING);
+ }
+ if ($opts{"backup"}) {
+ $tlp->make_container("xz", $localtlpdb->root,
+ $opts{"backupdir"},
+ "${pkg}.r" . $tlp->revision,
+ $tlp->relocated);
+ if ($autobackup) {
+ # in case we do auto backups we remove older backups
+ clear_old_backups($pkg, $opts{"backupdir"}, $autobackup);
+ }
+ }
+ return($localtlpdb->remove_package($pkg));
+}
+
sub action_remove {
- my $ret = $F_OK;
# we do the following:
# - (not implemented) order collections such that those depending on
# other collections are first removed, and then those which only
@@ -1034,6 +1056,10 @@ sub action_remove {
init_local_db();
return($F_ERROR) if !check_on_writable();
info("$prg remove: dry run, no changes will be made\n") if $opts{"dry-run"};
+
+ my ($ret, $autobackup) = setup_backup_directory();
+ return ($ret) if ($ret != $F_OK);
+
my @packs = @ARGV;
#
# we have to be careful not to remove too many packages. The idea is
@@ -1099,7 +1125,7 @@ sub action_remove {
my $foo = 0;
info ("$prg: removing $pkg\n");
if (!$opts{"dry-run"}) {
- $foo = $localtlpdb->remove_package($pkg);
+ $foo = backup_and_remove_package($pkg, $autobackup);
logpackage("remove: $pkg");
}
if ($foo) {
@@ -1120,7 +1146,7 @@ sub action_remove {
if (!defined($already_removed{$pkg})) {
info ("$prg: removing package $pkg\n");
if (!$opts{"dry-run"}) {
- if ($localtlpdb->remove_package($pkg)) {
+ if (backup_and_remove_package($pkg, $autobackup)) {
# removal was successful
logpackage("remove: $pkg");
$already_removed{$pkg} = 1;
@@ -2926,17 +2952,8 @@ sub action_update {
debug("$prg: warn, relocated bit set for $p, but that is wrong!\n");
$pkg->relocated(0);
}
- if ($opts{"backup"}) {
- $pkg->make_container("xz", $root,
- $opts{"backupdir"},
- "${p}.r" . $pkg->revision,
- $pkg->relocated);
- if ($autobackup) {
- # in case we do auto backups we remove older backups
- clear_old_backups($p, $opts{"backupdir"}, $autobackup);
- }
- }
- $localtlpdb->remove_package($p);
+ # TODO we do not check return value here!
+ backup_and_remove_package($p, $autobackup);
logpackage("remove: $p");
}
info("done\n") unless $::machinereadable;
@@ -7733,6 +7750,23 @@ package, dependencies are never removed. Options:
=over 4
+=item B<--backup> and B<--backupdir> I<directory>
+
+These two options control the creation of backups of packages I<before>
+removal; that is, backup of packages as currently installed. If
+neither of these options are given, no backup package will be saved. If
+C<--backupdir> is given and specifies a writable directory then a backup
+will be made in that location. If only C<--backup> is given, then a
+backup will be made to the directory previously set via the C<option>
+action (see below). If both are given then a backup will be made to the
+specified I<directory>.
+
+You can set options via the C<option> action to automatically create
+backups for all packages, and/or keep only a certain number of
+backups. Please see the C<option> action for details.
+
+The C<restore> action explains how to restore from a backup.
+
=item B<--no-depends>
Do not remove dependent packages.