a bit of interactive mode. Just hooks into the main loop and can prompt for
commands now, can't do anything serious yet.
This commit is contained in:
parent
80a679b82b
commit
bce91e106f
@ -1,7 +1,7 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: dpb,v 1.113 2015/07/15 14:30:26 espie Exp $
|
||||
# $OpenBSD: dpb,v 1.114 2015/08/24 10:16:18 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -74,7 +74,7 @@ DPB::Trace->setup(\%SIG);
|
||||
my $state = DPB::State->new('dpb');
|
||||
$state->handle_options;
|
||||
|
||||
$state->{all} = 1;
|
||||
$state->{all} = !$state->is_interactive;
|
||||
|
||||
my $default_handling =
|
||||
sub {
|
||||
@ -191,7 +191,9 @@ sub handle_non_waiting_jobs
|
||||
}
|
||||
DPB::Core->log_concurrency(time(), $state->{concurrent});
|
||||
DPB::Core->wake_jobs;
|
||||
$reporter->report($force_report);
|
||||
if ($state->want_report) {
|
||||
$reporter->report($force_report);
|
||||
}
|
||||
}
|
||||
|
||||
sub main_loop
|
||||
@ -221,7 +223,8 @@ sub main_loop
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$state->opt('q') || !$state->engine->recheck_errors) {
|
||||
if ($state->may_ask_for_commands) {
|
||||
} elsif (!$state->opt('q') || !$state->engine->recheck_errors) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: Config.pm,v 1.59 2015/08/22 09:24:42 espie Exp $
|
||||
# $OpenBSD: Config.pm,v 1.60 2015/08/24 10:16:18 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -103,7 +103,11 @@ sub parse_command_line
|
||||
$state->usage("-$l takes an integer argument, not $o");
|
||||
}
|
||||
}
|
||||
$state->{interactive} = $state->opt('i');
|
||||
if ($state->opt('i')) {
|
||||
require DPB::Interactive;
|
||||
$state->{interactive} = DPB::Interactive->new;
|
||||
}
|
||||
|
||||
$state->{chroot} = $state->opt('B');
|
||||
$state->{base_user} = DPB::User->from_uid($<);
|
||||
if (!defined $state->{base_user}) {
|
||||
@ -215,7 +219,7 @@ sub parse_command_line
|
||||
|
||||
$state->{size_log} = "%f/build-stats/%a-size";
|
||||
|
||||
my $k = $state->{interactive} ? "STARTUPI" : "STARTUP";
|
||||
my $k = $state->is_interactive ? "STARTUPI" : "STARTUP";
|
||||
if ($state->define_present($k)) {
|
||||
$state->{startup_script} = $state->{subst}->value($k);
|
||||
}
|
||||
|
63
infrastructure/lib/DPB/Interactive.pm
Normal file
63
infrastructure/lib/DPB/Interactive.pm
Normal file
@ -0,0 +1,63 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: Interactive.pm,v 1.1 2015/08/24 10:16:18 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2015 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;
|
||||
|
||||
package DPB::Interactive;
|
||||
|
||||
sub new
|
||||
{
|
||||
my $class = shift;
|
||||
require Term::ReadLine;
|
||||
bless {
|
||||
rl => Term::ReadLine->new('dpb'),
|
||||
prompt => '$ ',
|
||||
want_report => 1}, $class;
|
||||
}
|
||||
|
||||
|
||||
sub is_interactive
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub want_report
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
return $self->{want_report};
|
||||
}
|
||||
|
||||
sub may_ask_for_commands
|
||||
{
|
||||
my $self = shift;
|
||||
return 0 if $self->{quitting};
|
||||
my $cmd = $self->{rl}->readline($self->{prompt});
|
||||
$self->{want_report} = 0;
|
||||
if ($cmd =~ m/^(?:port|pkgpath)\s+(\S+)/) {
|
||||
$self->{current_port} = $1;
|
||||
$self->{prompt} = $self->{current_port}.'$ ';
|
||||
} elsif ($cmd =~ m/^quit\b/i) {
|
||||
$self->{quitting} = 1;
|
||||
} else {
|
||||
print STDERR "Unknown command\n";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
@ -1,5 +1,5 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: State.pm,v 1.14 2015/07/28 09:20:54 espie Exp $
|
||||
# $OpenBSD: State.pm,v 1.15 2015/08/24 10:16:18 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -18,6 +18,29 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
package DPB::InteractiveStub;
|
||||
|
||||
sub new
|
||||
{
|
||||
my $class = shift;
|
||||
bless {}, $class;
|
||||
}
|
||||
|
||||
sub is_interactive
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub want_report
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub may_ask_for_commands
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
package DPB::State;
|
||||
our @ISA = qw(OpenBSD::State);
|
||||
|
||||
@ -48,10 +71,29 @@ sub init
|
||||
$self->{heuristics} = DPB::Heuristics->new($self);
|
||||
$self->{make} = $ENV{MAKE} || OpenBSD::Paths->make;
|
||||
$self->{starttime} = time();
|
||||
$self->{interactive} = DPB::InteractiveStub->new;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub is_interactive
|
||||
{
|
||||
my $self = shift;
|
||||
return $self->{interactive}->is_interactive;
|
||||
}
|
||||
|
||||
sub want_report
|
||||
{
|
||||
my $self = shift;
|
||||
return $self->{interactive}->want_report;
|
||||
}
|
||||
|
||||
sub may_ask_for_commands
|
||||
{
|
||||
my $self = shift;
|
||||
return $self->{interactive}->may_ask_for_commands;
|
||||
}
|
||||
|
||||
sub startdate
|
||||
{
|
||||
my $self = shift;
|
||||
|
Loading…
Reference in New Issue
Block a user