cbuildbot: generate an index.html file for artifacts (try 2)

Now that we are publishing public artifacts, we need a way for people
to easily access them without guessing the full URL.  Based on the
list of files we uploaded, generate a simple html index of links.

We can't rely on Google Storage's automatic index because it doesn't
have a directory concept.  That means you can't apply ACLs to a dir
(only files), which means only the bucket wide ACLs are used for
control.  We don't want to give the public full indexing of our
buckets (it'd probably be fine as you can't really guess anything
new based on filename alone), but it's not worth the security hassle.

This CL has been rebased on top of version related fixes that no
longer have hanging issues when the build fails.

BUG=chromium-os:39482
TEST=`./buildbot/run_tests` passed
TEST=`cbuildbot --remote {x86,amd64,arm}-generic-full` generated an index readable w/out logging in
TEST=`cbuildbot --remote daisy-release` generated an index readable that requires logging in

Change-Id: I21a43ba9921204735b1fdf9aefffc8ec84a9014a
Previous-Reviewed-on: https://gerrit.chromium.org/gerrit/44611
Reviewed-on: https://gerrit.chromium.org/gerrit/45136
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 47e6b8d..b79b95c 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -136,10 +136,9 @@
   use is builder_instance.Run().
 
   Vars:
-    build_config:  The configuration dictionary from cbuildbot_config.
-    options:  The options provided from optparse in main().
-    archive_urls:  Where our artifacts for this builder will be archived.
-    release_tag:  The associated "chrome os version" of this build.
+    build_config: The configuration dictionary from cbuildbot_config.
+    options: The options provided from optparse in main().
+    release_tag: The associated "chrome os version" of this build.
   """
 
   def __init__(self, options, build_config):
@@ -152,7 +151,6 @@
       os.environ['CHROMEOS_OFFICIAL'] = '1'
 
     self.archive_stages = {}
-    self.archive_urls = {}
     self.release_tag = None
     self.patch_pool = trybot_patch_pool.TrybotPatchPool()
 
@@ -322,9 +320,8 @@
     finally:
       if print_report:
         results_lib.WriteCheckpoint(self.options.buildroot)
-        print '\n\n\n@@@BUILD_STEP Report@@@\n'
-        results_lib.Results.Report(sys.stdout, self.archive_urls,
-                                   self.release_tag)
+        self._RunStage(stages.ReportStage, self.archive_stages,
+                       self.release_tag)
         success = results_lib.Results.BuildSucceededSoFar()
         if exception_thrown and success:
           success = False
@@ -414,7 +411,6 @@
           config = configs.get(board, self.build_config)
           self._RunStage(stages.BuildTargetStage, board, archive_stage,
                          config=config)
-          self.archive_urls[board] = archive_stage.GetDownloadUrl()
 
           # Kick off task(board) in the background.
           queue.put([board])