X27GNHDV5KPZ5GSH6DCAJMNCEMZLCP7M43JWF2X3O5QWXMOX273AC # Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-10-28 17:59:29# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xXiHLBKW5fHl7ukdYeIsTw
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kck2qlNZVLFUnevNPSBVKw
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-10-28 17:59:29# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5SPq4at2/NRvbax49TwfDw
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CnCSHdI5+5p+L6+r/YITxQ
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-10-28 17:59:29# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gp6ZZpDA2VzgnNE9NX99dA
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Odp6qymLlNXbsD7VOQ7PAQ
package HydraFrontend::Schema::Jobsetinputs;use strict;use warnings;use base 'DBIx::Class';__PACKAGE__->load_components("Core");__PACKAGE__->table("jobSetInputs");__PACKAGE__->add_columns("project",{ data_type => "text", is_nullable => 0, size => undef },"job",{ data_type => "text", is_nullable => 0, size => undef },"name",{ data_type => "text", is_nullable => 0, size => undef },"type",{ data_type => "text", is_nullable => 0, size => undef },"uri",{ data_type => "text", is_nullable => 0, size => undef },"revision",{ data_type => "integer", is_nullable => 0, size => undef },"tag",{ data_type => "text", is_nullable => 0, size => undef },);__PACKAGE__->set_primary_key("project", "job", "name");__PACKAGE__->has_many("jobsets","HydraFrontend::Schema::Jobsets",{"foreign.name" => "self.job","foreign.nixexprinput" => "self.name","foreign.project" => "self.project",},);__PACKAGE__->belongs_to("jobset","HydraFrontend::Schema::Jobsets",{ name => "job", project => "project" },);# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pzKFsX3b5wTNZvo8t3WTDg# You can replace this text with custom content, and it will be preserved on regeneration1;
package HydraFrontend::Schema::Jobsets;use strict;use warnings;use base 'DBIx::Class';__PACKAGE__->load_components("Core");__PACKAGE__->table("jobSets");__PACKAGE__->add_columns("name",{ data_type => "text", is_nullable => 0, size => undef },"project",{ data_type => "text", is_nullable => 0, size => undef },"description",{ data_type => "text", is_nullable => 0, size => undef },"nixexprinput",{ data_type => "text", is_nullable => 0, size => undef },"nixexprpath",{ data_type => "text", is_nullable => 0, size => undef },);__PACKAGE__->set_primary_key("project", "name");__PACKAGE__->belongs_to("project","HydraFrontend::Schema::Projects",{ name => "project" },);__PACKAGE__->belongs_to("jobsetinput","HydraFrontend::Schema::Jobsetinputs",{ job => "name", name => "nixexprinput", project => "project" },);__PACKAGE__->has_many("jobsetinputs","HydraFrontend::Schema::Jobsetinputs",{ "foreign.job" => "self.name", "foreign.project" => "self.project" },);# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pEIAO9lDM+lMKLCLGWRdXg# You can replace this text with custom content, and it will be preserved on regeneration1;
package HydraFrontend::Schema::Projects;use strict;use warnings;use base 'DBIx::Class';__PACKAGE__->load_components("Core");__PACKAGE__->table("projects");__PACKAGE__->add_columns("name",{ data_type => "text", is_nullable => 0, size => undef },);__PACKAGE__->set_primary_key("name");__PACKAGE__->has_many("jobsets","HydraFrontend::Schema::Jobsets",{ "foreign.project" => "self.name" },);# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cpO0BGfChpnpm7KBKkSUjw# You can replace this text with custom content, and it will be preserved on regeneration1;
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-10-28 17:59:29# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Fayli8dtSdcAYhfKSZnJwg
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UAjA2VmMoOSjiHk0NUzLfQ
create table projects (name text primary key not null);-- A jobset consists of a set of inputs (e.g. SVN repositories), one-- of which contains a Nix expression containing an attribute set-- describing build jobs.create table jobSets (name text not null,project text not null,description text,nixExprInput text not null, -- name of the jobSetInput containing the Nix expressionnixExprPath text not null, -- relative path of the Nix expressionprimary key (project, name),foreign key (project) references projects(name) on delete cascade, -- ignored by sqliteforeign key (project, name, nixExprInput) references jobSetInputs(project, job, name));create table jobSetInputs (project text not null,job text not null,name text not null,type text not null, -- "svn", "cvs", "path", "file"uri text,revision integer, -- for svntag text, -- for cvsprimary key (project, job, name),foreign key (project, job) references jobSets(project, name) on delete cascade -- ignored by sqlite);
my $jobsXml = `nix-env -f $jobsFile --query --available "*" --attr-path --out-path --drv-path --meta --xml --system-filter "*"`or die "cannot evaluate the Nix expression containing the job definitions: $?";print "$jobsXml";my $jobs = XMLin($jobsXml, KeyAttr => ['attrPath', 'name'])or die "cannot parse XML output";foreach my $jobName (keys %{$jobs->{item}}) {my $job = $jobs->{item}->{$jobName};my $description = defined $job->{meta}->{description} ? $job->{meta}->{description}->{value} : "";print "JOB: $jobName ($description)\n";my $outPath = $job->{outPath};my $drvPath = $job->{drvPath};if (scalar(@{$dbh->selectall_arrayref("select * from builds where jobName = ? and outPath = ?", {}, $jobName, $outPath)}) > 0) {print " already done\n";next;
if (scalar($db->resultset('Builds')->search({project => $project->name, jobset => $jobset->name, attrname => $jobName, outPath => $outPath})) > 0) {print " already done\n";return;
$db->txn_do(sub {my $build = $db->resultset('Builds')->create({ timestamp => time(), project => $project->name, jobset => $jobset->name, attrname => $jobName, drvpath => $drvPath, outpath => $outPath, iscachedbuild => $isCachedBuild, buildstatus => $buildStatus, starttime => $startTime, stoptime => $stopTime});});return 0;my $dbh, my $description, my $jobName;
}sub fetchInput {my ($input, $inputInfo) = @_;my $type = $input->type;my $uri = $input->uri;if ($type eq "path") {my $storePath = `nix-store --add "$uri"`or die "cannot copy path $uri to the Nix store";chomp $storePath;print " copied to $storePath\n";$$inputInfo{$input->name} = {storePath => $storePath};}else {die "input `" . $input->type . "' has unknown type `$type'";}
sub checkJobSet {my ($project, $jobset) = @_;my $inputInfo = {};foreach my $input ($jobset->jobsetinputs) {print " INPUT ", $input->name, " (", $input->type, " ", $input->uri, ")\n";fetchInput($input, $inputInfo);}die unless defined $inputInfo->{$jobset->nixexprinput};my $nixExprPath = $inputInfo->{$jobset->nixexprinput}->{storePath} . "/" . $jobset->nixexprpath;print " EVALUATING $nixExprPath\n";my $jobsXml = `nix-instantiate $nixExprPath --eval-only --strict --xml`or die "cannot evaluate the Nix expression containing the jobs: $?";#print "$jobsXml";my $jobs = XMLin($jobsXml,ForceArray => [qw(value)],KeyAttr => ['name'],SuppressEmpty => '',ValueAttr => [value => 'value'])or die "cannot parse XML output";die unless defined $jobs->{attrs};foreach my $jobName (keys(%{$jobs->{attrs}->{attr}})) {print " JOB $jobName\n";my $jobExpr = $jobs->{attrs}->{attr}->{$jobName};my $extraArgs = "";# If the expression is a function, then look at its formal# arguments and see if we can supply them.if (defined $jobExpr->{function}->{attrspat}) {foreach my $argName (keys(%{$jobExpr->{function}->{attrspat}->{attr}})) {print " needs input $argName\n";die "missing input `$argName'" if !defined $inputInfo->{$argName};$extraArgs .= " --arg $argName '{path = " . $inputInfo->{$argName}->{storePath} . ";}'";}}# Instantiate the store derivation.my $drvPath = `nix-instantiate $nixExprPath --attr $jobName $extraArgs`or die "cannot evaluate the Nix expression containing the job definitions: $?";chomp $drvPath;# Call nix-env --xml to get info about this job (drvPath, outPath, meta attributes, ...).my $infoXml = `nix-env -f $nixExprPath --query --available "*" --attr-path --out-path --drv-path --meta --xml --system-filter "*" --attr $jobName $extraArgs`or die "cannot get information about the job: $?";my $info = XMLin($infoXml, KeyAttr => ['attrPath', 'name'])or die "cannot parse XML output";my $job = $info->{item};die unless !defined $job || $job->{system} ne $jobName;my $description = defined $job->{meta}->{description} ? $job->{meta}->{description}->{value} : "";die unless $job->{drvPath} eq $drvPath;my $outPath = $job->{outPath};buildJob($project, $jobset, $jobName, $drvPath, $outPath);}}sub checkJobs {foreach my $project ($db->resultset('Projects')->all) {print "PROJECT ", $project->name, "\n";foreach my $jobset ($project->jobsets->all) {print " JOBSET ", $jobset->name, "\n";checkJobSet($project, $jobset);}}}checkJobs;
insert into projects(name) values('patchelf');insert into jobSets(project, name, description, nixExprInput, nixExprPath) values('patchelf', 'trunk', 'PatchELF', 'patchelfSrc', 'release.nix');insert into jobSetInputs(project, job, name, type, uri) values('patchelf', 'trunk', 'patchelfSrc', 'path', '/home/eelco/Dev/patchelf-wc');insert into jobSetInputs(project, job, name, type, uri) values('patchelf', 'trunk', 'nixpkgs', 'path', '/home/eelco/Dev/nixpkgs-wc');insert into jobSetInputs(project, job, name, type, uri) values('patchelf', 'trunk', 'release', 'path', '/home/eelco/Dev/release');--insert into projects(name) values('nixpkgs');--insert into jobSets(project, name) values('nixpkgs', 'trunk');--insert into jobSets(project, name) values('nixpkgs', 'stdenv-branch');