diff options
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/AddDelete.pm | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm | 10 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Tracker.pm | 23 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/UpdateSet.pm | 3 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 13 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete | 8 |
6 files changed, 49 insertions, 14 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm index 573c0569f5a..98136795923 100644 --- a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm +++ b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: AddDelete.pm,v 1.7 2009/12/17 11:11:51 espie Exp $ +# $OpenBSD: AddDelete.pm,v 1.8 2009/12/19 14:21:14 espie Exp $ # # Copyright (c) 2007-2009 Marc Espie <espie@openbsd.org> # @@ -220,9 +220,9 @@ sub init sub ntogo { - my $self = shift; + my ($self, $offset) = @_; - return $self->progress->ntogo($self->{todo}); + return $self->progress->ntogo($self->todo, $offset); } sub vstat diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm index be7f8d7cc65..0614bbe3c40 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.25 2009/12/17 11:11:51 espie Exp $ +# $OpenBSD: ProgressMeter.pm,v 1.26 2009/12/19 14:21:14 espie Exp $ # # Copyright (c) 2004-2007 Marc Espie <espie@openbsd.org> # @@ -161,9 +161,13 @@ sub next sub ntogo { - my ($self, $todo) = @_; + my ($self, $todo, $offset) = @_; + + $todo //= 0; + $offset //= 0; + $todo += $offset; - if (defined $todo && $todo > 0) { + if ($todo > 0) { return " ($todo to go)"; } else { return ""; diff --git a/usr.sbin/pkg_add/OpenBSD/Tracker.pm b/usr.sbin/pkg_add/OpenBSD/Tracker.pm index 485e14b0797..97c111e565d 100644 --- a/usr.sbin/pkg_add/OpenBSD/Tracker.pm +++ b/usr.sbin/pkg_add/OpenBSD/Tracker.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Tracker.pm,v 1.16 2009/12/14 18:11:26 espie Exp $ +# $OpenBSD: Tracker.pm,v 1.17 2009/12/19 14:21:14 espie Exp $ # # Copyright (c) 2009 Marc Espie <espie@openbsd.org> # @@ -38,6 +38,22 @@ sub new return bless {}, $class; } +sub sets_todo +{ + my $self = shift; + + return scalar keys %{$self->{todo}}; +} +sub handle_set +{ + my ($self, $set) = @_; + if ($set->{finished}) { + delete $self->{todo}->{$set}; + } else { + $self->{todo}->{$set} = 1; + } +} + sub known { my ($self, $set) = @_; @@ -60,6 +76,7 @@ sub add_set $self->{uptodate}->{$n->pkgname} = 1; } $self->known($set); + $self->handle_set($set); return $self; } @@ -82,11 +99,13 @@ sub remove_set delete $self->{to_update}->{$n->pkgname}; delete $self->{cant_update}->{$n->pkgname}; } + $self->handle_set($set); } sub uptodate { my ($self, $set) = @_; + $set->{finished} = 1; $self->remove_set($set); for my $n ($set->older, $set->kept) { $self->{uptodate}->{$n->pkgname} = 1; @@ -96,6 +115,7 @@ sub uptodate sub cant { my ($self, $set) = @_; + $set->{finished} = 1; $self->remove_set($set); for my $n ($set->older) { $self->{cant_update}->{$n->pkgname} = 1; @@ -106,6 +126,7 @@ sub done { my ($self, $set) = @_; + $set->{finished} = 1; $self->remove_set($set); $self->known($set); diff --git a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm index 8551035a3c6..64bb3782344 100644 --- a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm +++ b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: UpdateSet.pm,v 1.39 2009/12/14 18:11:26 espie Exp $ +# $OpenBSD: UpdateSet.pm,v 1.40 2009/12/19 14:21:14 espie Exp $ # # Copyright (c) 2007-2009 Marc Espie <espie@openbsd.org> # @@ -282,6 +282,7 @@ sub merge $self->add_older($set->older); # ... and mark it as already done $set->{finished} = 1; + $tracker->handle_set($set); $self->{updates} += $set->{updates}; $set->{updates} = 0; # XXX and mark it as merged, for eventual updates diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 1e05b50ec35..d1801eb38a8 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.429 2009/12/19 09:21:04 espie Exp $ +# $OpenBSD: pkg_add,v 1.430 2009/12/19 14:21:14 espie Exp $ # # Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org> # @@ -77,6 +77,12 @@ sub build_deptree } } +sub todo +{ + my $state = shift; + return $state->tracker->sets_todo; +} + sub deptree_header { my ($state, $pkg) = @_; @@ -536,7 +542,7 @@ sub really_add } }); $set->setup_header($state); - $state->progress->next($state->ntogo); + $state->progress->next($state->ntogo(-1)); for my $handle ($set->newer) { my $pkgname = $handle->pkgname; my $plist = $handle->plist; @@ -571,7 +577,6 @@ sub install_set } if (!$state->updater->process_set($set, $state)) { - $set->{finished} = 1; return (); } @@ -845,7 +850,6 @@ framework( sub { if ($state->{allow_replacing}) { $state->progress->set_header("Looking for packages"); - $state->{todo} = (scalar @todo2) + 1; do_quirks($state); } @@ -853,7 +857,6 @@ sub { # This is the actual very small loop that adds all packages while (my $set = shift @todo2) { $state->progress->set_header("Looking for packages"); - $state->{todo} = scalar @todo2; unshift(@todo2, install_set($set, $state)); eval { $state->quirks->tweak_list(\@todo2, $state); diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete index 8c53c8613d2..96eabcc107d 100644 --- a/usr.sbin/pkg_add/pkg_delete +++ b/usr.sbin/pkg_add/pkg_delete @@ -1,6 +1,6 @@ #!/usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_delete,v 1.128 2009/11/28 10:05:58 espie Exp $ +# $OpenBSD: pkg_delete,v 1.129 2009/12/19 14:21:14 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -24,6 +24,12 @@ use OpenBSD::AddDelete; package OpenBSD::State; our @ISA=(qw(OpenBSD::UI)); +sub todo +{ + my $state = shift; + return $state->{todo}; +} + package OpenBSD::AddDelete; our ($state, %defines, $bad, $opt_B); |