diff options
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageLocator.pm | 29 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Update.pm | 5 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 9 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_info | 5 |
4 files changed, 34 insertions, 14 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm index f4e95de293b..8772793c980 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageLocator.pm,v 1.58 2007/05/07 13:27:28 espie Exp $ +# $OpenBSD: PackageLocator.pm,v 1.59 2007/05/07 14:12:43 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -128,5 +128,32 @@ sub match_spec return OpenBSD::PkgSpec::match($spec); } +my $stemlist; + +sub findstem +{ + my ($class, $stem) = @_; + if (!@avail) { + @avail = available(); + } + require OpenBSD::PackageName; + if (!$stemlist) { + $stemlist = OpenBSD::PackageName::avail2stems(@avail); + } + return $stemlist->findstem($stem); +} + +sub find_partialstem +{ + my ($class, $partial) = @_; + if (!@avail) { + @avail = available(); + } + require OpenBSD::PackageName; + if (!$stemlist) { + $stemlist = OpenBSD::PackageName::avail2stems(@avail); + } + return $stemlist->find_partialstem($partial); +} 1; diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index 36ee3967425..480b2a49cd0 100644 --- a/usr.sbin/pkg_add/OpenBSD/Update.pm +++ b/usr.sbin/pkg_add/OpenBSD/Update.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Update.pm,v 1.68 2007/05/07 13:51:58 espie Exp $ +# $OpenBSD: Update.pm,v 1.69 2007/05/07 14:12:43 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -38,7 +38,6 @@ sub find @list = OpenBSD::Requiring->compute_closure(@list); } my @cantupdate = (); - my $hash = OpenBSD::PackageName::available_stems($state); OpenBSD::ProgressMeter::set_header("Looking for updates"); for my $pkgname (@list) { @@ -48,7 +47,7 @@ sub find next; } my $stem = OpenBSD::PackageName::splitstem($pkgname); - my @l = $hash->findstem($stem); + my @l = OpenBSD::PackageLocator->findstem($stem); if (@l == 0) { push(@cantupdate, $pkgname); next; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 71add1224bf..8719182eaf3 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.235 2007/05/07 13:51:58 espie Exp $ +# $OpenBSD: pkg_add,v 1.236 2007/05/07 14:12:43 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -582,8 +582,6 @@ sub find_truenames { my ($old, $new, $state) = @_; - my $allstems; - for my $pkgname (@$old) { if (OpenBSD::PackageName::is_stem($pkgname)) { my ($h, $path, $repo); @@ -591,10 +589,7 @@ sub find_truenames ($repo, $path, $pkgname) = OpenBSD::PackageLocator::path_parse($pkgname); $h = OpenBSD::PackageName::avail2stems($state, $repo->available); } else { - if (!defined $allstems) { - $allstems = OpenBSD::PackageName::available_stems($state); - } - $h = $allstems; + $h = 'OpenBSD::PackageLocator'; $path = ""; } my @l = $h->findstem($pkgname); diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info index 4a00ca14510..3042ba4591f 100644 --- a/usr.sbin/pkg_add/pkg_info +++ b/usr.sbin/pkg_add/pkg_info @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_info,v 1.46 2007/05/07 14:06:38 espie Exp $ +# $OpenBSD: pkg_info,v 1.47 2007/05/07 14:12:43 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -368,10 +368,9 @@ unless ($opt_c || $opt_M || $opt_U || $opt_d || $opt_f || $opt_I || $opt_i || if ($opt_Q) { require OpenBSD::PackageLocator; - my $stemlist = OpenBSD::PackageName::available_stems(); print "PKG_PATH=$ENV{PKG_PATH}\n" if $opt_v; - for my $p (sort $stemlist->find_partialstem($opt_Q)) { + for my $p (sort OpenBSD::PackageLocator->find_partialstem($opt_Q)) { print $p, is_installed($p) ? " (installed)" : "" , "\n"; } |