diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-14 10:53:32 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-14 10:53:32 +0000 |
commit | 1f94b8d9a850dbb366ebbd30c37f8e1446017987 (patch) | |
tree | 35cce9bc8f1299f6ff45bf2a374669c415c8071a /usr.sbin/pkg_add/OpenBSD | |
parent | b625ec4ca173b166b6eed5bafd2aa02064886be0 (diff) |
put search objects into a search class.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Dependencies.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageInfo.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageName.pm | 39 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgCfl.pm | 10 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgSpec.pm | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Update.pm | 4 |
7 files changed, 35 insertions, 38 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm index 46cf895a348..895b66db2aa 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.24 2007/05/14 10:43:45 espie Exp $ +# $OpenBSD: Dependencies.pm,v 1.25 2007/05/14 10:53:31 espie Exp $ # # Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org> # @@ -136,7 +136,7 @@ sub find_old_lib { my ($state, $base, $pattern, $lib, $dependencies) = @_; - my $spec = OpenBSD::PkgSpec->new(".libs-".$pattern); + my $spec = OpenBSD::Search::PkgSpec->new(".libs-".$pattern); require OpenBSD::PackageRepository::Installed; for my $try (OpenBSD::PackageRepository::Installed->new->match($spec)) { diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm index acdd0dd9d87..e2a52641331 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageInfo.pm,v 1.26 2007/05/14 10:00:08 espie Exp $ +# $OpenBSD: PackageInfo.pm,v 1.27 2007/05/14 10:53:31 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -209,7 +209,7 @@ sub solve_installed_names if (OpenBSD::PackageName::is_stem($pkgname)) { require OpenBSD::PackageRepository; - my @l = OpenBSD::PackageRepository::Installed->new->match(OpenBSD::PackageName::Stem->new($pkgname)); + my @l = OpenBSD::PackageRepository::Installed->new->match(OpenBSD::Search::Stem->new($pkgname)); if (@l == 0) { print "Can't resolve $pkgname to an installed package name\n"; $bad = 1; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageName.pm b/usr.sbin/pkg_add/OpenBSD/PackageName.pm index 1ceabd06aab..085d1026997 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageName.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageName.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageName.pm,v 1.24 2007/05/14 10:43:45 espie Exp $ +# $OpenBSD: PackageName.pm,v 1.25 2007/05/14 10:53:31 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -308,6 +308,20 @@ sub to_pattern return $o->{stem}.'-*'; } +package OpenBSD::PackageName::Name; +sub to_string +{ + my $o = shift; + return join('-', $o->{stem}, $o->{version}->to_string, @{$o->{flavors}}); +} + +sub to_pattern +{ + my $o = shift; + return join('-', $o->{stem}, '*', @{$o->{flavors}}); +} + +package OpenBSD::Search::Stem; sub new { my ($class, $stem) = @_; @@ -327,14 +341,8 @@ sub match return $o->stemlist->find($self->{stem}); } -package OpenBSD::PackageName::PartialStem; -our @ISA=(qw(OpenBSD::PackageName::Stem)); - -sub to_pattern -{ - my $o = shift; - return '*.'.$o->{stem}.'*-*'; -} +package OpenBSD::Search::PartialStem; +our @ISA=(qw(OpenBSD::Search::Stem)); sub match { @@ -342,17 +350,4 @@ sub match return $o->stemlist->find_partial($self->{stem}); } -package OpenBSD::PackageName::Name; -sub to_string -{ - my $o = shift; - return join('-', $o->{stem}, $o->{version}->to_string, @{$o->{flavors}}); -} - -sub to_pattern -{ - my $o = shift; - return join('-', $o->{stem}, '*', @{$o->{flavors}}); -} - 1; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 679d83857ea..47871a7580d 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.107 2007/05/14 10:43:45 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.108 2007/05/14 10:53:31 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -691,7 +691,7 @@ sub spec my $self = shift; if (!defined $self->{spec}) { require OpenBSD::PkgSpec; - $self->{spec} = OpenBSD::PkgSpec->new($self->{pattern}); + $self->{spec} = OpenBSD::Search::PkgSpec->new($self->{pattern}); } return $self->{spec}; } @@ -743,7 +743,7 @@ sub add require OpenBSD::PackageRepository::Installed; my @candidates = OpenBSD::PackageRepository::Installed->new - ->match(OpenBSD::PkgSpec->new($args)); + ->match(OpenBSD::Search::PkgSpec->new($args)); if (@candidates == 1) { if (!defined $installed_modules->{$candidates[0]}) { # pull in the module right here and now; diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm b/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm index af63362c251..29f90927fb3 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgCfl.pm,v 1.19 2007/05/14 10:43:45 espie Exp $ +# $OpenBSD: PkgCfl.pm,v 1.20 2007/05/14 10:53:31 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # @@ -35,15 +35,15 @@ sub make_conflict_list my $stem = OpenBSD::PackageName::splitstem($pkgname); unless (defined $plist->{'no-default-conflict'}) { - push(@$l, OpenBSD::PkgSpec->new("$stem-*|partial-$stem-*")); + push(@$l, OpenBSD::Search::PkgSpec->new("$stem-*|partial-$stem-*")); } else { $pkgname =~ s/p\d+$//; - push(@$l, OpenBSD::PkgSpec->new("$pkgname|partial-$pkgname")); + push(@$l, OpenBSD::Search::PkgSpec->new("$pkgname|partial-$pkgname")); } - push(@$l, OpenBSD::PkgSpec->new(".libs-$stem-*")); + push(@$l, OpenBSD::Search::PkgSpec->new(".libs-$stem-*")); if (defined $plist->{conflict}) { for my $cfl (@{$plist->{conflict}}) { - push(@$l, OpenBSD::PkgSpec->new($cfl->{name})); + push(@$l, OpenBSD::Search::PkgSpec->new($cfl->{name})); } } bless $l, $class; diff --git a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm index 2b4cd2badc1..7850f1a6f7e 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgSpec.pm,v 1.10 2007/05/14 10:43:45 espie Exp $ +# $OpenBSD: PkgSpec.pm,v 1.11 2007/05/14 10:53:31 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # @@ -206,13 +206,15 @@ sub subpattern_match return @result; } +package OpenBSD::Search::PkgSpec; + sub match_ref { my ($self, $r) = @_; my @l = (); for my $subpattern (@{$self->{patterns}}) { - push(@l, subpattern_match($subpattern, $r)); + push(@l, OpenBSD::PkgSpec::subpattern_match($subpattern, $r)); } return @l; } diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index 5c3fc71d5bc..b9da98c7916 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.75 2007/05/14 09:29:07 espie Exp $ +# $OpenBSD: Update.pm,v 1.76 2007/05/14 10:53:31 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -63,7 +63,7 @@ sub process_package print "Not updating $pkgname, remember to clean it\n"; return; } - my $stem = OpenBSD::PackageName::Stem->split($pkgname); + my $stem = OpenBSD::Search::Stem->split($pkgname); my $found; my $plist; |