tweak weight handling so that fixing weights and scaling weights works.

add -m option as a reverse to -x, like in pkg_add
This commit is contained in:
espie 2012-03-09 12:51:38 +00:00
parent c3ef4f9916
commit 38db8f2149
3 changed files with 25 additions and 15 deletions

View File

@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
# $OpenBSD: dpb,v 1.48 2012/03/06 11:22:40 espie Exp $
# $OpenBSD: dpb,v 1.49 2012/03/09 12:51:38 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -81,7 +81,7 @@ sub interpret_path
my ($state, $path, $do, $scale) = @_;
my $weight;
if ($path =~ s/\^=(.*)//) {
if ($path =~ s/\=(.*)//) {
$weight = $1;
}
if ($path =~ s/\*(\d+)$//) {
@ -160,8 +160,8 @@ sub handle_options
},
};
$state->SUPER::handle_options('aceqrRstuUvh:xA:C:f:F:I:j:J:m:P:b:L:S:',
"[-acerRsuUvx] [-A arch] [-C plist] [-f N] [-F N] [-I plist] [-J p] [-j N]",
$state->SUPER::handle_options('acemqrRstuUvh:xA:C:f:F:I:j:J:m:P:b:L:S:',
"[-acemrRsuUvx] [-A arch] [-C plist] [-f N] [-F N] [-I plist] [-J p] [-j N]",
"[-P plist] [-h hosts] [-L logdir] [-b log] [-t ctimeout] [-m threshold]",
"[path ...]");
$state->{fullrepo} = join("/", $state->{repo}, $state->arch, "all");
@ -477,8 +477,6 @@ my $state = DPB::State->new('dpb');
$state->handle_options;
$state->start_cores;
$state->handle_build_files;
$state->{all} = 1;
my $default_handling =
@ -511,11 +509,14 @@ $state->interpret_paths(@{$state->{cpaths}},
if ($state->opt('a')) {
$state->{all} = 1;
}
$state->handle_build_files;
$state->{builder} = DPB::PortBuilder->new($state);
$state->{locker} = DPB::Locks->new($state, join("/", $state->logdir, "locks"));
$state->{engine} = DPB::Engine->new($state);
$reporter = DPB::Reporter->new($state->opt('x'),
$reporter = DPB::Reporter->new($state,
$state->heuristics, "DPB::Core", $state->engine);
while (!DPB::Core->avail) {
DPB::Core->reap;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Heuristics.pm,v 1.13 2012/03/06 13:41:38 espie Exp $
# $OpenBSD: Heuristics.pm,v 1.14 2012/03/09 12:51:38 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -125,11 +125,12 @@ sub finish_special
sub set_weight
{
my ($self, $v, $w) = @_;
return unless defined $w;
if (ref $v && $v->{scaled}) {
$weight{$v} //= $w * $v->{scaled};
$weight{$v} = $w * $v->{scaled};
delete $v->{scaled};
} else {
$weight{$v} //= $w + 0;
$weight{$v} = $w;
}
}

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Reporter.pm,v 1.8 2012/02/27 15:37:36 espie Exp $
# $OpenBSD: Reporter.pm,v 1.9 2012/03/09 12:51:38 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -94,12 +94,20 @@ sub filter_can
sub new
{
my $class = shift;
my $notty = shift;
my $isatty = !$notty && -t STDOUT;
if ($isatty) {
my $state = shift;
my $dotty;
if ($state->opt('x')) {
$dotty = 0;
} elsif ($state->opt('m')) {
$dotty = 1;
} else {
$dotty = -t STDOUT;
}
if ($dotty) {
$class->ttyclass->new(@_);
} else {
$singleton //= bless {msg => '', tty => $isatty,
$singleton //= bless {msg => '', tty => $dotty,
producers => $class->filter_can(\@_, 'important'),
continued => 0}, $class;
}