From ec8ddac0b1b2a0ba80424a1b47bb6bab9e35bcf5 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sun, 19 Apr 2009 14:58:33 +0000 Subject: synch with my new style search/location changes It's likely there will be some fallout, but it's getting a bit too large to keep around. This does kill a few very old oddities as well. --- usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm | 35 +++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm') diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm index 935ba2d299f..f073c13cff3 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepositoryList.pm,v 1.16 2007/05/19 09:50:31 espie Exp $ +# $OpenBSD: PackageRepositoryList.pm,v 1.17 2009/04/19 14:58:32 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie # @@ -23,20 +23,20 @@ package OpenBSD::PackageRepositoryList; sub new { my $class = shift; - return bless {list => [] }, $class; + return bless [], $class; } sub add { my $self = shift; - push @{$self->{list}}, @_; + push @$self, @_; } sub find { my ($self, $pkgname, $arch) = @_; - for my $repo (@{$self->{list}}) { + for my $repo (@$self) { my $pkg = $repo->find($pkgname, $arch); return $pkg if defined $pkg; } @@ -47,7 +47,7 @@ sub grabPlist { my ($self, $pkgname, $arch, $code) = @_; - for my $repo (@{$self->{list}}) { + for my $repo (@$self) { my $plist = $repo->grabPlist($pkgname, $arch, $code); return $plist if defined $plist; } @@ -57,7 +57,7 @@ sub grabPlist sub match { my ($self, @search) = @_; - for my $repo (@{$self->{list}}) { + for my $repo (@$self) { my @l = $repo->match(@search); if (@l > 0) { return @l; @@ -69,21 +69,32 @@ sub match sub match_locations { my ($self, @search) = @_; - for my $repo (@{$self->{list}}) { - my @l = $repo->match_locations(@search); - if (@l > 0) { - return @l; + for my $repo (@$self) { + my $l = $repo->match_locations(@search); + if (@$l > 0) { + return $l; } } - return (); + return []; } sub cleanup { my $self = shift; - for my $repo (@{$self->{list}}) { + for my $repo (@$self) { $repo->cleanup; } } +sub print_without_src +{ + my $self = shift; + my @l = (); + for my $repo (@$self) { + next if $repo->isa("OpenBSD::PackageRepository::Source"); + push(@l, $repo->url); + } + return join(':', @l); +} + 1; -- cgit v1.2.3