against the set of current builds for the job). This ensures that the builds with the highest ID are what we want in the channel, even in case of reverts.
CVDK3XJKQJVLCNJM5E5K2T7ZIIIBN3WLEK3ADBGQEPAOJ6FZTPNQC
S6OISBQ3HPFHAAQ5ENG7N3MNGOPNEJPIFKSSA5N4G6KJQTQBSSLQC
AHTEIK7GGPHUC3AXIJ2NX4TI3RLX65XYKGAIIC6MC2S6I6QPWTAAC
UUGBVEGYV3FUNL7D3ECA2DIMFHE2S5UQF4ACSLESX3M3NRYYE57AC
S5PV6IIMKJ7PGWIFLLXERHYF3BCP2UEGFRZEZLD6UUBLVEZXJLUAC
N22GPKYTOLZLBGTGDATQDVZ4R5APZEAOIA7L32X4UXBH4XNI7MWAC
7YBYT2LQML2PKEO6UO4444AGSASS664UCDXW2YO3ALB7THQHCEBQC
# Have we already done this build (in this job)? Don't do it
# again unless it has been garbage-collected. The latest
# builds for each platforms are GC roots, so they shouldn't be
# GCed. However, if a job has reverted to a previous state,
# it's possible that a GCed build becomes current again. In
# that case we have to rebuild it to ensure that it appears in
# channels etc.
my @previousBuilds = $jobInDB->builds->search({outPath => $outPath}, {order_by => "id"});
# Don't add a build that has already been scheduled for this
# job, or has been built but is still a "current" build for
# this job. Note that this means that if the sources of a job
# are changed from A to B and then reverted to A, three builds
# will be performed (though the last one will probably use the
# cached result from the first). This ensures that the builds
# with the highest ID will always be the ones that we want in
# the channels.
# !!! Checking $drvPath doesn't take meta-attributes into
# account. For instance, do we want a new build to be
# scheduled if the meta.maintainers field is changed?
my @previousBuilds = $jobInDB->builds->search({drvPath => $drvPath, isCurrent => 1});
foreach my $build (@previousBuilds) {
if (!$build->finished) {
print "already scheduled as build ", $build->id, "\n";
$currentBuilds->{$build->id} = 1;
return;
}
}
if (isValidPath($outPath)) {
print "already done as build ", $previousBuilds[0]->id, "\n";
# Mark the previous build as "current" so that it will
# appear in the "latest" channel for this
# project/jobset/job.
$previousBuilds[0]->update({iscurrent => 1});
$currentBuilds->{$previousBuilds[0]->id} = 1;
return;
}
print "already done as build ", $previousBuilds[0]->id,
"; rebuilding because it was garbage-collected\n";
print "already scheduled/built\n";
$currentBuilds->{$_->id} = 1 foreach @previousBuilds;
return;