bootstrap: Support hooks
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 27 Aug 2013 15:14:59 +0000 (18:14 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 30 Aug 2013 12:06:19 +0000 (15:06 +0300)
Initial support for per-branch hooks. Currently only post-build hook is
supported.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
bootstrap.py

index a35ddf6..1061f59 100755 (executable)
@@ -82,6 +82,11 @@ def build_test_pkg(pkg_name, branch, outdir):
         tag_pattern = 'srcdata/%s/%s/release/*' % (pkg_name, branch)
 
     git_cmd('checkout', ['srcdata/%s/%s' % (pkg_name, branch)])
+    # Check for hooks
+    hooks = {}
+    if os.path.exists('.bootstrap_hooks.py'):
+        LOG.info('Loading bootstrap hooks')
+        execfile('.bootstrap_hooks.py', hooks, hooks)
     tags = git_cmd('tag', ['-l', tag_pattern], True)
     for ind, tag in enumerate(tags):
         builddir = tempfile.mkdtemp(dir='.',
@@ -95,6 +100,12 @@ def build_test_pkg(pkg_name, branch, outdir):
             raise Exception('Building %s / %s failed! Builddata can be found '
                             'in %s' % (pkg_name, tag, builddir))
 
+        # Run postbuild_all hook
+        if 'postbuild' in hooks:
+            LOG.info('Running postbuild_all() hook for %s / %s' %
+                        (pkg_name, tag))
+            hooks['postbuild'](builddir, tag, LOG)
+
         # Create subdirs
         orig_dir = '%s/%s' % (outdir, 'orig')
         if not os.path.isdir(orig_dir):