From a81221c13651412f324fecfb00629c5a5808b8d3 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 17 Nov 2017 01:29:05 +0000 Subject: tlmgr remove: support machine readable git-svn-id: svn://tug.org/texlive/trunk@45837 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/texlive/tlmgr.pl | 48 ++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'Master') 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); -- cgit v1.2.3