refactor: make the builder responsible for telling us whether we should

clean at the end of a build.

Add a new global config option: NEVER_CLEAN
so that no path ever gets cleaned (to be used ONLY if you have lots of disk
space).

I've actually done this manually in the past, to test various tools on
lots of objdirs...
This commit is contained in:
espie 2021-03-21 19:17:34 +00:00
parent 456cabf246
commit 03db828d59
4 changed files with 29 additions and 16 deletions

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Config.pm,v 1.88 2020/03/31 11:12:15 espie Exp $
# $OpenBSD: Config.pm,v 1.89 2021/03/21 19:17:34 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -262,6 +262,9 @@ sub parse_command_line
if ($state->define_present('TESTS')) {
$state->{tests} = $state->{subst}->value('tests');
}
if ($state->{subst}->value('NEVER_CLEAN')) {
$state->{never_clean} = 1;
}
if ($state->{flogdir}) {
$state->{logdir} = $state->{flogdir};
}

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: External.pm,v 1.27 2020/04/04 16:45:33 espie Exp $
# $OpenBSD: External.pm,v 1.28 2021/03/21 19:17:34 espie Exp $
#
# Copyright (c) 2017 Marc Espie <espie@openbsd.org>
#
@ -189,7 +189,7 @@ sub handle_command
my $state = $self->{state};
if ($line =~ m/^dontclean\s+(.*)/) {
for my $p (split(/\s+/, $1)) {
$state->{builder}{dontclean}{$p} = 1;
$state->{dontclean}{$p} = 1;
}
} elsif ($line =~ m/^addhost\s+(.*)/) {
my @list = split(/\s+/, $1);

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Port.pm,v 1.203 2021/02/21 10:48:04 sthen Exp $
# $OpenBSD: Port.pm,v 1.204 2021/03/21 19:17:34 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -243,8 +243,7 @@ sub finalize
if ($core->{status} == 0) {
my $v = $job->{v};
my $builder = $job->{builder};
$job->add_normal_tasks($builder->{dontclean}{$v->pkgpath},
$core);
$job->add_normal_tasks($builder->should_clean($v), $core);
} else {
$job->{signature_only} = 1;
$job->{builder}->register_updates($job->{v});
@ -862,13 +861,14 @@ sub setup
{
my ($task, $core) = @_;
my $job = $core->job;
if ($job->{builder}{dontclean}{$job->{v}->pkgpath}) {
return $job->next_task($core);
} else {
if ($job->{builder}->should_clean($job->{v})) {
$job->{lock}->write("cleaned");
return $task;
} else {
return $job->next_task($core);
}
}
sub finalize
{
my ($self, $core) = @_;
@ -911,6 +911,7 @@ my $repo = {
inbetween => 'DPB::Task::Port::InBetween',
fake => 'DPB::Task::Port::Fake',
signature => 'DPB::Task::Port::Signature',
test => 'DPB::Task::Test',
};
sub create
@ -1195,8 +1196,7 @@ sub new
if ($builder->checks_rebuild($v)) {
$job->add_tasks(DPB::Port::TaskFactory->create('signature'));
} else {
$job->add_normal_tasks($builder->{dontclean}{$v->pkgpath},
$core);
$job->add_normal_tasks($builder->should_clean($v), $core);
}
return $job;
}
@ -1228,7 +1228,7 @@ sub new_junk_only
sub add_normal_tasks
{
my ($self, $dontclean, $core) = @_;
my ($self, $should_clean, $core) = @_;
my @todo;
my $builder = $self->{builder};
@ -1302,9 +1302,9 @@ sub add_normal_tasks
push @todo, 'show-size';
}
if ($self->{v}{info}->want_tests) {
$dontclean = 1;
$should_clean = 0;
}
if (!$dontclean) {
if ($should_clean) {
push @todo, 'clean';
}
$self->add_tasks(map {DPB::Port::TaskFactory->create($_)} @todo);

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: PortBuilder.pm,v 1.87 2019/10/23 10:07:24 espie Exp $
# $OpenBSD: PortBuilder.pm,v 1.88 2021/03/21 19:17:34 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -36,7 +36,6 @@ sub new
my $self = bless {
state => $state,
clean => $state->opt('c'),
dontclean => $state->{dontclean},
fetch => $state->opt('f'),
wantsize => $state->{wantsize},
fullrepo => $state->fullrepo,
@ -101,6 +100,17 @@ sub dontjunk
$self->{dontjunk}{$v->fullpkgname} = 1;
}
sub should_clean
{
my ($self, $v) = @_;
my $state = $self->{state};
if ($state->{never_clean}) {
return 0;
} else {
return !$state->{dontclean}{$v->pkgpath};
}
}
sub make
{
my $self = shift;