summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-01-01 12:58:31 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-01-01 12:58:31 +0000
commit791a462ff212aa467cd39446e57311ed07e27d57 (patch)
treef6a7de5d569ce42748ee80b0242db16e576be279 /usr.sbin/pkg_add
parent44ed6ee04c327dc2429f9f00c22f81393b92aeec (diff)
store repository paths in sets and propagate them.
This fixes pkg_add /some/path/package which will now find dependencies in the same path again.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm23
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm27
2 files changed, 24 insertions, 26 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index c92adcce955..b86157c81b6 100644
--- a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Dependencies.pm,v 1.116 2009/12/31 14:46:37 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.117 2010/01/01 12:58:30 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -388,9 +388,8 @@ sub dependencies
sub find_dep_in_repositories
{
my ($self, $state, $dep) = @_;
- require OpenBSD::PackageLocator;
- my $candidates = OpenBSD::PackageLocator->match_locations($dep->spec);
+ my $candidates = $self->{set}->match_locations($dep->spec);
if (!$state->{defines}->{allversions}) {
require OpenBSD::Search;
$candidates = OpenBSD::Search::FilterLocation->
@@ -527,6 +526,7 @@ sub solve_dependency
return $v;
}
my $set = OpenBSD::UpdateSet->new->add_older(OpenBSD::Handle->create_old($v, $state));
+ $set->merge_paths($self->{set});
$self->add_dep($set);
$self->set_cache($dep, _cache::to_update->new($v));
$state->tracker->todo($set);
@@ -539,17 +539,18 @@ sub solve_dependency
}
$v = $self->find_dep_in_repositories($state, $dep);
+
+ my $s;
if ($v) {
- my $s = OpenBSD::UpdateSet->from_location($v);
- $state->tracker->todo($s);
- $self->add_dep($s);
- $self->set_cache($dep, _cache::to_install->new($v->name));
- return $v->name;
+ $s = OpenBSD::UpdateSet->from_location($v);
+ $v = $v->name;
+ } else {
+ # resort to default if nothing else
+ $v = $dep->{def};
+ $s = OpenBSD::UpdateSet->create_new($v);
}
- # resort to default if nothing else
- $v = $dep->{def};
- my $s = OpenBSD::UpdateSet->create_new($v);
+ $s->merge_paths($self->{set});
$state->tracker->todo($s);
$self->add_dep($s);
$self->set_cache($dep, _cache::to_install->new($v));
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index 3e70756a14f..c4024ecb11e 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.122 2009/12/28 19:28:59 espie Exp $
+# $OpenBSD: Update.pm,v 1.123 2010/01/01 12:58:30 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -43,7 +43,6 @@ sub update
package OpenBSD::Update;
use OpenBSD::PackageInfo;
-use OpenBSD::PackageLocator;
use OpenBSD::PackageName;
use OpenBSD::Error;
use OpenBSD::UpdateSet;
@@ -165,7 +164,7 @@ sub process_handle
push(@search, OpenBSD::Search::FilterLocation->keep_most_recent);
}
- my $l = OpenBSD::PackageLocator->match_locations(@search);
+ my $l = $set->match_locations(@search);
if (@$l == 0) {
if ($oldfound) {
$h->{update_found} = $h;
@@ -214,11 +213,11 @@ sub process_hint
# first try to find us exactly
$state->progress->message("Looking for $hint_name");
- $l = OpenBSD::PackageLocator->match_locations(OpenBSD::Search::Exact->new($hint_name), $k);
+ $l = $set->match_locations(OpenBSD::Search::Exact->new($hint_name), $k);
if (@$l == 0) {
my $t = $hint_name;
$t =~ s/\-\d([^-]*)\-?/--/;
- $l = OpenBSD::PackageLocator->match_locations(OpenBSD::Search::Stem->new($t), $k);
+ $l = $set->match_locations(OpenBSD::Search::Stem->new($t), $k);
}
my $r = $state->choose_location($hint_name, $l);
if (defined $r) {
@@ -236,15 +235,13 @@ sub process_hint2
my ($self, $set, $hint, $state) = @_;
my $pkgname = $hint->pkgname;
if (OpenBSD::PackageName::is_stem($pkgname)) {
- my ($h, $path, $repo);
if ($pkgname =~ m/\//o) {
- ($repo, $path, $pkgname) = OpenBSD::PackageLocator::path_parse($pkgname);
- $h = $repo;
- } else {
- $h = 'OpenBSD::PackageLocator';
- $path = "";
- }
- my $l = $state->updater->stem2location($h, $pkgname, $state,
+ require OpenBSD::PackageLocator;
+ my $repo;
+ ($repo, undef, $pkgname) = OpenBSD::PackageLocator::path_parse($pkgname);
+ $set->add_repositories($repo);
+ };
+ my $l = $state->updater->stem2location($set, $pkgname, $state,
$set->{quirks});
if (defined $l) {
$self->add_location($set, $hint, $l);
@@ -289,8 +286,8 @@ sub process_set
sub stem2location
{
- my ($self, $repo, $name, $state, $is_quirks) = @_;
- my $l = $repo->match_locations(OpenBSD::Search::Stem->new($name));
+ my ($self, $locator, $name, $state, $is_quirks) = @_;
+ my $l = $locator->match_locations(OpenBSD::Search::Stem->new($name));
if (@$l > 1 && !$state->{defines}->{allversions}) {
$l = OpenBSD::Search::FilterLocation->keep_most_recent->filter_locations($l);
}