2010-08-20 09:40:13 -04:00
|
|
|
# ex:ts=8 sw=4:
|
2012-01-30 10:11:04 -05:00
|
|
|
# $OpenBSD: Grabber.pm,v 1.24 2012/01/30 15:11:04 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
|
|
|
|
{
|
2011-05-22 04:21:38 -04:00
|
|
|
my ($class, $state, $endcode) = @_;
|
2011-04-25 07:58:46 -04:00
|
|
|
|
2011-12-04 07:05:41 -05:00
|
|
|
my $o = bless {
|
2011-04-25 07:58:46 -04:00
|
|
|
loglist => DPB::Util->make_hot($state->logger->open("vars")),
|
2011-05-22 04:21:38 -04:00
|
|
|
engine => $state->engine,
|
|
|
|
state => $state,
|
2010-08-20 09:40:13 -04:00
|
|
|
keep_going => 1,
|
2012-01-08 15:28:37 -05:00
|
|
|
errors => 0,
|
2010-08-20 09:40:13 -04:00
|
|
|
endcode => $endcode
|
|
|
|
}, $class;
|
2012-01-30 10:11:04 -05:00
|
|
|
if ($state->{want_fetchinfo}) {
|
2011-05-22 04:21:38 -04:00
|
|
|
require DPB::Fetch;
|
|
|
|
$o->{dpb} = "fetch";
|
2011-12-31 06:20:00 -05:00
|
|
|
$o->{fetch} = DPB::Fetch->new($state->distdir, $state->logger,
|
2012-01-14 07:26:21 -05:00
|
|
|
$state);
|
2011-05-22 04:21:38 -04:00
|
|
|
} else {
|
|
|
|
$o->{dpb} = "normal";
|
|
|
|
$o->{fetch} = DPB::FetchDummy->new;
|
|
|
|
}
|
2010-10-27 08:58:26 -04:00
|
|
|
return $o;
|
2010-08-20 09:40:13 -04:00
|
|
|
}
|
|
|
|
|
2012-01-08 15:28:37 -05:00
|
|
|
sub expire_old_distfiles
|
|
|
|
{
|
2012-01-09 12:56:28 -05:00
|
|
|
my ($self, $core, $opt_e) = @_;
|
2012-01-08 15:28:37 -05:00
|
|
|
# don't bother if dump-vars wasn't perfectly clean
|
2012-01-09 12:56:28 -05:00
|
|
|
return 0 if $self->{errors};
|
2012-01-18 10:26:49 -05:00
|
|
|
return $self->{fetch}->run_expire_old($core, $opt_e);
|
2012-01-08 15:28:37 -05:00
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
sub finish
|
|
|
|
{
|
|
|
|
my ($self, $h) = @_;
|
|
|
|
for my $v (values %$h) {
|
|
|
|
if ($v->{broken}) {
|
|
|
|
delete $v->{info};
|
2011-11-06 07:23:28 -05:00
|
|
|
$self->{engine}->add_fatal($v, $v->{broken});
|
2010-10-28 06:33:20 -04:00
|
|
|
delete $v->{broken};
|
2011-10-10 14:56:50 -04:00
|
|
|
} elsif ($v->{wantbuild}) {
|
|
|
|
delete $v->{wantbuild};
|
2010-08-20 09:40:13 -04:00
|
|
|
$self->{engine}->new_path($v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$self->{keepgoing} = &{$self->{endcode}};
|
|
|
|
}
|
|
|
|
|
2010-10-30 06:35:09 -04:00
|
|
|
sub ports
|
|
|
|
{
|
|
|
|
my $self = shift;
|
2011-12-04 07:05:41 -05:00
|
|
|
return $self->{state}->ports;
|
2010-10-30 06:35:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub make
|
|
|
|
{
|
|
|
|
my $self = shift;
|
2011-12-04 07:05:41 -05:00
|
|
|
return $self->{state}->make;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub make_args
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{state}->make_args;
|
2010-10-30 06:35:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub logger
|
|
|
|
{
|
|
|
|
my $self = shift;
|
2011-12-04 07:05:41 -05:00
|
|
|
return $self->{state}->logger;
|
2010-10-30 06:35:09 -04:00
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
sub grab_subdirs
|
|
|
|
{
|
|
|
|
my ($self, $core, $list) = @_;
|
2010-10-30 06:35:09 -04:00
|
|
|
DPB::Vars->grab_list($core, $self, $list,
|
|
|
|
$self->{loglist}, $self->{dpb},
|
2010-08-20 09:40:13 -04:00
|
|
|
sub {
|
2011-10-10 14:56:50 -04:00
|
|
|
my $h = shift;
|
|
|
|
for my $v (values %$h) {
|
|
|
|
$v->{wantbuild} = 1;
|
|
|
|
}
|
|
|
|
$self->finish($h);
|
2010-08-20 09:40:13 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-10-30 06:35:09 -04:00
|
|
|
sub grab_signature
|
|
|
|
{
|
|
|
|
my ($self, $core, $pkgpath) = @_;
|
2010-10-30 07:19:38 -04:00
|
|
|
return DPB::PortSignature->grab_signature($core, $self, $pkgpath);
|
2010-10-30 06:35:09 -04:00
|
|
|
}
|
2010-08-20 09:40:13 -04:00
|
|
|
|
2010-11-02 16:32:59 -04:00
|
|
|
sub clean_packages
|
2010-10-30 07:36:07 -04:00
|
|
|
{
|
|
|
|
my ($self, $core, $pkgpath) = @_;
|
2010-11-02 16:32:59 -04:00
|
|
|
return DPB::CleanPackages->clean($core, $self, $pkgpath);
|
2010-10-30 07:36:07 -04:00
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
sub complete_subdirs
|
|
|
|
{
|
|
|
|
my ($self, $core) = @_;
|
|
|
|
# more passes if necessary
|
|
|
|
while ($self->{keep_going}) {
|
2011-10-10 14:56:50 -04:00
|
|
|
my $subdirlist = {};
|
2010-08-20 09:40:13 -04:00
|
|
|
for my $v (DPB::PkgPath->seen) {
|
2011-10-10 14:56:50 -04:00
|
|
|
if (defined $v->{info}) {
|
2011-11-07 08:21:46 -05:00
|
|
|
delete $v->{tried};
|
|
|
|
delete $v->{wantinfo};
|
2011-10-10 14:56:50 -04:00
|
|
|
if (defined $v->{wantbuild}) {
|
|
|
|
delete $v->{wantbuild};
|
|
|
|
$self->{engine}->new_path($v);
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
2010-12-05 05:06:12 -05:00
|
|
|
next if defined $v->{category};
|
2010-08-20 09:40:13 -04:00
|
|
|
if (defined $v->{tried}) {
|
2011-11-06 07:23:28 -05:00
|
|
|
$self->{engine}->add_fatal($v, "tried and didn't get it")
|
2011-09-25 06:40:25 -04:00
|
|
|
if !defined $v->{errored};
|
|
|
|
$v->{errored} = 1;
|
2012-01-08 15:28:37 -05:00
|
|
|
$self->{errors}++;
|
2011-10-10 14:56:50 -04:00
|
|
|
} elsif ($v->{wantinfo} || $v->{wantbuild}) {
|
|
|
|
$v->add_to_subdirlist($subdirlist);
|
2010-10-23 14:02:59 -04:00
|
|
|
$v->{tried} = 1;
|
2010-08-20 09:40:13 -04:00
|
|
|
}
|
|
|
|
}
|
2011-10-10 14:56:50 -04:00
|
|
|
last if (keys %$subdirlist) == 0;
|
2010-08-20 09:40:13 -04:00
|
|
|
|
2011-10-10 14:56:50 -04:00
|
|
|
DPB::Vars->grab_list($core, $self, $subdirlist,
|
|
|
|
$self->{loglist}, $self->{dpb},
|
|
|
|
sub {
|
|
|
|
$self->finish(shift);
|
|
|
|
});
|
2010-08-20 09:40:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-22 04:21:38 -04:00
|
|
|
package DPB::FetchDummy;
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift;
|
|
|
|
bless {}, $class;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub build_distinfo
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-18 10:26:49 -05:00
|
|
|
sub run_expire_old
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
1;
|