aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/mic/plugin.py23
-rw-r--r--scripts/lib/mic/pluginbase.py55
2 files changed, 75 insertions, 3 deletions
diff --git a/scripts/lib/mic/plugin.py b/scripts/lib/mic/plugin.py
index 7c296e9765..df03c15081 100644
--- a/scripts/lib/mic/plugin.py
+++ b/scripts/lib/mic/plugin.py
@@ -19,13 +19,12 @@ import os, sys
from mic import msger
from mic import pluginbase
-from mic.conf import configmgr
from mic.utils import errors
__ALL__ = ['PluginMgr', 'pluginmgr']
-PLUGIN_TYPES = ["imager", "backend"] # TODO "hook"
+PLUGIN_TYPES = ["imager", "source"] # TODO "hook"
class PluginMgr(object):
@@ -99,4 +98,24 @@ class PluginMgr(object):
return pluginbase.get_plugins(ptype)
+ def get_source_plugin_methods(self, source_name, methods):
+ """
+ The methods param is a dict with the method names to find. On
+ return, the dict values will be filled in with pointers to the
+ corresponding methods. If one or more methods are not found,
+ None is returned.
+ """
+ return_methods = None
+ for _source_name, klass in self.get_plugins('source').iteritems():
+ if _source_name == source_name:
+ for _method_name in methods.keys():
+ if not hasattr(klass, _method_name):
+ msger.warning("Unimplemented %s source interface for: %s"\
+ % (_method_name, _source_name))
+ return None
+ func = getattr(klass, _method_name)
+ methods[_method_name] = func
+ return_methods = methods
+ return return_methods
+
pluginmgr = PluginMgr()
diff --git a/scripts/lib/mic/pluginbase.py b/scripts/lib/mic/pluginbase.py
index 2f9d7209e9..e26b525dc3 100644
--- a/scripts/lib/mic/pluginbase.py
+++ b/scripts/lib/mic/pluginbase.py
@@ -80,6 +80,59 @@ class ImagerPlugin(_Plugin):
def do_chroot(self):
pass
+class SourcePlugin(_Plugin):
+ mic_plugin_type = "source"
+ """
+ The methods that can be implemented by --source plugins.
+
+ Any methods not implemented in a subclass inherit these.
+ """
+
+ @classmethod
+ def do_install_disk(self, disk, disk_name, cr, workdir, oe_builddir,
+ bootimg_dir, kernel_dir, native_sysroot):
+ """
+ Called after all partitions have been prepared and assembled into a
+ disk image. This provides a hook to allow finalization of a
+ disk image e.g. to write an MBR to it.
+ """
+ msger.debug("SourcePlugin: do_install_disk: disk: %s" % disk_name)
+
+ @classmethod
+ def do_stage_partition(self, part, cr, workdir, oe_builddir, bootimg_dir,
+ kernel_dir, native_sysroot):
+ """
+ Special content staging hook called before do_prepare_partition(),
+ normally empty.
+
+ Typically, a partition will just use the passed-in parame e.g
+ straight bootimg_dir, etc, but in some cases, things need to
+ be more tailored e.g. to use a deploy dir + /boot, etc. This
+ hook allows those files to be staged in a customized fashion.
+ Not that get_bitbake_var() allows you to acces non-standard
+ variables that you might want to use for this.
+ """
+ msger.debug("SourcePlugin: do_stage_partition: part: %s" % part)
+
+ @classmethod
+ def do_configure_partition(self, part, cr, cr_workdir, oe_builddir,
+ bootimg_dir, kernel_dir, native_sysroot):
+ """
+ Called before do_prepare_partition(), typically used to create
+ custom configuration files for a partition, for example
+ syslinux or grub config files.
+ """
+ msger.debug("SourcePlugin: do_configure_partition: part: %s" % part)
+
+ @classmethod
+ def do_prepare_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir,
+ kernel_dir, native_sysroot):
+ """
+ Called to do the actual content population for a partition i.e. it
+ 'prepares' the partition to be incorporated into the image.
+ """
+ msger.debug("SourcePlugin: do_prepare_partition: part: %s" % part)
+
class BackendPlugin(_Plugin):
mic_plugin_type="backend"
@@ -93,4 +146,4 @@ def get_plugins(typen):
else:
return None
-__all__ = ['ImagerPlugin', 'BackendPlugin', 'get_plugins']
+__all__ = ['ImagerPlugin', 'BackendPlugin', 'SourcePlugin', 'get_plugins']