summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-01-09 13:42:04 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-01-09 13:42:04 +0000
commit1302aec079707d28d0a9ae45d01a5b5f7b1784e4 (patch)
tree7c7dc6eb0cb2e3f15901f55f379204afd3d1807a /usr.sbin/pkg_add
parente5c39d873f91aad77d17c09225a6e683f9ecdad6 (diff)
create unique object for each repo
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepository.pm28
1 files changed, 18 insertions, 10 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
index 6297ea6a661..e41e683b62d 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageRepository.pm,v 1.75 2010/01/09 12:01:57 espie Exp $
+# $OpenBSD: PackageRepository.pm,v 1.76 2010/01/09 13:42:03 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -47,18 +47,25 @@ sub new
return $o;
}
-# we have to pass a reference because we want to:
-# - strip the scheme
-# - report whether we stripped it
-# (relevant for file: url, where we strip, but don't care if we did
-# vs other schemes, where not having the ftp: marker is a problem)
+my $cache = {};
+
+sub unique
+{
+ my ($class, $o) = @_;
+ return $o unless defined $o;
+ if (defined $cache->{$o->url}) {
+ return $cache->{$o->url};
+ }
+ $cache->{$o->url} = $o;
+ return $o;
+}
sub parse_fullurl
{
my ($class, $r) = @_;
$class->strip_urlscheme($r) or return undef;
- return $class->parse_url($r);
+ return $class->unique($class->parse_url($r));
}
sub parse
@@ -264,7 +271,7 @@ sub parse_fullurl
if (!$ok && $o->{path} eq $class->pkg_db()."/") {
return OpenBSD::PackageRepository::Installed->new;
} else {
- return $o;
+ return $class->unique($o);
}
}
@@ -353,10 +360,11 @@ sub may_exist
return 1;
}
+my $s = bless {}, __PACKAGE__;
+
sub new
{
- my $class = shift;
- bless {}, $class;
+ return $s;
}
sub open_pipe