hydra: if evaluator sees cached build, also add the buildproducts
This commit is contained in:
parent
6d74064999
commit
38d50806b9
|
@ -586,6 +586,68 @@ sub evalJobs {
|
||||||
return ($jobs, $nixExprInput);
|
return ($jobs, $nixExprInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub addBuildProducts {
|
||||||
|
my ($db, $build) = @_;
|
||||||
|
|
||||||
|
my $outPath = $build->outpath;
|
||||||
|
my $productnr = 1;
|
||||||
|
|
||||||
|
if (-e "$outPath/nix-support/hydra-build-products") {
|
||||||
|
open LIST, "$outPath/nix-support/hydra-build-products" or die;
|
||||||
|
while (<LIST>) {
|
||||||
|
/^([\w\-]+)\s+([\w\-]+)\s+(\S+)(\s+(\S+))?$/ or next;
|
||||||
|
my $type = $1;
|
||||||
|
my $subtype = $2 eq "none" ? "" : $2;
|
||||||
|
my $path = $3;
|
||||||
|
my $defaultPath = $5;
|
||||||
|
next unless -e $path;
|
||||||
|
|
||||||
|
my $fileSize, my $sha1, my $sha256;
|
||||||
|
|
||||||
|
# !!! validate $path, $defaultPath
|
||||||
|
|
||||||
|
if (-f $path) {
|
||||||
|
my $st = stat($path) or die "cannot stat $path: $!";
|
||||||
|
$fileSize = $st->size;
|
||||||
|
|
||||||
|
$sha1 = `nix-hash --flat --type sha1 $path`
|
||||||
|
or die "cannot hash $path: $?";;
|
||||||
|
chomp $sha1;
|
||||||
|
|
||||||
|
$sha256 = `nix-hash --flat --type sha256 $path`
|
||||||
|
or die "cannot hash $path: $?";;
|
||||||
|
chomp $sha256;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $name = $path eq $outPath ? "" : basename $path;
|
||||||
|
|
||||||
|
$db->resultset('BuildProducts')->create(
|
||||||
|
{ build => $build->id
|
||||||
|
, productnr => $productnr++
|
||||||
|
, type => $type
|
||||||
|
, subtype => $subtype
|
||||||
|
, path => $path
|
||||||
|
, filesize => $fileSize
|
||||||
|
, sha1hash => $sha1
|
||||||
|
, sha256hash => $sha256
|
||||||
|
, name => $name
|
||||||
|
, defaultpath => $defaultPath
|
||||||
|
});
|
||||||
|
}
|
||||||
|
close LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
$db->resultset('BuildProducts')->create(
|
||||||
|
{ build => $build->id
|
||||||
|
, productnr => $productnr++
|
||||||
|
, type => "nix-build"
|
||||||
|
, subtype => ""
|
||||||
|
, path => $outPath
|
||||||
|
, name => $build->nixname
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Check whether to add the build described by $buildInfo.
|
# Check whether to add the build described by $buildInfo.
|
||||||
sub checkBuild {
|
sub checkBuild {
|
||||||
|
@ -666,6 +728,7 @@ sub checkBuild {
|
||||||
, errormsg => ""
|
, errormsg => ""
|
||||||
, releasename => getReleaseName($outPath)
|
, releasename => getReleaseName($outPath)
|
||||||
});
|
});
|
||||||
|
addBuildProducts($build);
|
||||||
} else {
|
} else {
|
||||||
print STDERR "added to queue as build ", $build->id, "\n";
|
print STDERR "added to queue as build ", $build->id, "\n";
|
||||||
$build->create_related('buildschedulinginfo',
|
$build->create_related('buildschedulinginfo',
|
||||||
|
|
|
@ -117,8 +117,8 @@ sub getChannelData {
|
||||||
|
|
||||||
my @storePaths = ();
|
my @storePaths = ();
|
||||||
foreach my $build (@builds2) {
|
foreach my $build (@builds2) {
|
||||||
next unless isValidPath($build->outpath);
|
next unless Hydra::Helper::Nix::isValidPath($build->outpath);
|
||||||
if (isValidPath($build->drvpath)) {
|
if (Hydra::Helper::Nix::isValidPath($build->drvpath)) {
|
||||||
# Adding `drvpath' implies adding `outpath' because of the
|
# Adding `drvpath' implies adding `outpath' because of the
|
||||||
# `--include-outputs' flag passed to `nix-store'.
|
# `--include-outputs' flag passed to `nix-store'.
|
||||||
push @storePaths, $build->drvpath;
|
push @storePaths, $build->drvpath;
|
||||||
|
|
|
@ -383,64 +383,7 @@ sub doBuild {
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($buildStatus == 0) {
|
if ($buildStatus == 0) {
|
||||||
|
addBuildProducts($db, $build);
|
||||||
my $productnr = 1;
|
|
||||||
|
|
||||||
if (-e "$outPath/nix-support/hydra-build-products") {
|
|
||||||
open LIST, "$outPath/nix-support/hydra-build-products" or die;
|
|
||||||
while (<LIST>) {
|
|
||||||
/^([\w\-]+)\s+([\w\-]+)\s+(\S+)(\s+(\S+))?$/ or next;
|
|
||||||
my $type = $1;
|
|
||||||
my $subtype = $2 eq "none" ? "" : $2;
|
|
||||||
my $path = $3;
|
|
||||||
my $defaultPath = $5;
|
|
||||||
next unless -e $path;
|
|
||||||
|
|
||||||
my $fileSize, my $sha1, my $sha256;
|
|
||||||
|
|
||||||
# !!! validate $path, $defaultPath
|
|
||||||
|
|
||||||
if (-f $path) {
|
|
||||||
my $st = stat($path) or die "cannot stat $path: $!";
|
|
||||||
$fileSize = $st->size;
|
|
||||||
|
|
||||||
$sha1 = `nix-hash --flat --type sha1 $path`
|
|
||||||
or die "cannot hash $path: $?";;
|
|
||||||
chomp $sha1;
|
|
||||||
|
|
||||||
$sha256 = `nix-hash --flat --type sha256 $path`
|
|
||||||
or die "cannot hash $path: $?";;
|
|
||||||
chomp $sha256;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $name = $path eq $outPath ? "" : basename $path;
|
|
||||||
|
|
||||||
$db->resultset('BuildProducts')->create(
|
|
||||||
{ build => $build->id
|
|
||||||
, productnr => $productnr++
|
|
||||||
, type => $type
|
|
||||||
, subtype => $subtype
|
|
||||||
, path => $path
|
|
||||||
, filesize => $fileSize
|
|
||||||
, sha1hash => $sha1
|
|
||||||
, sha256hash => $sha256
|
|
||||||
, name => $name
|
|
||||||
, defaultpath => $defaultPath
|
|
||||||
});
|
|
||||||
}
|
|
||||||
close LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
$db->resultset('BuildProducts')->create(
|
|
||||||
{ build => $build->id
|
|
||||||
, productnr => $productnr++
|
|
||||||
, type => "nix-build"
|
|
||||||
, subtype => ""
|
|
||||||
, path => $outPath
|
|
||||||
, name => $build->nixname
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$build->schedulingInfo->delete;
|
$build->schedulingInfo->delete;
|
||||||
|
|
Loading…
Reference in a new issue