diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2009-11-08 09:39:22 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2009-11-08 09:39:22 +0000 |
commit | 88ed14ed4437db0fc7aaadb75df641525b2be45a (patch) | |
tree | 2826ef6dfc66bda2471c9b74e92354507740ea8c /usr.sbin/pkg_add | |
parent | 725d974373f4678337d6a1766695c198a7e3d411 (diff) |
put all the state of the current update into the tracker
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Tracker.pm | 26 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 13 |
2 files changed, 33 insertions, 6 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Tracker.pm b/usr.sbin/pkg_add/OpenBSD/Tracker.pm index bb5af15b4e5..fb67fabb179 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.4 2009/10/19 14:07:26 espie Exp $ +# $OpenBSD: Tracker.pm,v 1.5 2009/11/08 09:39:21 espie Exp $ # # Copyright (c) 2009 Marc Espie <espie@openbsd.org> # @@ -61,6 +61,24 @@ sub remove_set } } +sub mark_uptodate +{ + my ($self, $set) = @_; + for my $n ($set->older) { + delete $self->{to_update}->{$n->pkgname}; + $self->{uptodate}->{$n->pkgname} = 1; + } +} + +sub mark_cant_update +{ + my ($self, $set) = @_; + for my $n ($set->older) { + delete $self->{to_update}->{$n->pkgname}; + $self->{cant_update}->{$n->pkgname} = 1; + } +} + sub mark_installed { my ($self, $set) = @_; @@ -82,4 +100,10 @@ sub installed return keys %{$self->{installed}}; } +sub cant_update +{ + my $self = shift; + return keys %{$self->{cant_update}}; +} + 1; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 6e71e9ffb90..67ddee7daec 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.369 2009/11/04 16:50:02 espie Exp $ +# $OpenBSD: pkg_add,v 1.370 2009/11/08 09:39:21 espie Exp $ # # Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org> # @@ -662,6 +662,9 @@ $state->check_root; # later for the most part... my @todo2 = (); +require OpenBSD::Tracker; +$state->{tracker} = OpenBSD::Tracker->new; + if ($opt_l) { open my $f, '<', $opt_l or die "$!: bad list $opt_l"; my $_; @@ -704,7 +707,6 @@ if ($opt_l || $opt_z) { my $updater = OpenBSD::Update->new; my $inst = OpenBSD::PackageRepository::Installed->new; $state->progress->set_header("Looking for updates"); - my @cantupdate = (); for my $pkgname (@ARGV) { my $l; @@ -723,14 +725,17 @@ if ($opt_l || $opt_z) { } if ($set->newer > 0) { push(@todo2, $set); + } else { + $state->{tracker}->mark_uptodate($set); } if ($problem) { - push(@cantupdate, $set); + $state->{tracker}->mark_cant_update($set); } } } $state->progress->next; + my @cantupdate = $state->{tracker}->cant_update; if (@cantupdate > 0) { print "Cannot find updates for ", join(', ', map {$_->short_print} (@cantupdate > 50 ? @cantupdate[1..50] : @cantupdate)); print " and more" if @cantupdate > 50; @@ -774,8 +779,6 @@ local $SIG{'TERM'} = $handler; # This is the actual very small loop that adds all packages eval { -require OpenBSD::Tracker; -$state->{tracker} = OpenBSD::Tracker->new; $state->{tracker}->add_sets(@todo2); while (my $set = shift @todo2) { unshift(@todo2, install_set($set, $state)); |