diff --git a/infrastructure/lib/DPB/HostProperties.pm b/infrastructure/lib/DPB/HostProperties.pm index 8cb90f6258f..60faf68c0ca 100644 --- a/infrastructure/lib/DPB/HostProperties.pm +++ b/infrastructure/lib/DPB/HostProperties.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: HostProperties.pm,v 1.13 2015/06/23 09:01:56 espie Exp $ +# $OpenBSD: HostProperties.pm,v 1.14 2015/07/02 08:04:22 espie Exp $ # # Copyright (c) 2010-2013 Marc Espie # @@ -120,7 +120,7 @@ sub taint return; } my $t1 = $self->{tainted}; - if (!defined $t1 || $v->{forcejunk}) { + if (!defined $t1) { $self->{tainted} = $t2; $self->{tainted_source} = $v->fullpkgpath; return; diff --git a/infrastructure/lib/DPB/Job/Port.pm b/infrastructure/lib/DPB/Job/Port.pm index 2339bb414b8..efdec21ce40 100644 --- a/infrastructure/lib/DPB/Job/Port.pm +++ b/infrastructure/lib/DPB/Job/Port.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Port.pm,v 1.165 2015/06/23 09:01:56 espie Exp $ +# $OpenBSD: Port.pm,v 1.166 2015/07/02 08:04:22 espie Exp $ # # Copyright (c) 2010-2013 Marc Espie # @@ -27,7 +27,7 @@ sub want # job is normally attached to core, unless it's not attached, # and then we pass it as an extra parameter $job //= $core->job; - return 2 if $job->{v}{forcejunk}; + return 2 if $job->{v}->forcejunk; # XXX let's wipe the slates at the start of the first tagged # job, as we don't know the exact state of the host. return 2 if $job->{v}{info}->has_property('tag') && @@ -347,7 +347,7 @@ sub finalize my $task = $job->{tasks}[0]; # XXX if we didn't lock at the entrance, we locked here. $job->{locked} = 1; - if ($core->{status} != 0 || defined $task && !$task->is_serialized) { + if ($core->{status} != 0 || !defined $task || !$task->is_serialized) { $self->junk_unlock($core); } $self->SUPER::finalize($core); @@ -1118,6 +1118,21 @@ sub new return $job; } +sub new_junk_only +{ + my $class = shift; + my ($log, $fh, $v, $lock, $builder, $special, $core, + $endcode) = @_; + + my $job = $class->SUPER::new(@_); + my $fh2 = $job->{builder}->logger->append("junk"); + print $fh2 "$$@", CORE::time(), ": ", $core->hostname, + ": forced junking -> $job->{path}\n"; + $job->add_tasks(DPB::Port::TaskFactory->create('junk')); + return $job; +} + + sub add_normal_tasks { my ($self, $dontclean, $core) = @_; diff --git a/infrastructure/lib/DPB/PkgPath.pm b/infrastructure/lib/DPB/PkgPath.pm index 556e4fe0cf4..e9d5524717a 100644 --- a/infrastructure/lib/DPB/PkgPath.pm +++ b/infrastructure/lib/DPB/PkgPath.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgPath.pm,v 1.50 2015/06/11 08:42:38 espie Exp $ +# $OpenBSD: PkgPath.pm,v 1.51 2015/07/02 08:04:22 espie Exp $ # # Copyright (c) 2010-2013 Marc Espie # @@ -35,6 +35,11 @@ sub init $self->{has} = 5; } +sub forcejunk +{ + return 0; +} + sub path { my $self = shift; diff --git a/infrastructure/lib/DPB/PortBuilder.pm b/infrastructure/lib/DPB/PortBuilder.pm index de59c41f93c..658598ca9d9 100644 --- a/infrastructure/lib/DPB/PortBuilder.pm +++ b/infrastructure/lib/DPB/PortBuilder.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PortBuilder.pm,v 1.71 2015/05/12 19:48:29 espie Exp $ +# $OpenBSD: PortBuilder.pm,v 1.72 2015/07/02 08:04:22 espie Exp $ # # Copyright (c) 2010-2013 Marc Espie # @@ -252,6 +252,27 @@ sub build $job->set_watch($self->logger, $v); } +sub force_junk +{ + my ($self, $v, $core, $final_sub) = @_; + my $start = time(); + my $log = $self->logger->log_pkgpath($v); + my $fh = $self->logger->open('>>', $log); + print $fh ">>> Force junking on ", $core->hostname; + if (defined $core->{user}) { + print $fh " as ", $core->{user}->user, " "; + } + my $job; + $job = DPB::Job::Port->new_junk_only($log, $fh, $v, undef, $self, + 0,$core, + sub { + close($fh); + &$final_sub($job->{failed}); + $core->mark_ready; + }); + $core->start_job($job, $v); +} + sub test { my ($self, $v, $core, $lock, $final_sub) = @_; diff --git a/infrastructure/lib/DPB/SubEngine/Build.pm b/infrastructure/lib/DPB/SubEngine/Build.pm index 956972cd488..9061f3ff46e 100644 --- a/infrastructure/lib/DPB/SubEngine/Build.pm +++ b/infrastructure/lib/DPB/SubEngine/Build.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Build.pm,v 1.15 2015/06/23 14:22:50 espie Exp $ +# $OpenBSD: Build.pm,v 1.16 2015/07/02 08:04:22 espie Exp $ # # Copyright (c) 2010-2013 Marc Espie # @@ -44,6 +44,7 @@ sub preempt_core # so mismatches holds a copy of stuff that's still there. $self->{mismatches} = []; $self->{tag_mismatches} = []; + $self->{klogged} = {}; return 0; } @@ -60,9 +61,17 @@ sub can_start_build # fail abysmally if there's no junking going on my $reason = $core->prop->taint_incompatible($v); if (defined $reason) { - $self->log('K', $v, " ".$core->hostname." ".$reason); - push(@{$self->{tag_mismatches}}, $v); - return 0; + if (!$self->{klogged}{$v->pkgpath}) { + $self->log('K', $v, " ".$core->hostname." ".$reason); + $self->{klogged}{$v->pkgpath} = 1; + } +# if ($self->can_be_junked($v, $core)) { +# $self->force_junk($core); +# return 1; +# } else { + push(@{$self->{tag_mismatches}}, $v); + return 0; +# } } # keep affinity mismatches for later if (defined $v->{affinity} && !$core->matches_affinity($v)) { @@ -158,12 +167,8 @@ sub recheck_mismatches # to fix, it requires a "pseudo" junk first # to untaint the host, THEN we can try building. next unless $self->can_be_junked($v, $core); - $v->{forcejunk} = 1; - if ($self->lock_and_start_build($core, $v)) { - $self->log('C', $v); - return 1; - } - delete $v->{forcejunk}; + $self->force_junk($core); + return 1; } } # let's make sure we don't have something else first @@ -303,6 +308,18 @@ sub start_build }); } +sub force_junk +{ + my ($self, $core) = @_; + my $v = JunkPath->new; + $self->log('C', $v, " ".$core->hostname); + $self->{builder}->force_junk($v, $core, + sub { + my $fail = shift; + $self->log($fail ? 'E': 'B' , $v, " ".$core->hostname); + }); +} + sub end_build { my ($self, $v) = @_; @@ -323,4 +340,24 @@ sub add $self->SUPER::add($v); } +package JunkPath; +our @ISA = qw(DPB::PkgPath); +sub new +{ + my $class = shift; + my $v = bless {}, $class; + DPB::PortInfo->new($v); + return $v; +} + +sub fullpkgpath +{ + return "junk-proxy"; +} + +sub forcejunk +{ + return 1; +} + 1;