diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgCheck.pm | 17 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm | 17 |
2 files changed, 23 insertions, 11 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm b/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm index 67d33b9282b..0a157669ab7 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCheck.pm,v 1.17 2010/06/15 08:53:55 espie Exp $ +# $OpenBSD: PkgCheck.pm,v 1.18 2010/06/18 09:01:38 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # @@ -221,7 +221,7 @@ use OpenBSD::Log; sub init { my $self = shift; - $self->{l} = OpenBSD::Log->new; + $self->{l} = OpenBSD::Log->new($self); $self->SUPER::init; } @@ -441,14 +441,11 @@ sub for_all_packages { my ($self, $state, $l, $msg, $code) = @_; - my $total = scalar @$l; - $state->progress->set_header($msg); - my $i = 0; - for my $name (@$l) { - $state->progress->show(++$i, $total); - next if $state->{removed}{$name}; - &$code($name); - } + $state->progress->for_list($msg, $l, + sub { + next if $state->{removed}{$_[0]}; + &$code; + }); } sub sanity_check diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm index 6baf91e1b17..3319f68a6ba 100644 --- a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm +++ b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: ProgressMeter.pm,v 1.33 2010/06/05 12:01:08 espie Exp $ +# $OpenBSD: ProgressMeter.pm,v 1.34 2010/06/18 09:01:38 espie Exp $ # # Copyright (c) 2010 Marc Espie <espie@openbsd.org> # @@ -46,6 +46,21 @@ sub errprint print STDERR @_; } +sub for_list +{ + my ($self, $msg, $l, $code) = @_; + if (defined $msg) { + $self->set_header($msg); + } + my $total = scalar @$l; + my $i = 0; + for my $e (@$l) { + $self->show(++$i, $total); + &$code($e); + } + $self->next; +} + # stub class when no actual progressmeter that still prints out. package OpenBSD::ProgressMeter::Stub; our @ISA = qw(OpenBSD::ProgressMeter); |