From 36fdd7f37f3ad59222e8dfc9cf554462c53cf739 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 6 Mar 2009 13:34:53 +0000 Subject: [PATCH] * For products that are directories (like manuals), allow a default suffix other than index.html to be declared. E.g. if a build does echo "doc manual $out manual.html" >> $out/nix-support/hydra-build-products the default link for the product is http://localhost:3000/build/417/download/1/manual.html but other files are also accessible, e.g. http://localhost:3000/build/417/download/1/style.css --- src/lib/Hydra/Controller/Build.pm | 8 +++++++- src/lib/Hydra/Schema.pm | 4 ++-- src/lib/Hydra/Schema/BuildInputs.pm | 4 ++-- src/lib/Hydra/Schema/BuildProducts.pm | 6 ++++-- src/lib/Hydra/Schema/BuildResultInfo.pm | 4 ++-- src/lib/Hydra/Schema/BuildSchedulingInfo.pm | 4 ++-- src/lib/Hydra/Schema/BuildSteps.pm | 4 ++-- src/lib/Hydra/Schema/Builds.pm | 4 ++-- src/lib/Hydra/Schema/CachedPathInputs.pm | 4 ++-- src/lib/Hydra/Schema/CachedSubversionInputs.pm | 4 ++-- src/lib/Hydra/Schema/JobsetInputAlts.pm | 4 ++-- src/lib/Hydra/Schema/JobsetInputs.pm | 4 ++-- src/lib/Hydra/Schema/Jobsets.pm | 4 ++-- src/lib/Hydra/Schema/Projects.pm | 4 ++-- src/lib/Hydra/Schema/ReleaseSetJobs.pm | 4 ++-- src/lib/Hydra/Schema/ReleaseSets.pm | 4 ++-- src/lib/Hydra/Schema/SystemTypes.pm | 4 ++-- src/lib/Hydra/Schema/UserRoles.pm | 4 ++-- src/lib/Hydra/Schema/Users.pm | 4 ++-- src/root/common.tt | 2 +- src/root/product-list.tt | 4 +++- src/script/hydra_build.pl | 13 +++++++++++-- src/sql/hydra.sql | 1 + 23 files changed, 61 insertions(+), 41 deletions(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index d68382e7..a91f1a9e 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -80,13 +80,17 @@ sub loadLog { sub download : Chained('build') PathPart('download') { - my ($self, $c, $productnr, $filename, @path) = @_; + my ($self, $c, $productnr, @path) = @_; my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr}); notFound($c, "Build doesn't have a product $productnr.") if !defined $product; notFound($c, "Product " . $product->path . " has disappeared.") unless -e $product->path; + # If the product has a name, then the first path element can be + # ignored (it's the name included in the URL for informational purposes). + shift @path if $product->name; + # Security paranoia. foreach my $elem (@path) { error($c, "Invalid filename $elem.") if $elem !~ /^$pathCompRE$/; @@ -104,6 +108,8 @@ sub download : Chained('build') PathPart('download') { notFound($c, "File $path does not exist.") if !-e $path; + notFound($c, "Path $path is a directory.") if -d $path; + $c->serve_static_file($path); } diff --git a/src/lib/Hydra/Schema.pm b/src/lib/Hydra/Schema.pm index 3daf812b..7c96e47d 100644 --- a/src/lib/Hydra/Schema.pm +++ b/src/lib/Hydra/Schema.pm @@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema'; __PACKAGE__->load_classes; -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QcB8T/bY2/Pw34uuYXt2Cw +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hRwus0A1vxnFCzQxghFgTw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildInputs.pm b/src/lib/Hydra/Schema/BuildInputs.pm index 50ae8b63..579f53ff 100644 --- a/src/lib/Hydra/Schema/BuildInputs.pm +++ b/src/lib/Hydra/Schema/BuildInputs.pm @@ -36,8 +36,8 @@ __PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }); __PACKAGE__->belongs_to("dependency", "Hydra::Schema::Builds", { id => "dependency" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7Th7GxvR7m/DdodQqlmJXQ +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:H25BhHe9wbU6nj6fSKjZnw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildProducts.pm b/src/lib/Hydra/Schema/BuildProducts.pm index cecf6cb8..a3fb4df1 100644 --- a/src/lib/Hydra/Schema/BuildProducts.pm +++ b/src/lib/Hydra/Schema/BuildProducts.pm @@ -28,13 +28,15 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 0, size => undef }, "description", { data_type => "text", is_nullable => 0, size => undef }, + "defaultpath", + { data_type => "text", is_nullable => 0, size => undef }, ); __PACKAGE__->set_primary_key("build", "productnr"); __PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FFVpdoV0vBLhF9yyKJSoTA +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rfkj/A+Li7Q0hWydqtJHAw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildResultInfo.pm b/src/lib/Hydra/Schema/BuildResultInfo.pm index a9979880..a8e24310 100644 --- a/src/lib/Hydra/Schema/BuildResultInfo.pm +++ b/src/lib/Hydra/Schema/BuildResultInfo.pm @@ -31,8 +31,8 @@ __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CkjyZptB79J32VhDbXhKEg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wmL9881G+dZrgHKM83dHXw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildSchedulingInfo.pm b/src/lib/Hydra/Schema/BuildSchedulingInfo.pm index 26539d7f..a9d4cf36 100644 --- a/src/lib/Hydra/Schema/BuildSchedulingInfo.pm +++ b/src/lib/Hydra/Schema/BuildSchedulingInfo.pm @@ -27,8 +27,8 @@ __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HeodRHEOs/do8RKwDJhaXg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6cTj5JovtTmtemvQjWtucQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildSteps.pm b/src/lib/Hydra/Schema/BuildSteps.pm index 3e44efa4..d7fef19e 100644 --- a/src/lib/Hydra/Schema/BuildSteps.pm +++ b/src/lib/Hydra/Schema/BuildSteps.pm @@ -35,8 +35,8 @@ __PACKAGE__->set_primary_key("id", "stepnr"); __PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kKpIuRMrqdh7m4M5XPIEgg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LyNlkn5XjBnLp7M4ipB/ZQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Builds.pm b/src/lib/Hydra/Schema/Builds.pm index 829cbb91..8e6542d5 100644 --- a/src/lib/Hydra/Schema/Builds.pm +++ b/src/lib/Hydra/Schema/Builds.pm @@ -76,8 +76,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fGOOscNFEgDZpeVpA6HH0w +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8U9CmcfeowLJVViKiR3n1g __PACKAGE__->has_many(dependents => 'Hydra::Schema::BuildInputs', 'dependency'); diff --git a/src/lib/Hydra/Schema/CachedPathInputs.pm b/src/lib/Hydra/Schema/CachedPathInputs.pm index c7c3f696..cb70bc48 100644 --- a/src/lib/Hydra/Schema/CachedPathInputs.pm +++ b/src/lib/Hydra/Schema/CachedPathInputs.pm @@ -22,8 +22,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("srcpath", "sha256hash"); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0wY3JTSelPQSTbxpNQDJjg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+F3EiYsvXuOjnGDrkhLxng # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/CachedSubversionInputs.pm b/src/lib/Hydra/Schema/CachedSubversionInputs.pm index 845ed3b4..ea17cd02 100644 --- a/src/lib/Hydra/Schema/CachedSubversionInputs.pm +++ b/src/lib/Hydra/Schema/CachedSubversionInputs.pm @@ -20,8 +20,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("uri", "revision"); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eZPs3SB3XZW5BNQOQFrFBw +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:O0QvXjOulMVTjhW4rRHkmQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/JobsetInputAlts.pm b/src/lib/Hydra/Schema/JobsetInputAlts.pm index 6886b52f..5dd7f153 100644 --- a/src/lib/Hydra/Schema/JobsetInputAlts.pm +++ b/src/lib/Hydra/Schema/JobsetInputAlts.pm @@ -31,8 +31,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:atlyxsSKg41KbDkbCfuvHQ +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qXh+0QbMUHIDmQCG9T5qdA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/JobsetInputs.pm b/src/lib/Hydra/Schema/JobsetInputs.pm index 03b093da..8b0593f4 100644 --- a/src/lib/Hydra/Schema/JobsetInputs.pm +++ b/src/lib/Hydra/Schema/JobsetInputs.pm @@ -43,8 +43,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:85ro4sVmhc3HwAjgoA6p6w +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TUTdwfhSsFMKBXa/wKenOQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Jobsets.pm b/src/lib/Hydra/Schema/Jobsets.pm index 1ec36fe1..f6db720d 100644 --- a/src/lib/Hydra/Schema/Jobsets.pm +++ b/src/lib/Hydra/Schema/Jobsets.pm @@ -50,8 +50,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:c5PqrzN43jEGGrzKqI6WWQ +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dVevQ8lPI2/IRpYoJgzLBA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Projects.pm b/src/lib/Hydra/Schema/Projects.pm index 0798e4dd..d0108e16 100644 --- a/src/lib/Hydra/Schema/Projects.pm +++ b/src/lib/Hydra/Schema/Projects.pm @@ -45,8 +45,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7iZYMDM+wn+Neud0Fm1ZMA +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Q5mSKzMxB9px2ja8NjK/9Q # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/ReleaseSetJobs.pm b/src/lib/Hydra/Schema/ReleaseSetJobs.pm index 7b326621..cd0fb393 100644 --- a/src/lib/Hydra/Schema/ReleaseSetJobs.pm +++ b/src/lib/Hydra/Schema/ReleaseSetJobs.pm @@ -32,8 +32,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Rs3CRPpzFi30sAeHVe1yQA +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+Ky8V3sZIgT22hgF27Y0cw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/ReleaseSets.pm b/src/lib/Hydra/Schema/ReleaseSets.pm index db6ac6b6..ea1f05f5 100644 --- a/src/lib/Hydra/Schema/ReleaseSets.pm +++ b/src/lib/Hydra/Schema/ReleaseSets.pm @@ -29,8 +29,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PA+dfXHaBsSx9kE1mEZZ9w +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:f+4AnWTJsi4RDfxoJxECgw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/SystemTypes.pm b/src/lib/Hydra/Schema/SystemTypes.pm index 98f52125..936f63c0 100644 --- a/src/lib/Hydra/Schema/SystemTypes.pm +++ b/src/lib/Hydra/Schema/SystemTypes.pm @@ -16,8 +16,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("system"); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:olHboRdtxD6E7Ukr4aCLCA +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Af/LU15/hpXngfrBrDMI/A # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/UserRoles.pm b/src/lib/Hydra/Schema/UserRoles.pm index c8a05f16..78e5bca6 100644 --- a/src/lib/Hydra/Schema/UserRoles.pm +++ b/src/lib/Hydra/Schema/UserRoles.pm @@ -17,8 +17,8 @@ __PACKAGE__->set_primary_key("username", "role"); __PACKAGE__->belongs_to("username", "Hydra::Schema::Users", { username => "username" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Q7Nd3wv7Y3184GhkE/pdFA +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/yDlbFhRYDzf+0VHzygrhA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Users.pm b/src/lib/Hydra/Schema/Users.pm index 63f9e828..65547eda 100644 --- a/src/lib/Hydra/Schema/Users.pm +++ b/src/lib/Hydra/Schema/Users.pm @@ -30,8 +30,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-04 14:50:30 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:z8fRKy//Mx8wqymMgOcrWA +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-06 14:20:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:d7M/Q6OucU9NUCSB5zZK7Q # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/root/common.tt b/src/root/common.tt index 76bb0206..84da9965 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -42,7 +42,7 @@ [% FOREACH build IN builds -%] ) { - /^([\w\-]+)\s+([\w\-]+)\s+(\S+)$/ or next; + /^([\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; @@ -229,6 +232,8 @@ sub doBuild { or die "cannot hash $path: $?";; chomp $sha256; } + + my $name = $path eq $outPath ? "" : basename $path; $db->resultset('BuildProducts')->create( { build => $build->id @@ -239,7 +244,8 @@ sub doBuild { , filesize => $fileSize , sha1hash => $sha1 , sha256hash => $sha256 - , name => basename $path + , name => $name + , defaultpath => $defaultPath }); } close LIST; @@ -273,12 +279,15 @@ my $build; $db->txn_do(sub { $build = $db->resultset('Builds')->find($buildId); die "build $buildId doesn't exist" unless defined $build; + die "build $buildId already done" if defined $build->resultInfo; if ($build->schedulingInfo->busy != 0 && $build->schedulingInfo->locker != getppid) { die "build $buildId is already being built"; } $build->schedulingInfo->busy(1); $build->schedulingInfo->locker($$); $build->schedulingInfo->update; + $build->buildsteps->delete_all; + $build->buildproducts->delete_all; }); die unless $build; diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 196adc2e..0ff8e36e 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -140,6 +140,7 @@ create table BuildProducts ( path text, name text not null, -- generally just the filename part of `path' description text, -- optionally, some description of this file/directory + defaultPath text, -- if `path' is a directory, the default file relative to `path' to be served primary key (build, productnr), foreign key (build) references Builds(id) on delete cascade -- ignored by sqlite );