Merge branch 'queue-17'

This commit is contained in:
Rob Vermaas 2010-04-13 08:42:44 +00:00
parent 9eaaa0c1e9
commit 8fb3d901cb

View file

@ -6,7 +6,7 @@ use File::Basename;
use POSIX qw(dup2 :sys_wait_h); use POSIX qw(dup2 :sys_wait_h);
use Hydra::Schema; use Hydra::Schema;
use Hydra::Helper::Nix; use Hydra::Helper::Nix;
use Nix;
chdir getHydraPath or die; chdir getHydraPath or die;
my $db = openHydraDB; my $db = openHydraDB;
@ -50,6 +50,21 @@ sub unlockDeadBuilds {
}); });
} }
sub findBuildDependencyInQueue {
my ($build) = @_;
my $drvpath = $build->drvpath;
my @paths = reverse(split '\n', `nix-store -qR $drvpath`);
foreach my $path (@paths) {
if($path ne $drvpath) {
(my $depBuild) = $db->resultset('Builds')->search(
{ drvpath => $path, finished => 0, busy => 0, enabled => 1, disabled => 0 },
{ join => ['schedulingInfo', 'project'], rows => 1 } ) ;
return $depBuild if defined $depBuild;
}
}
return $build ;
}
sub checkBuilds { sub checkBuilds {
print "looking for runnable builds...\n"; print "looking for runnable builds...\n";
@ -90,6 +105,8 @@ sub checkBuilds {
"starting ", scalar(@builds), " builds\n"; "starting ", scalar(@builds), " builds\n";
foreach my $build (@builds) { foreach my $build (@builds) {
$build = findBuildDependencyInQueue($build);
my $logfile = getcwd . "/logs/" . $build->id; my $logfile = getcwd . "/logs/" . $build->id;
mkdir(dirname $logfile); mkdir(dirname $logfile);
unlink($logfile); unlink($logfile);