diff options
Diffstat (limited to 'bitbake/lib/bblayers')
-rw-r--r-- | bitbake/lib/bblayers/__init__.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bblayers/action.py | 15 | ||||
-rw-r--r-- | bitbake/lib/bblayers/common.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bblayers/layerindex.py | 43 | ||||
-rw-r--r-- | bitbake/lib/bblayers/query.py | 58 |
5 files changed, 91 insertions, 29 deletions
diff --git a/bitbake/lib/bblayers/__init__.py b/bitbake/lib/bblayers/__init__.py index 4e7c09da04..78efd29750 100644 --- a/bitbake/lib/bblayers/__init__.py +++ b/bitbake/lib/bblayers/__init__.py @@ -1,4 +1,6 @@ # +# Copyright BitBake Contributors +# # SPDX-License-Identifier: GPL-2.0-only # diff --git a/bitbake/lib/bblayers/action.py b/bitbake/lib/bblayers/action.py index f05f5d330f..a8f2699335 100644 --- a/bitbake/lib/bblayers/action.py +++ b/bitbake/lib/bblayers/action.py @@ -1,4 +1,6 @@ # +# Copyright BitBake Contributors +# # SPDX-License-Identifier: GPL-2.0-only # @@ -9,6 +11,7 @@ import shutil import sys import tempfile +from bb.cookerdata import findTopdir import bb.utils from bblayers.common import LayerPlugin @@ -35,7 +38,7 @@ class ActionPlugin(LayerPlugin): sys.stderr.write("Specified layer directory %s doesn't contain a conf/layer.conf file\n" % layerdir) return 1 - bblayers_conf = os.path.join('conf', 'bblayers.conf') + bblayers_conf = os.path.join(findTopdir(),'conf', 'bblayers.conf') if not os.path.exists(bblayers_conf): sys.stderr.write("Unable to find bblayers.conf\n") return 1 @@ -47,13 +50,15 @@ class ActionPlugin(LayerPlugin): try: notadded, _ = bb.utils.edit_bblayers_conf(bblayers_conf, layerdirs, None) + self.tinfoil.modified_files() if not (args.force or notadded): try: self.tinfoil.run_command('parseConfiguration') except (bb.tinfoil.TinfoilUIException, bb.BBHandledException): # Restore the back up copy of bblayers.conf shutil.copy2(backup, bblayers_conf) - bb.fatal("Parse failure with the specified layer added, aborting.") + self.tinfoil.modified_files() + bb.fatal("Parse failure with the specified layer added, exiting.") else: for item in notadded: sys.stderr.write("Specified layer %s is already in BBLAYERS\n" % item) @@ -63,7 +68,7 @@ class ActionPlugin(LayerPlugin): def do_remove_layer(self, args): """Remove one or more layers from bblayers.conf.""" - bblayers_conf = os.path.join('conf', 'bblayers.conf') + bblayers_conf = os.path.join(findTopdir() ,'conf', 'bblayers.conf') if not os.path.exists(bblayers_conf): sys.stderr.write("Unable to find bblayers.conf\n") return 1 @@ -78,6 +83,7 @@ class ActionPlugin(LayerPlugin): layerdir = os.path.abspath(item) layerdirs.append(layerdir) (_, notremoved) = bb.utils.edit_bblayers_conf(bblayers_conf, None, layerdirs) + self.tinfoil.modified_files() if notremoved: for item in notremoved: sys.stderr.write("No layers matching %s found in BBLAYERS\n" % item) @@ -237,6 +243,9 @@ build results (as the layer priority order has effectively changed). if not entry_found: logger.warning("File %s does not match the flattened layer's BBFILES setting, you may need to edit conf/layer.conf or move the file elsewhere" % f1full) + self.tinfoil.modified_files() + + def get_file_layer(self, filename): layerdir = self.get_file_layerdir(filename) if layerdir: diff --git a/bitbake/lib/bblayers/common.py b/bitbake/lib/bblayers/common.py index 6c76ef3505..f7b9cee371 100644 --- a/bitbake/lib/bblayers/common.py +++ b/bitbake/lib/bblayers/common.py @@ -1,4 +1,6 @@ # +# Copyright BitBake Contributors +# # SPDX-License-Identifier: GPL-2.0-only # diff --git a/bitbake/lib/bblayers/layerindex.py b/bitbake/lib/bblayers/layerindex.py index b2f27b21ee..ba91fac669 100644 --- a/bitbake/lib/bblayers/layerindex.py +++ b/bitbake/lib/bblayers/layerindex.py @@ -1,4 +1,6 @@ # +# Copyright BitBake Contributors +# # SPDX-License-Identifier: GPL-2.0-only # @@ -47,6 +49,31 @@ class LayerIndexPlugin(ActionPlugin): else: logger.plain("Repository %s needs to be fetched" % url) return subdir, layername, layerdir + elif os.path.exists(repodir) and branch: + """ + If the repo is already cloned, ensure it is on the correct branch, + switching branches if necessary and possible. + """ + base_cmd = ['git', '--git-dir=%s/.git' % repodir, '--work-tree=%s' % repodir] + cmd = base_cmd + ['branch'] + completed_proc = subprocess.run(cmd, text=True, capture_output=True) + if completed_proc.returncode: + logger.error("Unable to validate repo %s (%s)" % (repodir, stderr)) + return None, None, None + else: + if branch != completed_proc.stdout[2:-1]: + cmd = base_cmd + ['status', '--short'] + completed_proc = subprocess.run(cmd, text=True, capture_output=True) + if completed_proc.stdout.count('\n') != 0: + logger.warning("There are uncommitted changes in repo %s" % repodir) + cmd = base_cmd + ['checkout', branch] + completed_proc = subprocess.run(cmd, text=True, capture_output=True) + if completed_proc.returncode: + # Could be due to original shallow clone on a different branch for example + logger.error("Unable to automatically switch %s to desired branch '%s' (%s)" + % (repodir, branch, completed_proc.stderr)) + return None, None, None + return subdir, layername, layerdir elif os.path.exists(layerdir): return subdir, layername, layerdir else: @@ -159,12 +186,17 @@ class LayerIndexPlugin(ActionPlugin): logger.plain(' recommended by: %s' % ' '.join(recommendedby)) if dependencies: - fetchdir = self.tinfoil.config_data.getVar('BBLAYERS_FETCH_DIR') - if not fetchdir: - logger.error("Cannot get BBLAYERS_FETCH_DIR") - return 1 + if args.fetchdir: + fetchdir = args.fetchdir + else: + fetchdir = self.tinfoil.config_data.getVar('BBLAYERS_FETCH_DIR') + if not fetchdir: + logger.error("Cannot get BBLAYERS_FETCH_DIR") + return 1 + if not os.path.exists(fetchdir): os.makedirs(fetchdir) + addlayers = [] for deplayerbranch in dependencies: @@ -206,6 +238,8 @@ class LayerIndexPlugin(ActionPlugin): """ args.show_only = True args.ignore = [] + args.fetchdir = "" + args.shallow = True self.do_layerindex_fetch(args) def register_commands(self, sp): @@ -214,6 +248,7 @@ class LayerIndexPlugin(ActionPlugin): parser_layerindex_fetch.add_argument('-b', '--branch', help='branch name to fetch') parser_layerindex_fetch.add_argument('-s', '--shallow', help='do only shallow clones (--depth=1)', action='store_true') parser_layerindex_fetch.add_argument('-i', '--ignore', help='assume the specified layers do not need to be fetched/added (separate multiple layers with commas, no spaces)', metavar='LAYER') + parser_layerindex_fetch.add_argument('-f', '--fetchdir', help='directory to fetch the layer(s) into (will be created if it does not exist)') parser_layerindex_fetch.add_argument('layername', nargs='+', help='layer to fetch') parser_layerindex_show_depends = self.add_command(sp, 'layerindex-show-depends', self.do_layerindex_show_depends, parserecipes=False) diff --git a/bitbake/lib/bblayers/query.py b/bitbake/lib/bblayers/query.py index 947422a72f..bfc18a7593 100644 --- a/bitbake/lib/bblayers/query.py +++ b/bitbake/lib/bblayers/query.py @@ -1,4 +1,6 @@ # +# Copyright BitBake Contributors +# # SPDX-License-Identifier: GPL-2.0-only # @@ -27,12 +29,12 @@ class QueryPlugin(LayerPlugin): def do_show_layers(self, args): """show current configured layers.""" - logger.plain("%s %s %s" % ("layer".ljust(20), "path".ljust(40), "priority")) - logger.plain('=' * 74) + logger.plain("%s %s %s" % ("layer".ljust(20), "path".ljust(70), "priority")) + logger.plain('=' * 104) for layer, _, regex, pri in self.tinfoil.cooker.bbfile_config_priorities: layerdir = self.bbfile_collections.get(layer, None) - layername = self.get_layer_name(layerdir) - logger.plain("%s %s %d" % (layername.ljust(20), layerdir.ljust(40), pri)) + layername = layer + logger.plain("%s %s %s" % (layername.ljust(20), layerdir.ljust(70), pri)) def version_str(self, pe, pv, pr = None): verstr = "%s" % pv @@ -55,11 +57,12 @@ are overlayed will also be listed, with a " (skipped)" suffix. # Check for overlayed .bbclass files classes = collections.defaultdict(list) for layerdir in self.bblayers: - classdir = os.path.join(layerdir, 'classes') - if os.path.exists(classdir): - for classfile in os.listdir(classdir): - if os.path.splitext(classfile)[1] == '.bbclass': - classes[classfile].append(classdir) + for c in ["classes-global", "classes-recipe", "classes"]: + classdir = os.path.join(layerdir, c) + if os.path.exists(classdir): + for classfile in os.listdir(classdir): + if os.path.splitext(classfile)[1] == '.bbclass': + classes[classfile].append(classdir) # Locating classes and other files is a bit more complicated than recipes - # layer priority is not a factor; instead BitBake uses the first matching @@ -122,9 +125,14 @@ skipped recipes will also be listed, with a " (skipped)" suffix. if inherits: bbpath = str(self.tinfoil.config_data.getVar('BBPATH')) for classname in inherits: - classfile = 'classes/%s.bbclass' % classname - if not bb.utils.which(bbpath, classfile, history=False): - logger.error('No class named %s found in BBPATH', classfile) + found = False + for c in ["classes-global", "classes-recipe", "classes"]: + cfile = c + '/%s.bbclass' % classname + if bb.utils.which(bbpath, cfile, history=False): + found = True + break + if not found: + logger.error('No class named %s found in BBPATH', classname) sys.exit(1) pkg_pn = self.tinfoil.cooker.recipecaches[mc].pkg_pn @@ -154,7 +162,7 @@ skipped recipes will also be listed, with a " (skipped)" suffix. def print_item(f, pn, ver, layer, ispref): if not selected_layer or layer == selected_layer: if not bare and f in skiplist: - skipped = ' (skipped)' + skipped = ' (skipped: %s)' % self.tinfoil.cooker.skiplist[f].skipreason else: skipped = '' if show_filenames: @@ -172,7 +180,7 @@ skipped recipes will also be listed, with a " (skipped)" suffix. logger.plain(" %s %s%s", layer.ljust(20), ver, skipped) global_inherit = (self.tinfoil.config_data.getVar('INHERIT') or "").split() - cls_re = re.compile('classes/') + cls_re = re.compile('classes.*/') preffiles = [] show_unique_pn = [] @@ -274,7 +282,10 @@ Lists recipes with the bbappends that apply to them as subitems. else: logger.plain('=== Appended recipes ===') - pnlist = list(self.tinfoil.cooker_data.pkg_pn.keys()) + + cooker_data = self.tinfoil.cooker.recipecaches[args.mc] + + pnlist = list(cooker_data.pkg_pn.keys()) pnlist.sort() appends = False for pn in pnlist: @@ -287,7 +298,7 @@ Lists recipes with the bbappends that apply to them as subitems. if not found: continue - if self.show_appends_for_pn(pn): + if self.show_appends_for_pn(pn, cooker_data, args.mc): appends = True if not args.pnspec and self.show_appends_for_skipped(): @@ -296,8 +307,10 @@ Lists recipes with the bbappends that apply to them as subitems. if not appends: logger.plain('No append files found') - def show_appends_for_pn(self, pn): - filenames = self.tinfoil.cooker_data.pkg_pn[pn] + def show_appends_for_pn(self, pn, cooker_data, mc): + filenames = cooker_data.pkg_pn[pn] + if mc: + pn = "mc:%s:%s" % (mc, pn) best = self.tinfoil.find_best_provider(pn) best_filename = os.path.basename(best[3]) @@ -405,7 +418,7 @@ NOTE: .bbappend files can impact the dependencies. self.check_cross_depends("RRECOMMENDS", layername, f, best, args.filenames, ignore_layers) # The inherit class - cls_re = re.compile('classes/') + cls_re = re.compile('classes.*/') if f in self.tinfoil.cooker_data.inherits: inherits = self.tinfoil.cooker_data.inherits[f] for cls in inherits: @@ -441,10 +454,10 @@ NOTE: .bbappend files can impact the dependencies. line = fnfile.readline() # The "require/include xxx" in conf/machine/*.conf, .inc and .bbclass - conf_re = re.compile(".*/conf/machine/[^\/]*\.conf$") - inc_re = re.compile(".*\.inc$") + conf_re = re.compile(r".*/conf/machine/[^\/]*\.conf$") + inc_re = re.compile(r".*\.inc$") # The "inherit xxx" in .bbclass - bbclass_re = re.compile(".*\.bbclass$") + bbclass_re = re.compile(r".*\.bbclass$") for layerdir in self.bblayers: layername = self.get_layer_name(layerdir) for dirpath, dirnames, filenames in os.walk(layerdir): @@ -522,6 +535,7 @@ NOTE: .bbappend files can impact the dependencies. parser_show_appends = self.add_command(sp, 'show-appends', self.do_show_appends) parser_show_appends.add_argument('pnspec', nargs='*', help='optional recipe name specification (wildcards allowed, enclose in quotes to avoid shell expansion)') + parser_show_appends.add_argument('--mc', help='use specified multiconfig', default='') parser_show_cross_depends = self.add_command(sp, 'show-cross-depends', self.do_show_cross_depends) parser_show_cross_depends.add_argument('-f', '--filenames', help='show full file path', action='store_true') |