summaryrefslogtreecommitdiffstats
path: root/lib/bbsetup
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bbsetup')
-rw-r--r--lib/bbsetup/__init__.py2
-rw-r--r--lib/bbsetup/common.py31
-rw-r--r--lib/bbsetup/query.py75
3 files changed, 108 insertions, 0 deletions
diff --git a/lib/bbsetup/__init__.py b/lib/bbsetup/__init__.py
new file mode 100644
index 000000000..3ad9513f4
--- /dev/null
+++ b/lib/bbsetup/__init__.py
@@ -0,0 +1,2 @@
+from pkgutil import extend_path
+__path__ = extend_path(__path__, __name__)
diff --git a/lib/bbsetup/common.py b/lib/bbsetup/common.py
new file mode 100644
index 000000000..eff7624af
--- /dev/null
+++ b/lib/bbsetup/common.py
@@ -0,0 +1,31 @@
+import argparse
+import logging
+import os
+import bb.msg
+
+logger = logging.getLogger('BitBake.BBSetup.common')
+
+
+class SetupPlugin():
+ def __init__(self):
+ data = None
+
+ def init(self, d):
+ self.data = d
+
+ @staticmethod
+ def add_command(subparsers, cmdname, function, *args, **kwargs):
+ """Convert docstring for function to help."""
+ logger.debug(1, 'Adding command: %s' % cmdname)
+ docsplit = function.__doc__.splitlines()
+ help = docsplit[0]
+ if len(docsplit) > 1:
+ desc = '\n'.join(docsplit[1:])
+ else:
+ desc = help
+ subparser = subparsers.add_parser(cmdname, *args, help=help, description=desc, formatter_class=argparse.RawTextHelpFormatter, **kwargs)
+ subparser.set_defaults(func=function)
+ return subparser
+
+ def get_layer_name(self, layerdir):
+ return os.path.basename(layerdir.rstrip(os.sep))
diff --git a/lib/bbsetup/query.py b/lib/bbsetup/query.py
new file mode 100644
index 000000000..a7886ef36
--- /dev/null
+++ b/lib/bbsetup/query.py
@@ -0,0 +1,75 @@
+import collections
+import fnmatch
+import logging
+import sys
+import os
+import re
+
+import bb.utils
+
+from bbsetup.common import SetupPlugin
+
+import layers.layerindex
+
+logger = logging.getLogger('BitBake.BBSetup.query')
+
+def plugin_init(plugins):
+ return QueryPlugin()
+
+
+class QueryPlugin(SetupPlugin):
+ def do_query(self, args):
+ """Query the layer index"""
+ lindex = layers.layerindex.LayerIndex(self.data)
+
+ loadMask = ""
+ if args.layerdependencies:
+ loadMask += " layerDependencies"
+
+ if args.recipes:
+ loadMask += " recipes"
+
+ if args.machines:
+ loadMask += " machines"
+
+ if args.distros:
+ loadMask += " distros"
+
+ lindex.load_layerindex(self.data.getVar('BBLAYERINDEX_URI'), load=loadMask)
+
+ if args.distros:
+ lindex.list_obj('distros')
+
+ if args.machines:
+ lindex.list_obj('machines')
+
+ if args.branches:
+ lindex.list_obj('branches')
+
+ if args.layers:
+ lindex.list_obj('layerItems')
+
+ if args.layerbranches:
+ lindex.list_obj('layerBranches')
+
+ if args.layerdependencies:
+ lindex.list_obj('layerDependencies')
+
+ if args.recipes:
+ lindex.list_obj('recipes')
+
+ #lindex.store_layerindex('file:///tmp/wr-index;type=restapi', lindex.lindex[0])
+ #lindex.store_layerindex('file:///tmp/oe-index;type=restapi', lindex.lindex[1])
+ #lindex.store_layerindex('file:///tmp/test-api.json;type=restapi', lindex.lindex[0])
+
+ def register_commands(self, sp):
+ query = self.add_command(sp, 'query', self.do_query)
+
+ query.add_argument('--distros', help='List all available distro values', action='store_true')
+ query.add_argument('--machines', help='List all available machine values', action='store_true')
+ query.add_argument('--branches', help='List all available branch values', action='store_true')
+ query.add_argument('--layers', help='List all available layers', action='store_true')
+ query.add_argument('--layerbranches', help='List all available layerbranches', action='store_true')
+ query.add_argument('--layerdependencies', help='List all available layerdependencies', action='store_true')
+ query.add_argument('--recipes', help='List all available recipe values', action='store_true')
+