summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-14 11:02:16 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-14 11:02:16 +0000
commit720febe1bcd1646d4cd6850bd15b98c0df0a1324 (patch)
treeed68b21b01ec100e1c5bfad9683892533b68a9ca /usr.sbin
parent1f94b8d9a850dbb366ebbd30c37f8e1446017987 (diff)
put Search objects into their own file, finally
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/Makefile3
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm6
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageName.pm31
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm6
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCfl.pm4
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgSpec.pm36
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Search.pm88
-rw-r--r--usr.sbin/pkg_add/pkg4
-rw-r--r--usr.sbin/pkg_add/pkg_add4
-rw-r--r--usr.sbin/pkg_add/pkg_info5
10 files changed, 108 insertions, 79 deletions
diff --git a/usr.sbin/pkg_add/Makefile b/usr.sbin/pkg_add/Makefile
index 6f958be256d..351ba5087eb 100644
--- a/usr.sbin/pkg_add/Makefile
+++ b/usr.sbin/pkg_add/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.41 2007/05/14 10:12:24 espie Exp $
+# $OpenBSD: Makefile,v 1.42 2007/05/14 11:02:14 espie Exp $
.include <bsd.own.mk>
@@ -36,6 +36,7 @@ PACKAGES= \
OpenBSD/ProgressMeter.pm \
OpenBSD/Replace.pm \
OpenBSD/RequiredBy.pm \
+ OpenBSD/Search.pm \
OpenBSD/SharedItems.pm \
OpenBSD/SharedLibs.pm \
OpenBSD/Temp.pm \
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 895b66db2aa..5b9ff23a887 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.25 2007/05/14 10:53:31 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.26 2007/05/14 11:02:14 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -136,10 +136,10 @@ sub find_old_lib
{
my ($state, $base, $pattern, $lib, $dependencies) = @_;
- my $spec = OpenBSD::Search::PkgSpec->new(".libs-".$pattern);
+ require OpenBSD::Search;
require OpenBSD::PackageRepository::Installed;
- for my $try (OpenBSD::PackageRepository::Installed->new->match($spec)) {
+ for my $try (OpenBSD::PackageRepository::Installed->new->match(OpenBSD::Search::PkgSpec->new(".libs-".$pattern))) {
OpenBSD::SharedLibs::add_package_libs($try);
if (check_lib_spec($base, $lib, {$try => 1})) {
$dependencies->{$try} = 1;
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageName.pm b/usr.sbin/pkg_add/OpenBSD/PackageName.pm
index 085d1026997..76da6462f3d 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.25 2007/05/14 10:53:31 espie Exp $
+# $OpenBSD: PackageName.pm,v 1.26 2007/05/14 11:02:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -321,33 +321,4 @@ sub to_pattern
return join('-', $o->{stem}, '*', @{$o->{flavors}});
}
-package OpenBSD::Search::Stem;
-sub new
-{
- my ($class, $stem) = @_;
-
- return bless {stem => $stem}, $class;
-}
-
-sub split
-{
- my ($class, $pkgname) = @_;
- return $class->new(OpenBSD::PackageName::splitstem($pkgname));
-}
-
-sub match
-{
- my ($self, $o) = @_;
- return $o->stemlist->find($self->{stem});
-}
-
-package OpenBSD::Search::PartialStem;
-our @ISA=(qw(OpenBSD::Search::Stem));
-
-sub match
-{
- my ($self, $o) = @_;
- return $o->stemlist->find_partial($self->{stem});
-}
-
1;
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index 47871a7580d..799973b662c 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.108 2007/05/14 10:53:31 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.109 2007/05/14 11:02:15 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -690,7 +690,7 @@ sub spec
{
my $self = shift;
if (!defined $self->{spec}) {
- require OpenBSD::PkgSpec;
+ require OpenBSD::Search;
$self->{spec} = OpenBSD::Search::PkgSpec->new($self->{pattern});
}
return $self->{spec};
@@ -739,7 +739,7 @@ sub add
{
my ($class, $plist, $args) = @_;
- require OpenBSD::PkgSpec;
+ require OpenBSD::Search;
require OpenBSD::PackageRepository::Installed;
my @candidates = OpenBSD::PackageRepository::Installed->new
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm b/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm
index 29f90927fb3..5830dbdc4e8 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.20 2007/05/14 10:53:31 espie Exp $
+# $OpenBSD: PkgCfl.pm,v 1.21 2007/05/14 11:02:15 espie Exp $
#
# Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org>
#
@@ -20,7 +20,7 @@ use warnings;
package OpenBSD::PkgCfl;
use OpenBSD::PackageName;
-use OpenBSD::PkgSpec;
+use OpenBSD::Search;
use OpenBSD::PackageInfo;
sub make_conflict_list
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm
index 7850f1a6f7e..08ef81afbf6 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm
@@ -1,7 +1,7 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PkgSpec.pm,v 1.11 2007/05/14 10:53:31 espie Exp $
+# $OpenBSD: PkgSpec.pm,v 1.12 2007/05/14 11:02:15 espie Exp $
#
-# Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org>
+# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -206,36 +206,4 @@ sub subpattern_match
return @result;
}
-package OpenBSD::Search::PkgSpec;
-
-sub match_ref
-{
- my ($self, $r) = @_;
- my @l = ();
-
- for my $subpattern (@{$self->{patterns}}) {
- push(@l, OpenBSD::PkgSpec::subpattern_match($subpattern, $r));
- }
- return @l;
-}
-
-sub match
-{
- my ($self, $o) = @_;
- return $self->match_ref($o->list);
-}
-
-sub match_list
-{
- my ($self, @list) = @_;
- return $self->match_ref(\@list);
-}
-
-sub new
-{
- my ($class, $pattern) = @_;
- my @l = split /\|/, $pattern;
- bless { patterns => \@l }, $class;
-}
-
1;
diff --git a/usr.sbin/pkg_add/OpenBSD/Search.pm b/usr.sbin/pkg_add/OpenBSD/Search.pm
new file mode 100644
index 00000000000..bfc336d9af0
--- /dev/null
+++ b/usr.sbin/pkg_add/OpenBSD/Search.pm
@@ -0,0 +1,88 @@
+# ex:ts=8 sw=4:
+# $OpenBSD: Search.pm,v 1.1 2007/05/14 11:02:15 espie Exp $
+#
+# Copyright (c) 2007 Marc Espie <espie@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+package OpenBSD::Search;
+
+package OpenBSD::Search::PkgSpec;
+our @ISA=(qw(OpenBSD::Search));
+
+sub match_ref
+{
+ my ($self, $r) = @_;
+ my @l = ();
+
+ for my $subpattern (@{$self->{patterns}}) {
+ require OpenBSD::PkgSpec;
+ push(@l, OpenBSD::PkgSpec::subpattern_match($subpattern, $r));
+ }
+ return @l;
+}
+
+sub match
+{
+ my ($self, $o) = @_;
+ return $self->match_ref($o->list);
+}
+
+sub match_list
+{
+ my ($self, @list) = @_;
+ return $self->match_ref(\@list);
+}
+
+sub new
+{
+ my ($class, $pattern) = @_;
+ my @l = split /\|/, $pattern;
+ bless { patterns => \@l }, $class;
+}
+
+package OpenBSD::Search::Stem;
+our @ISA=(qw(OpenBSD::Search));
+
+sub new
+{
+ my ($class, $stem) = @_;
+
+ return bless {stem => $stem}, $class;
+}
+
+sub split
+{
+ my ($class, $pkgname) = @_;
+ require OpenBSD::PackageName;
+
+ return $class->new(OpenBSD::PackageName::splitstem($pkgname));
+}
+
+sub match
+{
+ my ($self, $o) = @_;
+ return $o->stemlist->find($self->{stem});
+}
+
+package OpenBSD::Search::PartialStem;
+our @ISA=(qw(OpenBSD::Search::Stem));
+
+sub match
+{
+ my ($self, $o) = @_;
+ return $o->stemlist->find_partial($self->{stem});
+}
+
+
+1;
diff --git a/usr.sbin/pkg_add/pkg b/usr.sbin/pkg_add/pkg
index be672d124ae..74efca62cf1 100644
--- a/usr.sbin/pkg_add/pkg
+++ b/usr.sbin/pkg_add/pkg
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg,v 1.7 2007/05/14 10:53:31 espie Exp $
+# $OpenBSD: pkg,v 1.8 2007/05/14 11:02:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -22,7 +22,7 @@ use Getopt::Std;
sub check_dependencies($)
{
- require OpenBSD::PkgSpec;
+ require OpenBSD::Search;
require OpenBSD::PackageRepository::Installed;
my $dependency = shift;
my @m = OpenBSD::PackageRepository::Installed->new
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 2ccf7e463c7..801eda22705 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.243 2007/05/14 10:53:31 espie Exp $
+# $OpenBSD: pkg_add,v 1.244 2007/05/14 11:02:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -26,7 +26,6 @@ use OpenBSD::PackageInfo;
use OpenBSD::PackageLocator;
use OpenBSD::PackageName;
use OpenBSD::PkgCfl;
-use OpenBSD::PkgSpec;
use OpenBSD::Vstat;
use OpenBSD::Getopt;
use OpenBSD::Error;
@@ -331,6 +330,7 @@ sub really_add($$)
for my $op (@toreplace) {
OpenBSD::ProgressMeter::set_header($op->pkgname." (deleting)");
$state->set_pkgname($op->pkgname);
+ require OpenBSD::Search;
if (OpenBSD::Search::PkgSpec->new("mozilla-thunderbird-<=1.0.2p0")->match_list($op->pkgname)) {
thunderbird_special_case($plist);
}
diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info
index 7f8ed3d7ae1..a357523d01a 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.53 2007/05/14 10:53:31 espie Exp $
+# $OpenBSD: pkg_info,v 1.54 2007/05/14 11:02:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -139,7 +139,7 @@ sub find_by_spec
{
my $pat = shift;
- require OpenBSD::PkgSpec;
+ require OpenBSD::Search;
require OpenBSD::PackageRepository::Installed;
return sort(OpenBSD::PackageRepository::Installed->new->match(OpenBSD::Search::PkgSpec->new($pat)));
@@ -368,6 +368,7 @@ unless ($opt_c || $opt_M || $opt_U || $opt_d || $opt_f || $opt_I || $opt_i ||
if ($opt_Q) {
require OpenBSD::PackageLocator;
+ require OpenBSD::Search;
print "PKG_PATH=$ENV{PKG_PATH}\n" if $opt_v;
my $partial = OpenBSD::Search::PartialStem->new($opt_Q);