From 1916482c3b5251a8990e00259e2889f8883239b1 Mon Sep 17 00:00:00 2001 From: espie Date: Mon, 30 May 2022 09:30:40 +0000 Subject: [PATCH] tweak the display a bit: have "hashing/tieing" be progress messages (they probably won't mean a lot to most users but then they only appear fleetingly apart from stuff like texlive) --- usr.sbin/pkg_add/OpenBSD/PkgAdd.pm | 32 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm index 8660ea6f41e..f92b9534c35 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgAdd.pm,v 1.134 2022/05/11 17:17:35 espie Exp $ +# $OpenBSD: PkgAdd.pm,v 1.135 2022/05/30 09:30:40 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -81,7 +81,7 @@ sub tie_files package OpenBSD::PackingElement::FileBase; sub hash_files { - my ($self, $sha, $state) = @_; + my ($self, $state, $sha) = @_; return if $self->{link} or $self->{symlink} or $self->{nochecksum}; if (defined $self->{d}) { push @{$sha->{$self->{d}->key}}, $self; @@ -90,7 +90,7 @@ sub hash_files sub tie_files { - my ($self, $sha, $state) = @_; + my ($self, $state, $sha) = @_; return if $self->{link} or $self->{symlink} or $self->{nochecksum}; # XXX python doesn't like this, overreliance on timestamps return if $self->{name} =~ m/\.py$/ && !defined $self->{ts}; @@ -117,8 +117,8 @@ sub tie_files # and we also need to tell size computation we won't be # needing extra room for this. $tied->{tied} = 1; - $state->say("Tying #1 to #2", $self->stringize, - $tied->realname($state)) if $state->verbose >= 3; + $state->say("Tying #1 to #2", $self->stringize, $realname) + if $state->verbose >= 3; } } @@ -788,13 +788,6 @@ sub really_add my $errors = 0; - if ($state->{not}) { - $state->status->what("Pretending to add"); - } else { - $state->status->what("Adding"); - } - $set->setup_header($state); - # XXX in `combined' updates, some dependencies may remove extra # packages, so we do a double-take on the list of packages we # are actually replacing. @@ -961,10 +954,14 @@ sub may_tie_files my $sha = {}; for my $o ($set->older_to_do) { - $o->{plist}->hash_files($sha, $state); + $set->setup_header($state, $o, "hashing"); + $state->progress->visit_with_count($o->{plist}, + 'hash_files', $sha); } for my $n ($set->newer) { - $n->{plist}->tie_files($sha, $state); + $set->setup_header($state, $n, "tieing"); + $state->progress->visit_with_count($n->{plist}, + 'tie_files', $sha); } } } @@ -1079,13 +1076,18 @@ sub process_set if ($state->verbose && !$set->{simple_update}) { $state->say("Update Set #1 runs exec commands", $set->print); } - may_tie_files($set, $state); if ($set->newer > 0 || $set->older_to_do > 0) { + if ($state->{not}) { + $state->status->what("Pretending to add"); + } else { + $state->status->what("Adding"); + } for my $h ($set->newer) { $h->plist->set_infodir($h->location->info); delete $h->location->{contents}; } + may_tie_files($set, $state); if (!$set->validate_plists($state)) { $state->{bad}++; $set->cleanup(OpenBSD::Handle::CANT_INSTALL, -- 2.20.1