mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00

Reuses the mic/livecd infrastructure but heavily subclasses and modifies it to adapt to the special needs of building images from existing OpenEmbedded build artifacts. In addition to the OE-specific mic objects and modifications to the underlying infrastructure, this adds a mechanism to allow OE kickstart files to be 'canned' and made available to users via the 'wic list images' command. Two initial OE kickstart files have been added as canned .wks files: directdisk, which implements the same thing as the images created by directdisk.bbclass, and mkefidisk, which can essentially be used as a replacement for mkefidisk.sh. Of course, since creation of these images are now driven by .wks files rather than being hard-coded into class files or scripts, they can be easily modified to generate different variations on those images. They also don't require root priveleges, since they don't use mount to create the images. They don't however write to media like mkefidisk.sh does, but rather create images that can be written onto media. (From OE-Core rev: f87acc5e59d3c2c39ff171b5557977dab4c8f4a6) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
103 lines
3.3 KiB
Python
103 lines
3.3 KiB
Python
#!/usr/bin/python -tt
|
|
#
|
|
# Copyright (c) 2011 Intel, Inc.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by the Free
|
|
# Software Foundation; version 2 of the License
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
# for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59
|
|
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
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"
|
|
|
|
|
|
class PluginMgr(object):
|
|
plugin_dirs = {}
|
|
|
|
# make the manager class as singleton
|
|
_instance = None
|
|
def __new__(cls, *args, **kwargs):
|
|
if not cls._instance:
|
|
cls._instance = super(PluginMgr, cls).__new__(cls, *args, **kwargs)
|
|
|
|
return cls._instance
|
|
|
|
def __init__(self):
|
|
mic_path = os.path.dirname(__file__)
|
|
eos = mic_path.find('scripts') + len('scripts')
|
|
scripts_path = mic_path[:eos]
|
|
|
|
self.plugin_dir = scripts_path + "/lib/mic/plugins"
|
|
|
|
def append_dirs(self, dirs):
|
|
for path in dirs:
|
|
self._add_plugindir(path)
|
|
|
|
# load all the plugins AGAIN
|
|
self._load_all()
|
|
|
|
def _add_plugindir(self, path):
|
|
path = os.path.abspath(os.path.expanduser(path))
|
|
|
|
if not os.path.isdir(path):
|
|
msger.warning("Plugin dir is not a directory or does not exist: %s"\
|
|
% path)
|
|
return
|
|
|
|
if path not in self.plugin_dirs:
|
|
self.plugin_dirs[path] = False
|
|
# the value True/False means "loaded"
|
|
|
|
def _load_all(self):
|
|
for (pdir, loaded) in self.plugin_dirs.iteritems():
|
|
if loaded: continue
|
|
|
|
sys.path.insert(0, pdir)
|
|
for mod in [x[:-3] for x in os.listdir(pdir) if x.endswith(".py")]:
|
|
if mod and mod != '__init__':
|
|
if mod in sys.modules:
|
|
#self.plugin_dirs[pdir] = True
|
|
msger.warning("Module %s already exists, skip" % mod)
|
|
else:
|
|
try:
|
|
pymod = __import__(mod)
|
|
self.plugin_dirs[pdir] = True
|
|
msger.debug("Plugin module %s:%s imported"\
|
|
% (mod, pymod.__file__))
|
|
except ImportError, err:
|
|
msg = 'Failed to load plugin %s/%s: %s' \
|
|
% (os.path.basename(pdir), mod, err)
|
|
msger.warning(msg)
|
|
|
|
del(sys.path[0])
|
|
|
|
def get_plugins(self, ptype):
|
|
""" the return value is dict of name:class pairs """
|
|
|
|
if ptype not in PLUGIN_TYPES:
|
|
raise errors.CreatorError('%s is not valid plugin type' % ptype)
|
|
|
|
self._add_plugindir(os.path.join(self.plugin_dir, ptype))
|
|
self._load_all()
|
|
|
|
return pluginbase.get_plugins(ptype)
|
|
|
|
pluginmgr = PluginMgr()
|