diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-06-30 10:37:27 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-06-30 10:37:27 +0000 |
commit | e4af358814d442aaf0c593a010db82911a595f9d (patch) | |
tree | c166ebd610faaa604ea244660ea8f698960d08e9 /usr.sbin | |
parent | 070facfeab089348bed90fec6499e501f76d8721 (diff) |
extra parameter to UpdateSet: use the factory to create extra object.
don't create updatesets directly, go through AddDelete::State.
Get all Locator/Repo access through state.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Dependencies.pm | 12 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageLocator.pm | 2 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm | 2 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgAdd.pm | 22 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/UpdateSet.pm | 15 |
5 files changed, 23 insertions, 30 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm index f9abfb26d83..7736c0eac67 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.129 2010/06/09 07:26:01 espie Exp $ +# $OpenBSD: Dependencies.pm,v 1.130 2010/06/30 10:37:25 espie Exp $ # # Copyright (c) 2005-2010 Marc Espie <espie@openbsd.org> # @@ -546,7 +546,7 @@ sub solve_dependency if ($state->tracker->is_known($v)) { return $v; } - my $set = OpenBSD::UpdateSet->new->add_older(OpenBSD::Handle->create_old($v, $state)); + my $set = $state->updateset->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)); @@ -563,12 +563,12 @@ sub solve_dependency my $s; if ($v) { - $s = OpenBSD::UpdateSet->from_location($v); + $s = $state->updateset_from_location($v); $v = $v->name; } else { # resort to default if nothing else $v = $dep->{def}; - $s = OpenBSD::UpdateSet->create_new($v); + $s = $state->updateset_with_new($v); } $s->merge_paths($self->{set}); @@ -674,10 +674,8 @@ sub find_old_lib my ($self, $state, $base, $pattern, $lib) = @_; require OpenBSD::Search; - require OpenBSD::PackageRepository::Installed; - - my $r = OpenBSD::PackageRepository::Installed->new->match_locations(OpenBSD::Search::PkgSpec->new(".libs-".$pattern)); + my $r = $state->repo->installed->match_locations(OpenBSD::Search::PkgSpec->new(".libs-".$pattern)); for my $try (map {$_->name} @$r) { OpenBSD::SharedLibs::add_libs_from_installed_package($try); if ($self->check_lib_spec($base, $lib, {$try => 1})) { diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm index 92864217fce..cf3fef32996 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.89 2010/06/25 10:15:13 espie Exp $ +# $OpenBSD: PackageLocator.pm,v 1.90 2010/06/30 10:37:25 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm index 569cc6274e5..8635ee6aeab 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Installed.pm,v 1.22 2010/05/10 09:17:55 espie Exp $ +# $OpenBSD: Installed.pm,v 1.23 2010/06/30 10:37:26 espie Exp $ # # Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org> # diff --git a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm index 50be034b60b..d49b2190fca 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgAdd.pm,v 1.6 2010/06/30 10:08:00 espie Exp $ +# $OpenBSD: PkgAdd.pm,v 1.7 2010/06/30 10:37:26 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # @@ -440,7 +440,7 @@ sub try_merging my $s = $state->tracker->is_to_update($m); if (!defined $s) { - $s = OpenBSD::UpdateSet->new->add_older( + $s = $state->updateset->add_older( OpenBSD::Handle->create_old($m, $state)); } if ($state->updater->process_set($s, $state)) { @@ -516,7 +516,6 @@ our @ISA = qw(OpenBSD::AddDelete); use OpenBSD::Dependencies; use OpenBSD::PackingList; use OpenBSD::PackageInfo; -use OpenBSD::PackageLocator; use OpenBSD::PackageName; use OpenBSD::PkgCfl; use OpenBSD::Add; @@ -949,12 +948,12 @@ sub inform_user_of_problems # if we already have quirks, we update it. If not, we try to install it. sub quirk_set { - require OpenBSD::PackageRepository::Installed; + my $state = shift; require OpenBSD::Search; - my $set = OpenBSD::UpdateSet->new; + my $set = $state->updateset; $set->{quirks} = 1; - my $l = OpenBSD::PackageRepository::Installed->new->match_locations(OpenBSD::Search::Stem->new('quirks')); + my $l = $state->repo->installed->match_locations(OpenBSD::Search::Stem->new('quirks')); if (@$l > 0) { $set->add_older(map {OpenBSD::Handle->from_location($_)} @$l); } else { @@ -967,7 +966,7 @@ sub do_quirks { my $state = shift; - install_set(quirk_set(), $state); + install_set(quirk_set($state), $state); eval { require OpenBSD::Quirks; # interface version number. @@ -990,19 +989,18 @@ sub process_parameters chomp; s/\s.*//; push(@{$state->{setlist}}, - OpenBSD::UpdateSet->new->$add_hints($_)); + $state->updateset->$add_hints($_)); } } # update existing stuff if ($state->{update}) { - require OpenBSD::PackageRepository::Installed; if (@ARGV == 0) { @ARGV = sort(installed_packages()); $state->{allupdates} = 1; } - my $inst = OpenBSD::PackageRepository::Installed->new; + my $inst = $state->repo->installed; for my $pkgname (@ARGV) { my $l; @@ -1016,7 +1014,7 @@ sub process_parameters $state->say("Problem finding #1", $pkgname); } else { push(@{$state->{setlist}}, - OpenBSD::UpdateSet->new->add_older(OpenBSD::Handle->from_location($l))); + $state->updateset->add_older(OpenBSD::Handle->from_location($l))); } } } else { @@ -1025,7 +1023,7 @@ sub process_parameters for my $pkgname (@ARGV) { next if $pkgname =~ m/^quirks\-\d/; push(@{$state->{setlist}}, - OpenBSD::UpdateSet->new->$add_hints($pkgname)); + $state->updateset->$add_hints($pkgname)); } } } diff --git a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm index f1b6de3ea6f..e726ef891dd 100644 --- a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm +++ b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: UpdateSet.pm,v 1.57 2010/06/25 10:34:03 espie Exp $ +# $OpenBSD: UpdateSet.pm,v 1.58 2010/06/30 10:37:26 espie Exp $ # # Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org> # @@ -64,9 +64,9 @@ package OpenBSD::UpdateSet; sub new { - my $class = shift; - return bless {newer => {}, older => {}, kept => {}, hints => [], updates => 0}, - $class; + my ($class, $state) = @_; + return bless {newer => {}, older => {}, kept => {}, + hints => [], updates => 0, repo => $state->repo}, $class; } sub path @@ -81,9 +81,7 @@ sub add_repositories my ($set, @repos) = @_; if (!defined $set->{path}) { - require OpenBSD::PackageRepositoryList; - - $set->{path} = OpenBSD::PackageRepositoryList->new; + $set->{path} = $set->{repo}->path; } $set->{path}->add(@repos); } @@ -109,8 +107,7 @@ sub match_locations $r = $set->{path}->match_locations(@spec); } if (@$r == 0) { - require OpenBSD::PackageLocator; - $r = OpenBSD::PackageLocator->match_locations(@spec); + $r = $set->{repo}->match_locations(@spec); } return $r; } |