master.cfg: Enable our custom buildbot plugin, yocto_console_view

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2018-06-10 17:13:03 +01:00
parent 02bcaeb027
commit c2f0529364

View File

@ -1,10 +1,46 @@
# -*- python -*-
# ex: set filetype=python:
import os
import imp
import pkg_resources
from buildbot.plugins import *
from buildbot.plugins import db
from yoctoabb import builders, config, schedulers, workers, services, www
import imp
#
# Prepare to feel ill
#
# Buildbot uses plugins from pkg_resources, i.e. things which are installed
# For the Yocto autobuilder, we want the plugin from this repo/directory.
#
# Firstly we therefore have to create a dummy pkg_resources entry/distribution
# which we add into the global working set. Ugly. It gets worse.
#
# The get_plugins('www') call from www/service.py happens before this
# master.cfg file is parsed, which means our plugin won't be found. There
# is no API to rescan for plugins. We therefore so some horrible internal
# API monkey patching to add ourselves into the internal list.
# Create a fake distribution to insert into the global working_set
us = os.path.dirname(os.path.realpath(__file__))
d = pkg_resources.Distribution(us + "/yocto_console_view", metadata=None, project_name="yocto_console_view", version="0.0.1")
# Create the fake entry point definition
ep = pkg_resources.EntryPoint.parse("yocto_console_view = yoctoabb.yocto_console_view.yocto_console_view:ep", dist=d)
# Add the mapping to the fake EntryPoint
d._ep_map = {'buildbot.www': {'yocto_console_view': ep}}
# Add the fake distribution to the global working_set
pkg_resources.working_set.add(d)
# Now monkey patch us into buildbot's plugins DB
for entry in pkg_resources.iter_entry_points('buildbot.www'):
if entry.name == "yocto_console_view":
plugindb = db._DB._namespaces['www']
plugindb._real_tree.add(entry.name, db._PluginEntry('buildbot.www', entry, plugindb._load_entry))
# supports re-loading configuration with buildbot sighup, meaning we can change