2010-08-20 09:40:13 -04:00
|
|
|
# ex:ts=8 sw=4:
|
2010-10-28 10:54:38 -04:00
|
|
|
# $OpenBSD: Grabber.pm,v 1.5 2010/10/28 14:54:38 espie Exp $
|
2010-08-20 09:40:13 -04:00
|
|
|
#
|
|
|
|
# Copyright (c) 2010 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.
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
|
|
|
|
use DPB::Vars;
|
|
|
|
use DPB::Util;
|
|
|
|
|
|
|
|
package DPB::Grabber;
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my ($class, $ports, $make, $logger, $engine, $dpb, $endcode) = @_;
|
2010-10-27 08:58:26 -04:00
|
|
|
my $o = bless { ports => $ports, make => $make,
|
2010-08-20 09:40:13 -04:00
|
|
|
loglist => DPB::Util->make_hot($logger->open("vars")),
|
2010-10-28 10:54:38 -04:00
|
|
|
logger => $logger,
|
2010-08-20 09:40:13 -04:00
|
|
|
engine => $engine,
|
|
|
|
dpb => $dpb,
|
|
|
|
keep_going => 1,
|
|
|
|
endcode => $endcode
|
|
|
|
}, $class;
|
2010-10-27 08:58:26 -04:00
|
|
|
$engine->{grabber} = $o;
|
|
|
|
return $o;
|
2010-08-20 09:40:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub finish
|
|
|
|
{
|
|
|
|
my ($self, $h) = @_;
|
|
|
|
for my $v (values %$h) {
|
|
|
|
if ($v->{broken}) {
|
|
|
|
delete $v->{info};
|
2010-10-28 06:33:20 -04:00
|
|
|
delete $v->{broken};
|
2010-08-20 09:40:13 -04:00
|
|
|
$self->{engine}->add_fatal($v);
|
|
|
|
} else {
|
|
|
|
$self->{engine}->new_path($v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$self->{keepgoing} = &{$self->{endcode}};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub grab_subdirs
|
|
|
|
{
|
|
|
|
my ($self, $core, $list) = @_;
|
|
|
|
DPB::Vars->grab_list($core, $self->{ports}, $self->{make}, $list,
|
2010-10-28 10:54:38 -04:00
|
|
|
$self->{loglist}, $self->{logger}, $self->{dpb},
|
2010-08-20 09:40:13 -04:00
|
|
|
sub {
|
|
|
|
$self->finish(shift);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub complete_subdirs
|
|
|
|
{
|
|
|
|
my ($self, $core) = @_;
|
|
|
|
# more passes if necessary
|
|
|
|
while ($self->{keep_going}) {
|
|
|
|
my @subdirlist = ();
|
|
|
|
for my $v (DPB::PkgPath->seen) {
|
|
|
|
next if defined $v->{info};
|
|
|
|
if (defined $v->{tried}) {
|
|
|
|
$self->{engine}->add_fatal($v);
|
2010-10-23 14:02:59 -04:00
|
|
|
} else {
|
|
|
|
$v->add_to_subdirlist(\@subdirlist);
|
|
|
|
$v->{tried} = 1;
|
2010-08-20 09:40:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
last if @subdirlist == 0;
|
|
|
|
|
|
|
|
$self->grab_subdirs($core, \@subdirlist);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|