add a "status fullpkgpath" that displays what it currently knows about a given path, to be augmented eventually.

This commit is contained in:
espie 2017-11-30 14:54:00 +00:00
parent 74bd12a086
commit 20e4b3344d
3 changed files with 61 additions and 4 deletions

View File

@ -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 <espie@openbsd.org>
#
@ -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;

View File

@ -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 <espie@openbsd.org>
#
@ -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;

View File

@ -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 <espie@openbsd.org>
#
@ -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 <fullpkgpath>...\n",
"\tbye\n",
"\tdontclean <pkgpath>...\n",
"\tstats\n"
"\tstats\n",
"\tstatus <fullpkgpath>...\n"
);
} else {
$fh->print("Unknown command: ", $line, " (help for details)\n");