summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2011-06-24 14:36:17 +0000
committerMarc Espie <espie@cvs.openbsd.org>2011-06-24 14:36:17 +0000
commit2da4f243b75a7c0f2e9aa565731e527548ab0770 (patch)
tree4617b2990ec9e331345f012d808708e79b4e9ca6
parent057d19d2ce7e11b152b32a5b255d70c1b862e527 (diff)
speed up dependency checking:
- if the ports tree is -current, do not compute @wantlib during dependencies. - add an extra cache. The solver caches "exact" depends, we can also cache pkgpaths when we go to the ports tree. - make the checking computation progress message less painful by adding the pkgpath currently investigated...
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCreate.pm38
1 files changed, 24 insertions, 14 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
index 4c8b323d3f7..256a6a29dea 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.46 2011/06/20 09:41:46 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.47 2011/06/24 14:36:16 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -581,6 +581,8 @@ sub really_solve_dependency
{
my ($self, $state, $dep, $package) = @_;
+ $state->progress->message($dep->{pkgpath});
+
# look in installed packages
my $v = $self->find_dep_in_installed($state, $dep);
if (!defined $v) {
@@ -594,33 +596,41 @@ sub really_solve_dependency
return $v;
}
+my $cache = {};
sub solve_from_ports
{
my ($self, $state, $dep, $package) = @_;
my $portsdir = $state->defines('PORTSDIR');
return undef unless defined $portsdir;
- my $plist = $self->ask_tree($state, $dep, $portsdir,
- 'print-plist-with-depends');
- if ($? != 0 || !defined $plist->pkgname) {
- $state->error("Can't obtain dependency #1 from ports tree",
- $dep->{pattern});
- return undef;
+ my $pkgname;
+ if (defined $cache->{$dep->{pkgpath}}) {
+ $pkgname = $cache->{$dep->{pkgpath}};
+ } else {
+ my $plist = $self->ask_tree($state, $dep, $portsdir,
+ 'print-plist-with-depends', 'wantlib_args=no-wantlib-args');
+ if ($? != 0 || !defined $plist->pkgname) {
+ $state->error("Can't obtain dependency #1 from ports tree",
+ $dep->{pattern});
+ return undef;
+ }
+ OpenBSD::SharedLibs::add_libs_from_plist($plist, $state);
+ $self->add_dep($plist);
+ $pkgname = $plist->pkgname;
+ $cache->{$dep->{pkgpath}} = $pkgname;
}
- if ($dep->spec->filter($plist->pkgname) == 0) {
+ if ($dep->spec->filter($pkgname) == 0) {
$state->error("Dependency #1 doesn't match FULLPKGNAME: #2",
- $dep->{pattern}, $plist->pkgname);
+ $dep->{pattern}, $pkgname);
return undef;
}
- OpenBSD::SharedLibs::add_libs_from_plist($plist, $state);
- $self->add_dep($plist);
- return $plist->pkgname;
+ return $pkgname;
}
sub ask_tree
{
- my ($self, $state, $dep, $portsdir, $action) = @_;
+ my ($self, $state, $dep, $portsdir, @action) = @_;
my $make = OpenBSD::Paths->make;
my $pid = open(my $fh, "-|");
@@ -632,7 +642,7 @@ sub ask_tree
open STDERR, '>', '/dev/null';
$ENV{SUBDIR} = $dep->{pkgpath};
$ENV{ECHO_MSG} = ':';
- exec $make ('make', $action);
+ exec $make ('make', @action);
}
my $plist = OpenBSD::PackingList->read($fh,
\&OpenBSD::PackingList::PrelinkStuffOnly);