From ffd0f75692fc36418d6ed35d823cfc36afa0acf3 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <e.dolstra@tudelft.nl>
Date: Fri, 7 Nov 2008 17:10:34 +0000
Subject: [PATCH] * Generic declaration of build products.

---
 src/HydraFrontend/lib/HydraFrontend/Schema.pm |   4 +-
 .../lib/HydraFrontend/Schema/Buildinputs.pm   |   4 +-
 .../lib/HydraFrontend/Schema/Buildlogs.pm     |   4 +-
 .../lib/HydraFrontend/Schema/Buildproducts.pm |   8 ++--
 .../lib/HydraFrontend/Schema/Builds.pm        |   4 +-
 .../HydraFrontend/Schema/Jobsetinputalts.pm   |   4 +-
 .../lib/HydraFrontend/Schema/Jobsetinputs.pm  |   4 +-
 .../lib/HydraFrontend/Schema/Jobsets.pm       |   4 +-
 .../lib/HydraFrontend/Schema/Projects.pm      |   4 +-
 src/HydraFrontend/root/build.tt               |  13 ++++++-
 src/HydraFrontend/root/hydra.css              |   7 +++-
 .../root/static/images/rpm-fedora.png         | Bin 0 -> 1384 bytes
 .../root/static/images/source-dist.png        | Bin 0 -> 534 bytes
 src/hydra.sql                                 |  24 ++++++++++--
 src/scheduler.pl                              |  36 ++++++++++++++----
 15 files changed, 88 insertions(+), 32 deletions(-)
 create mode 100644 src/HydraFrontend/root/static/images/rpm-fedora.png
 create mode 100644 src/HydraFrontend/root/static/images/source-dist.png

diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema.pm b/src/HydraFrontend/lib/HydraFrontend/Schema.pm
index 3cf0a797..b9596bce 100644
--- a/src/HydraFrontend/lib/HydraFrontend/Schema.pm
+++ b/src/HydraFrontend/lib/HydraFrontend/Schema.pm
@@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema';
 __PACKAGE__->load_classes;
 
 
-# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-06 19:19:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DQCaurV1oArj0odoPHR+zw
+# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-07 17:44:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WdXbmj1/EvPeU107AjY6zw
 
 
 # You can replace this text with custom content, and it will be preserved on regeneration
diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm
index c446cf3b..3e1e8243 100644
--- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm
+++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm
@@ -35,8 +35,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-06 19:19:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZDtFSXPegKbVEAoM+svosg
+# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-07 17:44:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GBvbApjpjiwkUQsdZg1PLg
 
 __PACKAGE__->belongs_to(
   "build",
diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm
index 561531b1..49934b7e 100644
--- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm
+++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm
@@ -25,8 +25,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-06 19:19:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YwyZF3sTsIWvkKAQ5fPtMQ
+# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-07 17:44:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vLByOFOHkwwHa6hf8nC1Jg
 
 
 # You can replace this text with custom content, and it will be preserved on regeneration
diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm
index 302b6229..37bf3476 100644
--- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm
+++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm
@@ -16,8 +16,10 @@ __PACKAGE__->add_columns(
   { data_type => "text", is_nullable => 0, size => undef },
   "path",
   { data_type => "text", is_nullable => 0, size => undef },
+  "productnr",
+  { data_type => "integer", is_nullable => 0, size => undef },
 );
-__PACKAGE__->set_primary_key("buildid", "type", "subtype");
+__PACKAGE__->set_primary_key("buildid", "productnr");
 __PACKAGE__->belongs_to(
   "buildid",
   "HydraFrontend::Schema::Builds",
@@ -25,8 +27,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-06 19:19:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:m2mxFOI2ZgjLoAzbNhiDlw
+# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-07 17:44:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4exGa1a3mCSv3b8Lqwu7Hw
 
 
 # You can replace this text with custom content, and it will be preserved on regeneration
diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm
index a917f76e..0fd02526 100644
--- a/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm
+++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm
@@ -55,8 +55,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-06 19:19:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jcNXcVLLxMEddBCUkq5aYg
+# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-07 17:44:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xsDBmgfas2tM/Dn9PE/eXQ
 
 __PACKAGE__->has_many(dependentBuildInputs => 'HydraFrontend::Schema::Buildinputs', 'inputid');
 
diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm
index b560460f..317ae9bd 100644
--- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm
+++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm
@@ -33,8 +33,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-06 19:19:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YK+TrYs5Zk+8q+66b3kOUw
+# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-07 17:44:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8fi3nwRY3VrwApBAW6XrQQ
 
 
 # You can replace this text with custom content, and it will be preserved on regeneration
diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm
index 54e3baf0..a5ff8443 100644
--- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm
+++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm
@@ -43,8 +43,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-06 19:19:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:H0KE/7kJ23s4RKFDVRIyUQ
+# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-07 17:44:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0uYHZfy1ZXCTLc3AsFWI0w
 
 
 # You can replace this text with custom content, and it will be preserved on regeneration
diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm
index 4c190b23..4adb8947 100644
--- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm
+++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm
@@ -40,8 +40,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-06 19:19:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7JksbkRjqTKzHQkOvUkt2g
+# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-07 17:44:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:g1LPc13y/7/ngDzFqL5jXQ
 
 
 # You can replace this text with custom content, and it will be preserved on regeneration
diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm
index 2b09566e..6f287ab1 100644
--- a/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm
+++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm
@@ -19,8 +19,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-06 19:19:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:F3bS3Kbsxhp9G6klfVPRmg
+# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-07 17:44:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fIpNlZNqqGDGGWd6EORCAA
 
 
 # You can replace this text with custom content, and it will be preserved on regeneration
diff --git a/src/HydraFrontend/root/build.tt b/src/HydraFrontend/root/build.tt
index e3a2e50c..22197099 100644
--- a/src/HydraFrontend/root/build.tt
+++ b/src/HydraFrontend/root/build.tt
@@ -103,13 +103,24 @@
 
 <h2>Build products</h2>
 
-<ul>
+<ul class="productList">
 
   [% FOREACH product IN build.buildproducts -%]
   <li>
     [% SWITCH product.type %]
     [% CASE "nix-build" %]
       Nix build of path <tt>[% product.path %]</tt>
+    [% CASE "file" %]
+      [% SWITCH product.subtype %]
+      [% CASE "source-dist" %]
+        <img src="/static/images/source-dist.png" alt="Source" /> Source distribution <tt>[% product.path %]</tt>
+      [% CASE "rpm" %]
+        <img src="/static/images/rpm-fedora.png" alt="RPM" /> RPM package <tt>[% product.path %]</tt>
+      [% CASE DEFAULT %]
+        File <tt>[% product.path %]</tt> of type <tt>[% product.subtype %]</tt>
+      [% END %]
+    [% CASE DEFAULT %]
+      Something of type <tt>[% product.type %]</tt>
     [% END %]
   </li>
   [% END -%]
diff --git a/src/HydraFrontend/root/hydra.css b/src/HydraFrontend/root/hydra.css
index b645077a..cfd9b3da 100644
--- a/src/HydraFrontend/root/hydra.css
+++ b/src/HydraFrontend/root/hydra.css
@@ -152,6 +152,11 @@ pre.buildlog {
     padding: 0.3em;
 }
 
+ul.productList {
+    list-style: none;
+    padding-left: 1em;
+}
+
 
 /* Sortable tables */
 
@@ -180,4 +185,4 @@ table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSo
 
 table.tablesorter thead tr th {
     padding-right: 1.5em;
-}
\ No newline at end of file
+}
diff --git a/src/HydraFrontend/root/static/images/rpm-fedora.png b/src/HydraFrontend/root/static/images/rpm-fedora.png
new file mode 100644
index 0000000000000000000000000000000000000000..a32716690d558f102c2d5dbb23b4da45204287e2
GIT binary patch
literal 1384
zcmeAS@N?(olHy`uVBq!ia0y~yV2}Y}4rT@h2G`5_%NQ7#CI<L~xH4!ZGH55UX(Tad
zC$nqDGU%i*=*DwsCNb!ya%#mf=%sOKB{S%!b8E*l7-aBhr!W~N^Xeq<X{Yk(CNdl3
z^XsIs7-k9RCbAk92<j!V8)Y+?7PA`_3hO6x8s~@@CNNl(F<6u{SQRl?R`8l-iW{Zz
zn`bdw)w5bx30bCd*p`WymowNmbJ`V(TIDe~w({E5%3Ege+t*3j<w)7*vbuH)J2c4I
zm#Eq0$vYJ?cu!;Souueo#OKk+@7clNH<Q7Cik4#$tN(0auL+_)J@TH-3?cJ41LlZ(
zPhtpLz!Nx^A$$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A~v@5v47_|Eb;o&
z9`*GL%=u25woFf!-MLsv>2Zwdx&u=LyEsm6{(GohL~oK7!@F;OF;&W+R=iyQ=hBTI
z1-a`4UU@Va39&uNv^@CvVp(S7|0S6x%?~b^ksu%Drq#HdbHBxpyLo5xw<?C|*BllN
z+~Kuq%RwcH6SFqe9N!jwDMw4|mcg;x;%}-G1iwD>slRZ&-$*=f(;1FrJ<+3lr`xwp
z*s#q()op9=?KvGn{JSSjIQ^?ec|mo^<%~rB7AdDgRegdU+r%rbO)}+ExGuK(TG)e<
z!zVWU&nwxi>Th*o=WfSD33sl;_S&kMH?uQq=RT8o!1>!uoAKGN@cNwp%aq*CU)Zs5
z+t$acLVtgG^LUxk=i{RNw`Wd2{86#;pyk&y)pykF?N2(Nny@-5WVXb5r!JYVA7`$V
z%i~`d%^&;TY|GZ;-^8ZB)7P}yuztywHGlr?*89ot=D8(kxw-2e1_lNOPgg&ebxsLQ
E0LucHfdBvi

literal 0
HcmV?d00001

diff --git a/src/HydraFrontend/root/static/images/source-dist.png b/src/HydraFrontend/root/static/images/source-dist.png
new file mode 100644
index 0000000000000000000000000000000000000000..cb6bdd346f9601a48d4f899f68af3bf81fef72a6
GIT binary patch
literal 534
zcmeAS@N?(olHy`uVBq!ia0y~yV31>AU=ZP8W?*1gTUz^#fq{V~-O<;Pfnog#bJnhx
z3=9mCC9V-A!TD(=<%vb942~)JNvR5+xryniL8*x;m4zo$Z5S9B3<7*YTyt`=Cr_HN
zZQGW=e}A7obs{7rWaWzG*REZ8`QoX)y<J^RWm{|W=g%J>Jh*+}z`p<g|Iav?u$h5@
zL7*haFZe$yV0fS$E6KpX7~tvR7*cU7>A`Vs2Br?isizMfIdc5Skwb?LaX(~c5$H0p
zwzrm+mR43)HWwE+k6=+~P`G4s#^J!hvnLKSO?$@XW!$97z{H`$J1OPa)3nD7s~WSO
zJ!1A|W)Wca(U&(D?s&xZishuSgAO}~!UPk2YioUdWp<BgbA?$VA|)df*D->Gtpz?5
zZrre8voW(TYvh>&TvORN6jCz9?Ci`o9OWs<Y+z{e*u24@kWuyLj05Y~PC6}RWa3af
z%RcE@+pE;4EgsA)0v=KsI^5D8vpPBTxIwyAGSw6sP8|X%)H-|o80)0eq=r{d)0)6)
zXU%MvRXTf&?c%AU$JjusGo~19E@)orxXHoOtSqg=!hzvnQcpXp%4xQVPaZcORdirb
zRGKogmG_0o0u^C)r7lJ$4$Xa)HynRGeAdM1z_4(cn4FlHoCsqB12e-jX7Sq--V3uc
QFfcH9y85}Sb4q9e0GEi(ssI20

literal 0
HcmV?d00001

diff --git a/src/hydra.sql b/src/hydra.sql
index 00743e8f..7716f2a1 100644
--- a/src/hydra.sql
+++ b/src/hydra.sql
@@ -7,8 +7,6 @@ create table builds (
     jobSet        text not null, -- !!! foreign key
     attrName      text not null,
 
-    -- !!! list all the inputs / arguments
-
     -- Info about the build result.
     description   text,
     drvPath       text not null,
@@ -44,10 +42,11 @@ create table buildInputs (
 
 create table buildProducts (
     buildId       integer not null,
+    productnr     integer not null,
     type          text not null, -- "nix-build", "file", "doc", "report", ...
-    subtype       text not null, -- "sources", "rpm", ...
+    subtype       text not null, -- "source-dist", "rpm", ...
     path          text not null,
-    primary key   (buildId, type, subType),
+    primary key   (buildId, productnr),
     foreign key   (buildId) references builds(id) on delete cascade -- ignored by sqlite
 );
 
@@ -117,3 +116,20 @@ create table jobSetInputAlts (
     primary key   (project, jobset, input, altnr),
     foreign key   (project, jobset, input) references jobSetInputs(project, jobset, name) on delete cascade -- ignored by sqlite
 );
+
+
+create table jobQueue (
+    id            integer primary key autoincrement not null,
+    timestamp     integer not null, -- time this build was added to the db (in Unix time)
+    
+    -- Info about the inputs.
+    project       text not null, -- !!! foreign key
+    jobSet        text not null, -- !!! foreign key
+    attrName      text not null,
+
+    -- What this job will build.
+    description   text,
+    drvPath       text not null,
+    outPath       text not null,
+    system        text not null
+);
diff --git a/src/scheduler.pl b/src/scheduler.pl
index 330af1b5..cf026bd7 100644
--- a/src/scheduler.pl
+++ b/src/scheduler.pl
@@ -96,13 +96,8 @@ sub buildJob {
 
         if ($outputCreated) {
 
-            $db->resultset('Buildproducts')->create(
-                { buildid => $build->id
-                , type => "nix-build"
-                , subtype => ""
-                , path => $outPath
-                });
-            
+            my $productnr = 0;
+
             if (-e "$outPath/log") {
                 foreach my $logPath (glob "$outPath/log/*") {
                     print "      LOG $logPath\n";
@@ -114,6 +109,33 @@ sub buildJob {
                         });
                 }
             }
+
+            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+)$/ or die;
+                    my $type = $1;
+                    my $subtype = $2;
+                    my $path = $3;
+                    die unless -e $path;
+                    $db->resultset('Buildproducts')->create(
+                        { buildid => $build->id
+                        , productnr => $productnr++
+                        , type => $type
+                        , subtype => $subtype
+                        , path => $path
+                        });
+                }
+                close LIST;
+            } else {
+                $db->resultset('Buildproducts')->create(
+                    { buildid => $build->id
+                    , productnr => $productnr++
+                    , type => "nix-build"
+                    , subtype => ""
+                    , path => $outPath
+                    });
+            }
         }
         
     });