diff --git a/infrastructure/lib/DPB/Core.pm b/infrastructure/lib/DPB/Core.pm index 1b7e7bda708..f78d3d1b82a 100644 --- a/infrastructure/lib/DPB/Core.pm +++ b/infrastructure/lib/DPB/Core.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Core.pm,v 1.84 2017/11/30 11:17:53 espie Exp $ +# $OpenBSD: Core.pm,v 1.85 2017/11/30 14:54:00 espie Exp $ # # Copyright (c) 2010-2013 Marc Espie # @@ -457,6 +457,18 @@ sub same_host_jobs return @jobs; } +sub status +{ + my ($self, $v) = @_; + while (my ($pid, $core) = each %{$self->repository}) { + next if !defined $core->job->{v}; + if ($core->job->{v} == $v) { + return "building on ".$core->hostname; + } + } + return undef; +} + sub wake_jobs { my $self = shift; diff --git a/infrastructure/lib/DPB/Engine.pm b/infrastructure/lib/DPB/Engine.pm index 91428f76fd1..ae3ab1c88e0 100644 --- a/infrastructure/lib/DPB/Engine.pm +++ b/infrastructure/lib/DPB/Engine.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Engine.pm,v 1.124 2017/05/04 23:40:29 espie Exp $ +# $OpenBSD: Engine.pm,v 1.125 2017/11/30 14:54:00 espie Exp $ # # Copyright (c) 2010-2013 Marc Espie # @@ -67,6 +67,25 @@ sub new return $o; } +sub status +{ + my ($self, $v) = @_; + for my $k (qw(built tobuild installable)) { + if ($self->{$k}{$v}) { + return $k; + } + } + if ($self->{buildable}->contains($v)) { + return "buildable"; + } + for my $k (qw(errors locks nfslist)) { + if (grep {$_ == $v} @{$self->{$k}}) { + return $k; + } + } + return undef; +} + sub recheck_errors { my $self = shift; diff --git a/infrastructure/lib/DPB/External.pm b/infrastructure/lib/DPB/External.pm index 1ae8a54d82b..3731b1b53ae 100644 --- a/infrastructure/lib/DPB/External.pm +++ b/infrastructure/lib/DPB/External.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: External.pm,v 1.11 2017/11/30 11:17:53 espie Exp $ +# $OpenBSD: External.pm,v 1.12 2017/11/30 14:54:00 espie Exp $ # # Copyright (c) 2017 Marc Espie # @@ -54,6 +54,25 @@ sub server return $o; } +sub status +{ + my ($self, $v) = @_; + if (!defined $v->{info}) { + return "unscanned/unknown"; + } + if ($v->{info} == DPB::PortInfo->stub) { + return "ignored"; + } + my $status = $self->{state}->{engine}->status($v); + if (!defined $status) { + $status = DPB::Core->status($v); + } + if (!defined $status) { + return "???"; + } + return $status; +} + sub handle_command { my ($self, $line, $fh) = @_; @@ -69,6 +88,12 @@ sub handle_command } } elsif ($line =~ m/^stats\b/) { $fh->print($state->engine->statline, "\n"); + } elsif ($line =~ m/^status\s+(.*)/) { + for my $p (split(/\s+/, $1)) { + my $v = DPB::PkgPath->new($p); + $v->quick_dump($fh); + $fh->print("\t", $self->status($v), "\n"); + } } elsif ($line =~ m/^pf{6}\b/) { $fh->print($motto, "\n"); } elsif ($line =~ m/^addpath\s+(.*)/) { @@ -87,7 +112,8 @@ sub handle_command "\taddpath ...\n", "\tbye\n", "\tdontclean ...\n", - "\tstats\n" + "\tstats\n", + "\tstatus ...\n" ); } else { $fh->print("Unknown command: ", $line, " (help for details)\n");