summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2017-11-17 01:29:05 +0000
committerNorbert Preining <preining@logic.at>2017-11-17 01:29:05 +0000
commita81221c13651412f324fecfb00629c5a5808b8d3 (patch)
tree46b1f9c5a621e834d2a4b5739c7d161867669c5e /Master/texmf-dist/scripts
parenta215227b9ffbeb4565db7264e2e7d9f39ea10c0b (diff)
tlmgr remove: support machine readable
git-svn-id: svn://tug.org/texlive/trunk@45837 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl48
1 files changed, 43 insertions, 5 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index 5ce566bcffb..f7fe02b1b4f 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -541,7 +541,7 @@ for the full story.\n";
# --machine-readable is only supported by update.
if ($::machinereadable &&
- $action ne "update" && $action ne "install" && $action ne "option" && $action ne "shell") {
+ $action ne "update" && $action ne "install" && $action ne "option" && $action ne "shell" && $action ne "remove") {
tlwarn("$prg: --machine-readable output not supported for $action\n");
}
@@ -1120,6 +1120,20 @@ sub action_remove {
}
}
@packs = keys %packs;
+
+ my %sizes = %{$localtlpdb->sizes_of_packages(
+ $localtlpdb->option("install_srcfiles"),
+ $localtlpdb->option("install_docfiles"), undef, @packs)};
+ defined($sizes{'__TOTAL__'}) || ($sizes{'__TOTAL__'} = 0);
+ my $totalsize = $sizes{'__TOTAL__'};
+ my $totalnr = $#packs;
+ my $currnr = 1;
+ my $starttime = time();
+ my $donesize = 0;
+
+ print "total-bytes\t$sizes{'__TOTAL__'}\n" if $::machinereadable;
+ print "end-of-header\n" if $::machinereadable;
+
foreach my $pkg (sort @packs) {
my $tlp = $localtlpdb->get_package($pkg);
next if defined($already_removed{$pkg});
@@ -1127,17 +1141,27 @@ sub action_remove {
info("$pkg: package not present, cannot remove\n");
$ret |= $F_WARNING;
} else {
+ my ($estrem, $esttot) = TeXLive::TLUtils::time_estimate($totalsize,
+ $donesize, $starttime);
+
# in the first round we only remove collections, nothing else
# but removing collections will remove all dependencies, too
# save the information of which packages have already been removed
# into %already_removed.
if ($tlp->category eq "Collection") {
my $foo = 0;
- info ("$prg: removing $pkg\n");
+ if ($::machinereadable) {
+ machine_line($pkg, "d", $tlp->revision, "-", $sizes{$pkg}, $estrem, $esttot);
+ } else {
+ # info ("$prg: removing $pkg\n");
+ info("[$currnr/$totalnr, $estrem/$esttot] remove: $pkg\n");
+ }
if (!$opts{"dry-run"}) {
$foo = backup_and_remove_package($pkg, $autobackup);
logpackage("remove: $pkg");
}
+ $currnr++;
+ $donesize += $sizes{$pkg};
if ($foo) {
# removal was successful, so the return is at least 0x0001 mktexlsr
# remove dependencies, too
@@ -1153,8 +1177,19 @@ sub action_remove {
}
}
foreach my $pkg (sort @more_removal) {
+ my $tlp = $localtlpdb->get_package($pkg);
if (!defined($already_removed{$pkg})) {
- info ("$prg: removing package $pkg\n");
+ my ($estrem, $esttot) = TeXLive::TLUtils::time_estimate($totalsize,
+ $donesize, $starttime);
+ # info ("$prg: removing package $pkg\n");
+ if ($::machinereadable) {
+ machine_line($pkg, "d", $tlp->revision, "-", $sizes{$pkg}, $estrem, $esttot);
+ } else {
+ # info ("$prg: removing $pkg\n");
+ info("[$currnr/$totalnr, $estrem/$esttot] remove: $pkg\n");
+ }
+ $currnr++;
+ $donesize += $sizes{$pkg};
if (!$opts{"dry-run"}) {
if (backup_and_remove_package($pkg, $autobackup)) {
# removal was successful
@@ -1164,6 +1199,7 @@ sub action_remove {
}
}
}
+ print "end-of-updates\n" if $::machinereadable;
if ($opts{"dry-run"}) {
# stop here, don't do any postinstall actions
return ($ret | $F_NOPOSTACTION);
@@ -1171,9 +1207,11 @@ sub action_remove {
$localtlpdb->save;
my @foo = sort keys %already_removed;
if (@foo) {
- info("$prg: ultimately removed these packages: @foo\n");
+ info("$prg: ultimately removed these packages: @foo\n")
+ if (!$::machinereadable);
} else {
- info("$prg: no packages removed.\n");
+ info("$prg: no packages removed.\n")
+ if (!$::machinereadable);
}
}
return ($ret);