From db5d134f397cc92d9c18bc249d914a171ebcc3d9 Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Tue, 31 Jul 2018 18:05:45 -0400 Subject: WIP Signed-off-by: Mark Hatle --- lib/bblayerlib/README | 11 ++ lib/bblayerlib/__init__.py | 373 ++++++++++++++++++++++++++++++++++++++++++++ lib/bblayerlib/plugin.py | 58 +++++++ lib/bblayers/query.py | 23 ++- lib/layerindexlib/cooker.py | 258 ++---------------------------- 5 files changed, 471 insertions(+), 252 deletions(-) create mode 100644 lib/bblayerlib/README create mode 100644 lib/bblayerlib/__init__.py create mode 100644 lib/bblayerlib/plugin.py diff --git a/lib/bblayerlib/README b/lib/bblayerlib/README new file mode 100644 index 000000000..f9d4ec6b9 --- /dev/null +++ b/lib/bblayerlib/README @@ -0,0 +1,11 @@ +The bblayerlib module is designed to manage the conf/bblayers.conf file +and related actions. + +It provides a common interface to: + fetch-layers - Fetch one or more layers from a remote SCM + add-layers - Add one or more layers to bblayers.conf + remove-layers - Remove one or more layers from bblayers.conf + get-layer-info - Get a list of currently configured layers + +TODO: + diff --git a/lib/bblayerlib/__init__.py b/lib/bblayerlib/__init__.py new file mode 100644 index 000000000..4e61db8b1 --- /dev/null +++ b/lib/bblayerlib/__init__.py @@ -0,0 +1,373 @@ +# Copyright (C) 2016-2018 Wind River Systems, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# 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 logging +import imp +import re + +from collections import defaultdict, OrderedDict + +import layerindexlib + +logger = logging.getLogger('BitBake.bblayerlib') + +# Exceptions + +class BBLayerLibException(Exception): + '''BBLayerLib Generic Exception''' + def __init__(self, message): + self.msg = message + Exception.__init__(self, message) + + def __str__(self): + return self.msg + +class BBLayerLibUrlError(BBLayerLibException): + '''Exception raised when unable to access a URL for some reason''' + def __init__(self, url, message=""): + if message: + msg = "Unable to access url %s: %s" % (url, message) + else: + msg = "Unable to access url %s" % url + self.url = url + BBLayerLibException.__init__(self, msg) + +class BBLayerLibFetchError(BBLayerLibException): + '''General layerindex fetcher exception when something fails''' + def __init__(self, url, message=""): + if message: + msg = "Unable to fetch url %s: %s" % (url, message) + else: + msg = "Unable to fetch url %s" % url + self.url = url + BBLayerLibException.__init__(self, msg) + + +# Interface to managing the bblayers.conf file +class BBLayers(): + def __init__(self, d): + self.data = d + self.bblayers = None + + def _run_command(self, command, path, default=None): + try: + result, _ = bb.process.run(command, cwd=path) + result = result.strip() + except bb.process.ExecutionError: + result = default + return result + + def _handle_git_remote(self, remote): + if "://" not in remote: + if ':' in remote: + # This is assumed to be ssh + remote = "ssh://" + remote + else: + # This is assumed to be a file path + remote = "file://" + remote + return remote + + def _get_bitbake_info(self): + """Return a tuple of bitbake information""" + + # Our path SHOULD be .../bitbake/lib/bblayerlib/__init__.py + bb_path = os.path.dirname(__file__) # .../bitbake/lib/bblayerlib/__init__.py + bb_path = os.path.dirname(bb_path) # .../bitbake/lib/bblayerlib + bb_path = os.path.dirname(bb_path) # .../bitbake/lib + bb_path = os.path.dirname(bb_path) # .../bitbake + bb_path = self._run_command('git rev-parse --show-toplevel', os.path.dirname(__file__), default=bb_path) + bb_branch = self._run_command('git rev-parse --abbrev-ref HEAD', bb_path, default="") + bb_rev = self._run_command('git rev-parse HEAD', bb_path, default="") + for remotes in self._run_command('git remote -v', bb_path, default="").split("\n"): + remote = remotes.split("\t")[1].split(" ")[0] + if "(fetch)" == remotes.split("\t")[1].split(" ")[1]: + bb_remote = self._handle_git_remote(remote) + break + else: + bb_remote = self._handle_git_remote(bb_path) + + return (bb_remote, bb_branch, bb_rev, bb_path) + + def load_bblayers(self, branches=None): + """Load the BBLAYERS and related collection information""" + + if not branches: + branches = [ 'HEAD' ] + + # Manage the items as a LayerInexObject.. just a bit easier + self.bblayers = layerindexlib.LayerIndexObj() + + branchId = 0 + self.bblayers.branches = {} + + layerItemId = 0 + self.bblayers.layerItems = {} + + layerBranchId = 0 + self.bblayers.layerBranches = {} + + bblayers = self.data.getVar('BBLAYERS').split() + + if not bblayers: + # It's blank! Nothing to process... + return self.bblayers + + collections = self.data.getVar('BBFILE_COLLECTIONS') + layerconfs = self.data.varhistory.get_variable_items_files('BBFILE_COLLECTIONS', self.data) + bbfile_collections = {layer: os.path.dirname(os.path.dirname(path)) for layer, path in layerconfs.items()} + + (_, bb_branch, _, _) = self._get_bitbake_info() + + for branch in branches: + branchId += 1 + self.bblayers.branches[branchId] = layerindexlib.Branch(self.bblayers, None) + self.bblayers.branches[branchId].define_data(branchId, branch, bb_branch) + + for entry in collections.split(): + layerpath = entry + if entry in bbfile_collections: + layerpath = bbfile_collections[entry] + + priority = int(self.data.getVar('BBFILE_PRIORITY_%s' % entry) or '0') + layername = self.data.getVar('BBLAYERS_LAYERINDEX_NAME_%s' % entry) or os.path.basename(layerpath) + layerversion = self.data.getVar('LAYERVERSION_%s' % entry) or "" + layerurl = self._handle_git_remote(layerpath) + + layersubdir = "" + layerrev = "" + layerbranch = "" + + if os.path.isdir(layerpath): + layerbasepath = self._run_command('git rev-parse --show-toplevel', layerpath, default=layerpath) + if os.path.abspath(layerpath) != os.path.abspath(layerbasepath): + layersubdir = os.path.abspath(layerpath)[len(layerbasepath) + 1:] + + layerbranch = self._run_command('git rev-parse --abbrev-ref HEAD', layerpath, default="") + layerrev = self._run_command('git rev-parse HEAD', layerpath, default="") + + for remotes in self._run_command('git remote -v', layerpath, default="").split("\n"): + remote = remotes.split("\t")[1].split(" ")[0] + if "(fetch)" == remotes.split("\t")[1].split(" ")[1]: + layerurl = self._handle_git_remote(remote) + break + + layerItemId += 1 + self.bblayers.layerItems[layerItemId] = layerindexlib.LayerItem(self.bblayers, None) + self.bblayers.layerItems[layerItemId].define_data(layerItemId, layername, description=layerpath, vcs_url=layerurl) + # The following two entries are unique to cooker layerItems, + # This means they usually will not exist from remote indexes + self.bblayers.layerItems[layerItemId].priority = priority + self.bblayers.layerItems[layerItemId].localpath = layerpath + + for branchId in self.bblayers.branches: + layerBranchId += 1 + self.bblayers.layerBranches[layerBranchId] = layerindexlib.LayerBranch(self.bblayers, None) + self.bblayers.layerBranches[layerBranchId].define_data(layerBranchId, entry, layerversion, layerItemId, branchId, + vcs_subdir=layersubdir, vcs_last_rev=layerrev, actual_branch=layerbranch) + + return self.bblayers + + + def load_layerDependencies(self): + """Augment previously loaded data by adding in layerDependency info""" + if not self.bblayers: + raise BBLayerLibException("load_bblayers doesn't appear to have been called first") + + layerDependencyId = 0 + self.bblayers.layerDependencies = {} + for layerBranchId in self.bblayers.layerBranches: + branchName = self.bblayers.layerBranches[layerBranchId].branch.name + collection = self.bblayers.layerBranches[layerBranchId].collection + + def add_dependency(layerDependencyId, index, deps, required): + try: + depDict = bb.utils.explode_dep_versions2(deps) + except bb.utils.VersionStringException as vse: + bb.fatal('Error parsing LAYERDEPENDS_%s: %s' % (c, str(vse))) + + for dep, oplist in list(depDict.items()): + # We need to search ourselves, so use the _ version... + depLayerBranch = index.find_collection(dep, branches=[branchName]) + if not depLayerBranch: + # Missing dependency?! + logger.error('Missing dependency %s (%s)' % (dep, branchName)) + continue + + # We assume that the oplist matches... + layerDependencyId += 1 + layerDependency = layerindexlib.LayerDependency(index, None) + layerDependency.define_data(id=layerDependencyId, + required=required, layerbranch=layerBranchId, + dependency=depLayerBranch.layer_id) + + logger.debug(1, '%s requires %s' % (layerDependency.layer.name, layerDependency.dependency.name)) + index.add_element("layerDependencies", [layerDependency]) + + return layerDependencyId + + deps = self.data.getVar("LAYERDEPENDS_%s" % collection) + if deps: + layerDependencyId = add_dependency(layerDependencyId, self.bblayers, deps, True) + + deps = self.data.getVar("LAYERRECOMMENDS_%s" % collection) + if deps: + layerDependencyId = add_dependency(layerDependencyId, self.bblayers, deps, False) + + return self.bblayers + + def load_recipes(self, tinfoil, full=False): + """Augment the recipe information for the layers""" + + # Assume at some point we'll implement the 'bb' way as well... + if not tinfoil: + raise BBLayerLibException("You must pass a valid tinfoil to parse recipe information") + + if not self.bblayers: + raise BBLayerLibException("load_bblayers doesn't appear to have been called first") + + recipeId = 0 + self.bblayers.recipes = {} + + if tinfoil: + pkg_pn = tinfoil.cooker.recipecaches[''].pkg_pn + (latest_versions, preferred_versions) = tinfoil.find_providers() + allproviders = tinfoil.get_all_providers() + skiplist = list(tinfoil.cooker.skiplist.keys()) + + for fn in skiplist: + recipe_parts = os.path.splitext(os.path.basename(fn))[0].split('_') + p = recipe_parts[0] + if len(recipe_parts) > 1: + ver = (None, recipe_parts[1], None) + else: + ver = (None, 'unknown', None) + allproviders[p].append((ver, fn)) + if not p in pkg_pn: + pkg_pn[p] = 'dummy' + preferred_versions[p] = (ver, fn) + + global_inherit = (self.data.getVar('INHERIT') or "").split() + cls_re = re.compile('classes/') + + for pn in pkg_pn: + for ((pe, pv, pr), fpath) in allproviders[pn]: + realfn = bb.cache.virtualfn2realfn(fpath) + + filepath = os.path.dirname(realfn[0]) + filename = os.path.basename(realfn[0]) + + # Compute inherits, excluding global + recipe_inherits = tinfoil.cooker_data.inherits.get(realfn[0], []) + inherits = [] + for cls in recipe_inherits: + if cls_re.match(cls): + continue + classname = os.path.splitext(os.path.basename(cls))[0] + if classname in global_inherit: + continue + inherits.append(classname) + + if not full: + recipe_data = self.data.createCopy() + recipe_data.setVar("PN", pn) + recipe_data.setVar("PV", pv) + else: + recipe_data = tinfoil.parse_recipe_file(fpath, appends=False) + + summary = recipe_data.getVar('SUMMARY') or '' + description = recipe_data.getVar('DESCRIPTION') or '' + section = recipe_data.getVar('SECTION') or '' + license = recipe_data.getVar('LICENSE') or '' + homepage = recipe_data.getVar('HOMEPAGE') or '' + bugtracker = recipe_data.getVar('BUGTRACKER') or '' + provides = recipe_data.getVar('PROVIDES') or '' + bbclassextend = recipe_data.getVar('BBCLASSEXTEND') or '' + blacklisted = recipe_data.getVarFlag('PNBLACKLIST', pn) or '' + + layer = bb.utils.get_file_layer(realfn[0], self.data) + + depBranchId = self.bblayers.find_collection(layer) + + recipeId += 1 + recipe = layerindexlib.Recipe(self.bblayers, None) + recipe.define_data(id=recipeId, + filename=filename, filepath=filepath, + pn=pn, pv=pv, + summary=summary, description=description, section=section, + license=license, homepage=homepage, bugtracker=bugtracker, + provides=provides, bbclassextend=bbclassextend, inherits=' '.join(inherits), + blacklisted=blacklisted, layerbranch=depBranchId) + + self.bblayers.add_element("recipes", [recipe]) + + return self.bblayers + + def load_machines(self): + """Augment the machine information for the layers""" + if not self.bblayers: + raise BBLayerLibException("load_bblayers doesn't appear to have been called first") + + machineId = 0 + self.bblayers.machines = {} + + for layerBranchId in self.bblayers.layerBranches: + # load_bblayers uses the description to cache the actual path... + machine_path = self.bblayers.layerBranches[layerBranchId].getDescription() + machine_path = os.path.join(machine_path, 'conf/machine') + if os.path.isdir(machine_path): + for (dirpath, _, filenames) in os.walk(machine_path): + # Ignore subdirs... + if not dirpath.endswith('conf/machine'): + continue + for fname in filenames: + if fname.endswith('.conf'): + machineId += 1 + machine = layerindexlib.Machine(self.bblayers, None) + machine.define_data(id=machineId, name=fname[:-5], + description=fname[:-5], + layerbranch=layerBranchId) + + self.bblayers.add_element("machines", [machine]) + + return self.bblayers + + def load_distros(self): + """Augment the distro information for the layers""" + if not self.bblayers: + raise BBLayerLibException("load_bblayers doesn't appear to have been called first") + + distroId = 0 + self.bblayers.distros = {} + + for layerBranchId in self.bblayers.layerBranches: + # load_bblayers uses the description to cache the actual path... + distro_path = self.bblayers.layerBranches[layerBranchId].getDescription() + distro_path = os.path.join(distro_path, 'conf/distro') + if os.path.isdir(distro_path): + for (dirpath, _, filenames) in os.walk(distro_path): + # Ignore subdirs... + if not dirpath.endswith('conf/distro'): + continue + for fname in filenames: + if fname.endswith('.conf'): + distroId += 1 + distro = layerindexlib.distro(self.bblayers, None) + distro.define_data(id=distroId, name=fname[:-5], + description=fname[:-5], + layerbranch=layerBranchId) + + self.bblayers.add_element("distros", [distro]) + + return self.bblayers diff --git a/lib/bblayerlib/plugin.py b/lib/bblayerlib/plugin.py new file mode 100644 index 000000000..c6b78741f --- /dev/null +++ b/lib/bblayerlib/plugin.py @@ -0,0 +1,58 @@ +# Copyright (C) 2016-2018 Wind River Systems, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# 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 + +# The file contains: +# Plugin base class + +import argparse +import logging +import os +import bb.msg + +logger = logging.getLogger('BitBake.bblayerlib.plugin') + +class BBLayerLibPluginException(Exception): + """LayerIndex Generic Exception""" + def __init__(self, message): + self.msg = message + Exception.__init__(self, message) + + def __str__(self): + return self.msg + +class BBLayerLibPluginUrlError(LayerIndexPluginException): + """Exception raised when a plugin does not support a given URL type""" + def __init__(self, plugin, url): + msg = "%s does not support %s:" % (plugin, url) + self.plugin = plugin + self.url = url + LayerIndexPluginException.__init__(self, msg) + +class BBLayerPlugin(): + def __init__(self): + self.type = None + + def init(self, layerindex): + self.layerindex = layerindex + + def plugin_type(self): + return self.type + + def load_index(self, uri): + raise NotImplementedError('load_index is not implemented') + + def store_index(self, uri, index): + raise NotImplementedError('store_index is not implemented') + diff --git a/lib/bblayers/query.py b/lib/bblayers/query.py index 9294dfa88..e15fced3c 100644 --- a/lib/bblayers/query.py +++ b/lib/bblayers/query.py @@ -11,6 +11,8 @@ from bblayers.common import LayerPlugin logger = logging.getLogger('bitbake-layers') +import bblayerlib + def plugin_init(plugins): return QueryPlugin() @@ -19,11 +21,16 @@ def plugin_init(plugins): class QueryPlugin(LayerPlugin): def do_show_layers(self, args): """show current configured layers.""" + bblayers = bblayerlib.BBLayers(self.tinfoil.config_data) + + index = bblayers.load_bblayers() + logger.plain("%s %s %s" % ("layer".ljust(20), "path".ljust(40), "priority")) logger.plain('=' * 74) - for layer, _, regex, pri in self.tinfoil.cooker.bbfile_config_priorities: - layerdir = self.bbfile_collections.get(layer, None) - layername = self.get_layer_name(layerdir) + for id, layerbranch in index.layerBranches.items(): + layername = layerbranch.layer.name + layerdir = layerbranch.layer.localpath + pri = layerbranch.layer.priority logger.plain("%s %s %d" % (layername.ljust(20), layerdir.ljust(40), pri)) def version_str(self, pe, pv, pr = None): @@ -119,6 +126,16 @@ skipped recipes will also be listed, with a " (skipped)" suffix. logger.error('No class named %s found in BBPATH', classfile) sys.exit(1) + bblayers = bblayerlib.BBLayers(self.tinfoil.config_data) + index = bblayers.load_bblayers() + index = bblayers.load_recipes(tinfoil=self.tinfoil, full=False) + + for id, recipe in index.recipes.items(): + logger.plain('%s' % (recipe._data)) + + + sys.exit(1) + pkg_pn = self.tinfoil.cooker.recipecaches[''].pkg_pn (latest_versions, preferred_versions) = self.tinfoil.find_providers() allproviders = self.tinfoil.get_all_providers() diff --git a/lib/layerindexlib/cooker.py b/lib/layerindexlib/cooker.py index 248a59775..08bed376b 100644 --- a/lib/layerindexlib/cooker.py +++ b/lib/layerindexlib/cooker.py @@ -39,121 +39,6 @@ class CookerPlugin(layerindexlib.plugin.IndexPlugin): self.ui_module = None self.server = None - def _run_command(self, command, path, default=None): - try: - result, _ = bb.process.run(command, cwd=path) - result = result.strip() - except bb.process.ExecutionError: - result = default - return result - - def _handle_git_remote(self, remote): - if "://" not in remote: - if ':' in remote: - # This is assumed to be ssh - remote = "ssh://" + remote - else: - # This is assumed to be a file path - remote = "file://" + remote - return remote - - def _get_bitbake_info(self): - """Return a tuple of bitbake information""" - - # Our path SHOULD be .../bitbake/lib/layerindex/cooker.py - bb_path = os.path.dirname(__file__) # .../bitbake/lib/layerindex/cooker.py - bb_path = os.path.dirname(bb_path) # .../bitbake/lib/layerindex - bb_path = os.path.dirname(bb_path) # .../bitbake/lib - bb_path = os.path.dirname(bb_path) # .../bitbake - bb_path = self._run_command('git rev-parse --show-toplevel', os.path.dirname(__file__), default=bb_path) - bb_branch = self._run_command('git rev-parse --abbrev-ref HEAD', bb_path, default="") - bb_rev = self._run_command('git rev-parse HEAD', bb_path, default="") - for remotes in self._run_command('git remote -v', bb_path, default="").split("\n"): - remote = remotes.split("\t")[1].split(" ")[0] - if "(fetch)" == remotes.split("\t")[1].split(" ")[1]: - bb_remote = self._handle_git_remote(remote) - break - else: - bb_remote = self._handle_git_remote(bb_path) - - return (bb_remote, bb_branch, bb_rev, bb_path) - - def _load_bblayers(self, branches=None): - """Load the BBLAYERS and related collection information""" - - d = self.layerindex.data - - if not branches: - raise LayerIndexFetchError("No branches specified for _load_bblayers!") - - index = layerindexlib.LayerIndexObj() - - branchId = 0 - index.branches = {} - - layerItemId = 0 - index.layerItems = {} - - layerBranchId = 0 - index.layerBranches = {} - - bblayers = d.getVar('BBLAYERS').split() - - if not bblayers: - # It's blank! Nothing to process... - return index - - collections = d.getVar('BBFILE_COLLECTIONS') - layerconfs = d.varhistory.get_variable_items_files('BBFILE_COLLECTIONS', d) - bbfile_collections = {layer: os.path.dirname(os.path.dirname(path)) for layer, path in layerconfs.items()} - - (_, bb_branch, _, _) = self._get_bitbake_info() - - for branch in branches: - branchId += 1 - index.branches[branchId] = layerindexlib.Branch(index, None) - index.branches[branchId].define_data(branchId, branch, bb_branch) - - for entry in collections.split(): - layerpath = entry - if entry in bbfile_collections: - layerpath = bbfile_collections[entry] - - layername = d.getVar('BBLAYERS_LAYERINDEX_NAME_%s' % entry) or os.path.basename(layerpath) - layerversion = d.getVar('LAYERVERSION_%s' % entry) or "" - layerurl = self._handle_git_remote(layerpath) - - layersubdir = "" - layerrev = "" - layerbranch = "" - - if os.path.isdir(layerpath): - layerbasepath = self._run_command('git rev-parse --show-toplevel', layerpath, default=layerpath) - if os.path.abspath(layerpath) != os.path.abspath(layerbasepath): - layersubdir = os.path.abspath(layerpath)[len(layerbasepath) + 1:] - - layerbranch = self._run_command('git rev-parse --abbrev-ref HEAD', layerpath, default="") - layerrev = self._run_command('git rev-parse HEAD', layerpath, default="") - - for remotes in self._run_command('git remote -v', layerpath, default="").split("\n"): - remote = remotes.split("\t")[1].split(" ")[0] - if "(fetch)" == remotes.split("\t")[1].split(" ")[1]: - layerurl = self._handle_git_remote(remote) - break - - layerItemId += 1 - index.layerItems[layerItemId] = layerindexlib.LayerItem(index, None) - index.layerItems[layerItemId].define_data(layerItemId, layername, description=layerpath, vcs_url=layerurl) - - for branchId in index.branches: - layerBranchId += 1 - index.layerBranches[layerBranchId] = layerindexlib.LayerBranch(index, None) - index.layerBranches[layerBranchId].define_data(layerBranchId, entry, layerversion, layerItemId, branchId, - vcs_subdir=layersubdir, vcs_last_rev=layerrev, actual_branch=layerbranch) - - return index - - def load_index(self, url, load): """ Fetches layer information from a build configuration. @@ -182,7 +67,9 @@ class CookerPlugin(layerindexlib.plugin.IndexPlugin): logger.debug(1, "Loading cooker data branches %s" % branches) - index = self._load_bblayers(branches=branches) + import bblayerlib + bblayers = bblayerlib.BBLayers(d) + index = bblayers.load_bblayers(branches=branches) index.config = {} index.config['TYPE'] = self.type @@ -198,144 +85,17 @@ class CookerPlugin(layerindexlib.plugin.IndexPlugin): index.config['BRANCH'] = branches - # ("layerDependencies", layerindexlib.LayerDependency) - layerDependencyId = 0 - if "layerDependencies" in load: - index.layerDependencies = {} - for layerBranchId in index.layerBranches: - branchName = index.layerBranches[layerBranchId].branch.name - collection = index.layerBranches[layerBranchId].collection - - def add_dependency(layerDependencyId, index, deps, required): - try: - depDict = bb.utils.explode_dep_versions2(deps) - except bb.utils.VersionStringException as vse: - bb.fatal('Error parsing LAYERDEPENDS_%s: %s' % (c, str(vse))) - - for dep, oplist in list(depDict.items()): - # We need to search ourselves, so use the _ version... - depLayerBranch = index.find_collection(dep, branches=[branchName]) - if not depLayerBranch: - # Missing dependency?! - logger.error('Missing dependency %s (%s)' % (dep, branchName)) - continue - - # We assume that the oplist matches... - layerDependencyId += 1 - layerDependency = layerindexlib.LayerDependency(index, None) - layerDependency.define_data(id=layerDependencyId, - required=required, layerbranch=layerBranchId, - dependency=depLayerBranch.layer_id) + if 'layerDependencies' in load: + index = bblayers.load_layerDependencies() - logger.debug(1, '%s requires %s' % (layerDependency.layer.name, layerDependency.dependency.name)) - index.add_element("layerDependencies", [layerDependency]) - - return layerDependencyId - - deps = d.getVar("LAYERDEPENDS_%s" % collection) - if deps: - layerDependencyId = add_dependency(layerDependencyId, index, deps, True) - - deps = d.getVar("LAYERRECOMMENDS_%s" % collection) - if deps: - layerDependencyId = add_dependency(layerDependencyId, index, deps, False) - - # Need to load recipes here (requires cooker access) - recipeId = 0 - ## TODO: NOT IMPLEMENTED - # The code following this is an example of what needs to be - # implemented. However, it does not work as-is. if False and 'recipes' in load: - index.recipes = {} - - ret = self.ui_module.main(self.server_connection.connection, self.server_connection.events, config_params) - - all_versions = self._run_command('allProviders') + # Requires server access, which we don't have + index = bblayers.load_recipes(server) - all_versions_list = defaultdict(list, all_versions) - for pn in all_versions_list: - for ((pe, pv, pr), fpath) in all_versions_list[pn]: - realfn = bb.cache.virtualfn2realfn(fpath) - - filepath = os.path.dirname(realfn[0]) - filename = os.path.basename(realfn[0]) - - # This is all HORRIBLY slow, and likely unnecessary - #dscon = self._run_command('parseRecipeFile', fpath, False, []) - #connector = myDataStoreConnector(self, dscon.dsindex) - #recipe_data = bb.data.init() - #recipe_data.setVar('_remote_data', connector) - - #summary = recipe_data.getVar('SUMMARY') - #description = recipe_data.getVar('DESCRIPTION') - #section = recipe_data.getVar('SECTION') - #license = recipe_data.getVar('LICENSE') - #homepage = recipe_data.getVar('HOMEPAGE') - #bugtracker = recipe_data.getVar('BUGTRACKER') - #provides = recipe_data.getVar('PROVIDES') - - layer = bb.utils.get_file_layer(realfn[0], self.config_data) - - depBranchId = collection_layerbranch[layer] - - recipeId += 1 - recipe = layerindexlib.Recipe(index, None) - recipe.define_data(id=recipeId, - filename=filename, filepath=filepath, - pn=pn, pv=pv, - summary=pn, description=pn, section='?', - license='?', homepage='?', bugtracker='?', - provides='?', bbclassextend='?', inherits='?', - blacklisted='?', layerbranch=depBranchId) - - index = addElement("recipes", [recipe], index) - - # ("machines", layerindexlib.Machine) - machineId = 0 if 'machines' in load: - index.machines = {} - - for layerBranchId in index.layerBranches: - # load_bblayers uses the description to cache the actual path... - machine_path = index.layerBranches[layerBranchId].getDescription() - machine_path = os.path.join(machine_path, 'conf/machine') - if os.path.isdir(machine_path): - for (dirpath, _, filenames) in os.walk(machine_path): - # Ignore subdirs... - if not dirpath.endswith('conf/machine'): - continue - for fname in filenames: - if fname.endswith('.conf'): - machineId += 1 - machine = layerindexlib.Machine(index, None) - machine.define_data(id=machineId, name=fname[:-5], - description=fname[:-5], - layerbranch=collection_layerbranch[entry]) + index = bblayers.load_machines() - index.add_element("machines", [machine]) - - # ("distros", layerindexlib.Distro) - distroId = 0 if 'distros' in load: - index.distros = {} - - for layerBranchId in index.layerBranches: - # load_bblayers uses the description to cache the actual path... - distro_path = index.layerBranches[layerBranchId].getDescription() - distro_path = os.path.join(distro_path, 'conf/distro') - if os.path.isdir(distro_path): - for (dirpath, _, filenames) in os.walk(distro_path): - # Ignore subdirs... - if not dirpath.endswith('conf/distro'): - continue - for fname in filenames: - if fname.endswith('.conf'): - distroId += 1 - distro = layerindexlib.Distro(index, None) - distro.define_data(id=distroId, name=fname[:-5], - description=fname[:-5], - layerbranch=collection_layerbranch[entry]) - - index.add_element("distros", [distro]) + index = bblayers.load_distros() return index -- cgit 1.2.3-korg