log signature errors

move the logs/locks yet again: those are dpb logs, so they belong in
logs dir (note the s). Use one single option (-L) to move both.
remove old -t mode, use -t/-T for ssh/display timeouts
Change the "mem" option to "parse size file", dependent on show-size.
This commit is contained in:
espie 2010-03-04 13:56:09 +00:00
parent ff14b4c7c3
commit 6ccdda1670
5 changed files with 56 additions and 55 deletions

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Core.pm,v 1.4 2010/03/01 17:59:49 espie Exp $
# $OpenBSD: Core.pm,v 1.5 2010/03/04 13:56:09 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -245,8 +245,8 @@ use DPB::Signature;
sub new
{
my $class = shift;
my $o = bless {name => "init"}, $class;
my ($class, $logger) = @_;
my $o = bless {name => "init", logger => $logger}, $class;
DPB::Signature->add_tasks($o);
return $o;
}
@ -255,7 +255,7 @@ sub new
sub finalize
{
my ($self, $core) = @_;
if ($self->{signature}->matches($core)) {
if ($self->{signature}->matches($core, $self->{logger})) {
for my $i (@{$core->{list}}) {
$i->mark_ready;
}
@ -284,8 +284,9 @@ sub new
sub init_cores
{
my ($self, $logger) = @_;
for my $core (values %$init) {
$core->start_job(DPB::Job::Init->new);
$core->start_job(DPB::Job::Init->new($logger));
}
$inited = 1;
}
@ -411,7 +412,7 @@ sub has_sf
sub parse_hosts_file
{
my ($class, $filename, $arch) = @_;
my ($class, $filename, $arch, $timeout, $logger) = @_;
open my $fh, '<', $filename or die "Can't read host files $filename\n";
my $_;
my $sf;
@ -438,11 +439,14 @@ sub parse_hosts_file
if (defined $prop->{sf} && $prop->{sf} != $sf) {
$has_sf = 1;
}
if (defined $timeout) {
$prop->{timeout} //= $timeout;
}
for my $j (1 .. $prop->{jobs}) {
DPB::Core::Factory->new($host, $prop);
}
}
DPB::Core::Factory->init_cores;
DPB::Core::Factory->init_cores($logger);
}
sub start_pipe

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Distant.pm,v 1.3 2010/03/01 17:59:49 espie Exp $
# $OpenBSD: Distant.pm,v 1.4 2010/03/04 13:56:09 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -34,8 +34,8 @@ sub ssh
sub new
{
my ($class, $host) = @_;
bless {master => DPB::Ssh::Master->find($host)}, $class;
my ($class, $host, $timeout) = @_;
bless {master => DPB::Ssh::Master->find($host, $timeout)}, $class;
}
sub is_alive
@ -145,10 +145,10 @@ sub is_alive
sub create
{
my ($class, $host) = @_;
my ($class, $host, $timeout) = @_;
my $core = $class->SUPER::new($host);
$core->start_job(DPB::Job::SshMaster->new($host));
$core->start_job(DPB::Job::SshMaster->new($host, $timeout));
}
sub find
@ -209,7 +209,7 @@ sub new_noreg
{
my ($class, $host, $prop) = @_;
my $o = $class->SUPER::new_noreg($host, $prop);
$o->{shell} = DPB::Ssh->new($host);
$o->{shell} = DPB::Ssh->new($host, $prop->{timeout});
return $o;
}

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Heuristics.pm,v 1.2 2010/03/01 18:11:11 espie Exp $
# $OpenBSD: Heuristics.pm,v 1.3 2010/03/04 13:56:09 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -25,7 +25,7 @@ package DPB::Heuristics;
# for now, we don't create a separate object, we assume everything here is
# "global"
my (%weight, %needed_by);
my (%weight, %wrkdir, %needed_by);
sub new
{
@ -68,12 +68,18 @@ sub set_threshold
$threshold = $t;
}
sub add_size_info
{
my ($self, $path, $sz) = @_;
$wrkdir{$path} = $sz;
}
sub special_parameters
{
my ($self, $core, $v) = @_;
my $t = $core->{memory} // $threshold;
# we build in memory if we know this port and it's light enough
if (!defined $t || !defined $weight{$v} || $weight{$v} > $t) {
if (!defined $t || !defined $wrkdir{$v} || $wrkdir{$v} > $t) {
return 0;
} else {
return 1;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: PortBuilder.pm,v 1.2 2010/02/26 12:14:57 espie Exp $
# $OpenBSD: PortBuilder.pm,v 1.3 2010/03/04 13:56:09 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -28,8 +28,8 @@ use DPB::Job::Port;
sub new
{
my $class = shift;
my ($opt_c, $fullrepo, $logger, $ports, $make, $h) = @_;
my $self = bless {clean => $opt_c,
my ($opt_c, $opt_s, $fullrepo, $logger, $ports, $make, $h) = @_;
my $self = bless {clean => $opt_c, size => $opt_s,
fullrepo => $fullrepo,
logger => $logger, ports => $ports, make => $make,
heuristics => $h}, $class;
@ -102,27 +102,4 @@ sub build
return $core;
}
package DPB::DummyCore;
sub host
{
return "dummy";
}
my $dummy = bless {}, "DPB::DummyCore";
package DPB::PortBuilder::Test;
our @ISA = qw(DPB::PortBuilder);
sub build
{
my ($self, $v, $core, $lock, $code) = @_;
my $name = $v->fullpkgname;
# my $log = $self->{logger}->make_logs(make_logs($v), $self->{clean});
# open my $out, ">>", $log or die "Can't write to $log";
open my $fh, ">", "$self->{fullrepo}/$name.tgz";
close $fh;
&$code;
return $dummy;
}
1;

View File

@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
# $OpenBSD: dpb3,v 1.5 2010/03/02 18:20:45 espie Exp $
# $OpenBSD: dpb3,v 1.6 2010/03/04 13:56:09 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -49,6 +49,21 @@ our ($opt_t, $opt_e, $opt_T, $opt_c, $opt_h, $opt_A, $opt_j, $opt_a,
$opt_L, $opt_m, $opt_f, $opt_x);
my @subdirlist;
sub parse_size_file
{
my ($fname, @consumers) = @_;
open my $fh, '<', $fname or die "Couldn't open build file $fname\n";
my $_;
while (<$fh>) {
chomp;
my ($pkgpath, $sz) = split(/\s+/, $_);
my $o = DPB::PkgPath->new_hidden($pkgpath);
for my $c (@consumers) {
$c->add_size_info($o, $sz);
}
}
}
sub parse_build_line
{
return split(/\s+/, shift);
@ -72,10 +87,10 @@ sub parse_build_file
my $parsed = 0;
my $heuristics = DPB::Heuristics->new;
set_usage("dpb3 [-acerstx] [-A arch] [-j N] [-P plist] [-h hosts] [-L lockdir] [-b log] ",
"[-T timeout] [-m threshold] [path ...]");
set_usage("dpb3 [-acersx] [-A arch] [-j N] [-P plist] [-h hosts] [-L logdir] [-b log] ",
"[-t ctimeout] [-T dtimeout] [-m threshold] [path ...]");
try {
getopts('acersh:txA:f:j:m:P:b:L:T:', {
getopts('acersh:xA:f:j:m:P:b:L:S:t:T:', {
P => sub {
my $file = shift;
open my $fh, '<', $file or die "Can't open $file\n";
@ -90,7 +105,9 @@ getopts('acersh:txA:f:j:m:P:b:L:T:', {
parse_build_file(shift, $heuristics, "DPB::Job::Port");
$parsed = 1;
},
S => sub {
parse_size_file(shift, $heuristics);
}
}
);
} catchall {
@ -130,8 +147,8 @@ my ($ports, $repo, $localarch, $distdir) = DPB::Vars->get($make,
my $arch = $opt_A // $localarch;
$opt_A //= '';
my $logdir = $ENV{LOGDIR} || "$ports/log/$opt_A";
my $lockdir = $opt_L // "$ports/locks/$opt_A";
my $logdir = $opt_L // $ENV{LOGDIR} // "$ports/logs/$opt_A";
my $lockdir = "$logdir/locks";
my $logger = DPB::Logger->new($logdir, $opt_c);
$heuristics->set_logger($logger);
@ -144,12 +161,9 @@ if (defined $opt_j && $opt_j !~ m/^\d+$/) {
Usage("-j takes a numerical argument");
}
my $fullrepo = $opt_t ? "$repo/$arch/test" : "$repo/$arch/all";
if ($opt_t) {
$logdir = "$logdir/test";
}
my $fullrepo = "$repo/$arch/all";
if ($opt_h) {
DPB::Core->parse_hosts_file($opt_h, $arch);
DPB::Core->parse_hosts_file($opt_h, $arch, $opt_t, $logger);
} else {
$opt_j //= `sysctl -n hw.ncpu`;
chomp($opt_j);
@ -160,7 +174,7 @@ for (1 .. $opt_j) {
DPB::Core::Factory->new('localhost');
}
my $builder = ($opt_t ? "DPB::PortBuilder::Test" : "DPB::PortBuilder")->new(
my $builder = DPB::PortBuilder->new(
$opt_c, $opt_s, $fullrepo, $logger, $ports, $make, $heuristics);
my $locker = DPB::Locks->new($lockdir);