diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-18 13:22:07 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-18 13:22:07 +0000 |
commit | 13af28e3fd307655a2270831d7a1ee6582df287b (patch) | |
tree | e2a5365841ed1d7b0b3e5055d92444cd42b1cbdc | |
parent | 46e52f3305af8bd3447d2f5c6977ce5e3ba73de8 (diff) |
Add pkgpath hints to pkgspec. Make PackageRepository/Source functional:
if a pkgpath is hinted at, then we build that package, and we delegate
to the corresponding File: repository.
Some XXX: we need to unlock the database temporarily, as the build
*requires* shared access to stuff that is going on (and possibly write
access for installing subpackages, so this cannot work 100% yet).
Still, this allows the transparent build of one single package, at least.
-rw-r--r-- | usr.sbin/pkg_add/Makefile | 3 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm | 44 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 3 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Search.pm | 8 |
5 files changed, 48 insertions, 14 deletions
diff --git a/usr.sbin/pkg_add/Makefile b/usr.sbin/pkg_add/Makefile index ffc04df6bbf..562dfb2aed5 100644 --- a/usr.sbin/pkg_add/Makefile +++ b/usr.sbin/pkg_add/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.43 2007/05/14 13:15:28 espie Exp $ +# $OpenBSD: Makefile,v 1.44 2007/05/18 13:22:06 espie Exp $ .include <bsd.own.mk> @@ -27,6 +27,7 @@ PACKAGES= \ OpenBSD/PackageRepository.pm \ OpenBSD/PackageRepository/Installed.pm \ OpenBSD/PackageRepository/SCP.pm \ + OpenBSD/PackageRepository/Source.pm \ OpenBSD/PackageRepositoryList.pm \ OpenBSD/PackingElement.pm \ OpenBSD/PackingList.pm \ diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index b2c7b7dd7fe..64a98a071b8 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.36 2007/05/17 18:59:38 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.37 2007/05/18 13:22:06 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -49,7 +49,7 @@ sub new } elsif ($baseurl =~ m/^src\:/i) { require OpenBSD::PackageRepository::Source; - return OpenBSD::PackageRepository::Source->_new($baseurl); + return OpenBSD::PackageRepository::Source->_new($'); } elsif ($baseurl =~ m/^file\:/i) { return OpenBSD::PackageRepository::Local->_new($'); } elsif ($baseurl =~ m/^inst\:/i) { 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; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 1a5a52ac7b0..4f8443f1e1f 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.110 2007/05/17 15:46:27 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.111 2007/05/18 13:22:06 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -692,6 +692,7 @@ sub spec if (!defined $self->{spec}) { require OpenBSD::Search; $self->{spec} = OpenBSD::Search::PkgSpec->new($self->{pattern}); + $self->{spec}->add_pkgpath_hint($self->{pkgpath}); } return $self->{spec}; } diff --git a/usr.sbin/pkg_add/OpenBSD/Search.pm b/usr.sbin/pkg_add/OpenBSD/Search.pm index 10060e2a21a..05121af0eeb 100644 --- a/usr.sbin/pkg_add/OpenBSD/Search.pm +++ b/usr.sbin/pkg_add/OpenBSD/Search.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Search.pm,v 1.3 2007/05/14 11:31:10 espie Exp $ +# $OpenBSD: Search.pm,v 1.4 2007/05/18 13:22:06 espie Exp $ # # Copyright (c) 2007 Marc Espie <espie@openbsd.org> # @@ -51,6 +51,12 @@ sub new bless { patterns => \@l }, $class; } +sub add_pkgpath_hint +{ + my ($self, $pkgpath) = @_; + $self->{pkgpath} = $pkgpath; +} + package OpenBSD::Search::Stem; our @ISA=(qw(OpenBSD::Search)); |