summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm44
1 files changed, 35 insertions, 9 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm
index 500d3b18126..332d91e8850 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Source.pm,v 1.3 2007/05/17 18:17:20 espie Exp $
+# $OpenBSD: Source.pm,v 1.4 2007/05/18 13:22:06 espie Exp $
#
# Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org>
#
@@ -18,16 +18,25 @@
use strict;
use warnings;
-package PackageRepository::Source;
+package OpenBSD::PackageRepository::Source;
+our @ISA=(qw(OpenBSD::PackageRepository));
+use OpenBSD::PackageInfo;
sub urlscheme
{
return 'src';
}
-sub find
+sub _new
{
- my ($repository, $name, $arch, $srcpath) = @_;
+ my ($class, $baseurl) = @_;
+ bless { baseurl => $baseurl }, $class;
+}
+
+sub build_package
+{
+ my ($self, $pkgpath) = @_;
+
my $dir;
my $make;
if (defined $ENV{'MAKE'}) {
@@ -35,18 +44,21 @@ sub find
} else {
$make = '/usr/bin/make';
}
- if (defined $repository->{baseurl} && $repository->{baseurl} ne '') {
- $dir = $repository->{baseurl}
+ if (defined $self->{baseurl} && $self->{baseurl} ne '') {
+ $dir = $self->{baseurl}
} elsif (defined $ENV{PORTSDIR}) {
$dir = $ENV{PORTSDIR};
} else {
$dir = '/usr/ports';
}
# figure out the repository name and the pkgname
- my $pkgfile = `cd $dir && SUBDIR=$srcpath ECHO_MSG=: $make show=PKGFILE`;
+ my $pkgfile = `cd $dir && SUBDIR=$pkgpath ECHO_MSG=: $make show=PKGFILE`;
chomp $pkgfile;
if (! -f $pkgfile) {
- system "cd $dir && SUBDIR=$srcpath $make package BULK=Yes";
+ # XXX
+ unlock_db();
+ system "cd $dir && SUBDIR=$pkgpath $make package BULK=Yes";
+ lock_db(0);
}
if (! -f $pkgfile) {
return undef;
@@ -55,7 +67,21 @@ sub find
my ($base, $fname) = ($1, $2);
my $repo = OpenBSD::PackageRepository::Local->_new($base);
- return $repo->find($fname);
+ return $repo;
+}
+
+sub match
+{
+ my ($self, $search, @filters) = @_;
+ my $built;
+
+ if (defined $search->{pkgpath}) {
+ $built = $self->build_package($search->{pkgpath});
+ }
+ if ($built) {
+ return $built->match($search, @filters);
+ }
+ return ();
}
1;