From patchwork Mon Nov 30 15:27:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 106510 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.34564.1796052450915750189 for ; Mon, 30 Nov 2026 07:27:31 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=TNkq+kA6; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.52, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4bb606491faso55471365e9.3 for ; Mon, 30 Nov 2026 07:27:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1796052449; x=1796657249; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=xmqK5XqxnoK0zqOkBj9zEDG0NksSdAIbXhg9BQr3RDo=; b=TNkq+kA6ceSrs6aJdpuhM7hRPiUY4EN23a5rUgL9cXDragtl9IpC39oSSDjcFd242J mitBVWSQ2oKlVp7tBueTVKxBN/mxWkMlrhXmW/fJd8fYNZJmZ43Y7MJ+O50yziakMQiw eP3jPEpm+vr5oL+wjX8A0v2330WkFbJmtmT7I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796052449; x=1796657249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=xmqK5XqxnoK0zqOkBj9zEDG0NksSdAIbXhg9BQr3RDo=; b=J+Rmxc2BqrJb/Yz3VkiAH1VIeIWXkou67AIAGCYGYj52FaaaxcfADWf+2fiWPhvrNm XiB9MLP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ov0w== X-Received: by 2002:a05:600c:1384:b0:4a2:1612:6367 with SMTP id 5b1f17b1804b1-4bb88816c44mr682886295e9.15.1796052448965; Mon, 30 Nov 2026 07:27:28 -0800 (PST) Return-Path: Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:2444:81bb:2aff:8d84]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8538b09bsm1704014155e9.4.2026.11.30.07.27.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 07:27:27 -0800 (PST) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 15/16] lib/oe/recipeutils: Find recipe and bbappend locations from layer structure Date: Mon, 30 Nov 2026 15:27:03 +0000 Message-ID: <20261130152704.3471590-15-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261130152704.3471590-1-richard.purdie@linuxfoundation.org> References: <20261130152704.3471590-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Mon, 30 Nov 2026 15:27:41 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251624 get_bbfile_path() and get_bbappend_path() parsed the destination layer's layer.conf for BBFILES patterns, which layers no longer set, so devtool finish and recipetool appendfile couldn't work out where to put files. Derive the patterns from the layer's recipes* (and dynamic-recipes) directories as bitbake now does, preferring the conventional recipes-// layout. AI-Generated: Uses Claude Opus 5.5 Signed-off-by: Richard Purdie --- meta/lib/oe/recipeutils.py | 139 ++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 80 deletions(-) diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 9b3a2d0638d..635998d021b 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -539,6 +539,24 @@ def validate_pn(pn): return '' +def get_layer_bbfile_specs(d, layerdir, ext): + """ + Return a list of fnmatch patterns matching the recipes (ext='.bb') or + bbappends (ext='.bbappend') bitbake will pick up from the specified layer. + Bitbake searches any recipes* directories within a layer (at any depth) + plus dynamic-recipes// for any configured layer. This is + determined from the layer's structure so works for layers which aren't + in bblayers.conf. + """ + # fnmatch's '*' also matches '/', so this covers files at any depth + specs = [os.path.join(layerdir, 'recipes*', '*' + ext)] + dynamicdir = os.path.join(layerdir, 'dynamic-recipes') + if os.path.isdir(dynamicdir): + for layername in sorted(os.listdir(dynamicdir)): + if os.path.isdir(os.path.join(dynamicdir, layername)) and d.getVar('LAYERDIR_%s' % layername): + specs.append(os.path.join(dynamicdir, layername, '*' + ext)) + return specs + def get_bbfile_path(d, destdir, extrapathhint=None): """ Determine the correct path for a recipe within a layer @@ -548,48 +566,25 @@ def get_bbfile_path(d, destdir, extrapathhint=None): partial path somewhere within the layer. extrapathhint: a path relative to the base of the layer to try """ - import bb.cookerdata - destdir = os.path.abspath(destdir) destlayerdir = find_layerdir(destdir) - - # Parse the specified layer's layer.conf file directly, in case the layer isn't in bblayers.conf - confdata = d.createCopy() - confdata.setVar('BBFILES', '') - confdata.setVar('LAYERDIR', destlayerdir) - destlayerconf = os.path.join(destlayerdir, "conf", "layer.conf") - confdata = bb.cookerdata.parse_config_file(destlayerconf, confdata) + if not destlayerdir: + return None pn = d.getVar('PN') - # Parse BBFILES_DYNAMIC and append to BBFILES - bbfiles_dynamic = (confdata.getVar('BBFILES_DYNAMIC') or "").split() - collections = (confdata.getVar('BBFILE_COLLECTIONS') or "").split() - invalid = [] - for entry in bbfiles_dynamic: - parts = entry.split(":", 1) - if len(parts) != 2: - invalid.append(entry) - continue - l, f = parts - invert = l[0] == "!" - if invert: - l = l[1:] - if (l in collections and not invert) or (l not in collections and invert): - confdata.appendVar("BBFILES", " " + f) - if invalid: - return None - bbfilespecs = (confdata.getVar('BBFILES') or '').split() + bbfilespecs = get_layer_bbfile_specs(d, destlayerdir, '.bb') if destdir == destlayerdir: - for bbfilespec in bbfilespecs: - if not bbfilespec.endswith('.bbappend'): - for match in glob.glob(bbfilespec): - splitext = os.path.splitext(os.path.basename(match)) - if splitext[1] == '.bb': - mpn = splitext[0].split('_')[0] - if mpn == pn: - return os.path.dirname(match) - - # Try to make up a path that matches BBFILES + # See if there is an existing recipe for this PN in the layer + for root, dirs, files in os.walk(destlayerdir): + dirs.sort() + for fn in sorted(files): + splitext = os.path.splitext(fn) + if splitext[1] == '.bb' and splitext[0].split('_')[0] == pn: + match = os.path.join(root, fn) + if any(fnmatch.fnmatchcase(match, spec) for spec in bbfilespecs): + return root + + # Try to make up a path bitbake will find recipes in # this is a little crude, but better than nothing bpn = d.getVar('BPN') recipefn = os.path.basename(d.getVar('FILE')) @@ -602,19 +597,28 @@ def get_bbfile_path(d, destdir, extrapathhint=None): pathoptions.append(os.path.join(destdir, bpn)) elif not destdir.endswith(('/' + pn, '/' + bpn)): pathoptions.append(os.path.join(destdir, bpn)) - closepath = '' - for pathoption in pathoptions: - bbfilepath = os.path.join(pathoption, 'test.bb') - for bbfilespec in bbfilespecs: - if fnmatch.fnmatchcase(bbfilepath, bbfilespec): - return pathoption + + def conventional(path): + # Recipes are conventionally placed in recipes-// + # (optionally under dynamic-recipes//) + parts = os.path.relpath(path, destlayerdir).split(os.sep) + if parts[0] == 'dynamic-recipes': + parts = parts[2:] + return len(parts) == 2 and parts[0].startswith('recipes') + + # Bitbake will find recipes at any depth within a recipes* directory, so + # prefer the first option giving the conventional layout, if there is one + valid = [p for p in pathoptions if any(fnmatch.fnmatchcase(os.path.join(p, 'test.bb'), spec) for spec in bbfilespecs)] + for pathoption in valid: + if conventional(pathoption): + return pathoption + if valid: + return valid[0] return None def get_bbappend_path(d, destlayerdir, wildcardver=False): """Determine how a bbappend for a recipe should be named and located within another layer""" - import bb.cookerdata - destlayerdir = os.path.abspath(destlayerdir) recipefile = d.getVar('FILE') recipefn = os.path.splitext(os.path.basename(recipefile))[0] @@ -622,45 +626,20 @@ def get_bbappend_path(d, destlayerdir, wildcardver=False): recipefn = recipefn.split('_', 1)[0] + '_%' appendfn = recipefn + '.bbappend' - # Parse the specified layer's layer.conf file directly, in case the layer isn't in bblayers.conf - confdata = d.createCopy() - confdata.setVar('BBFILES', '') - confdata.setVar('LAYERDIR', destlayerdir) - destlayerconf = os.path.join(destlayerdir, "conf", "layer.conf") - confdata = bb.cookerdata.parse_config_file(destlayerconf, confdata) - origlayerdir = find_layerdir(recipefile) if not origlayerdir: return (None, False) - # Now join this to the path where the bbappend is going and check if it is covered by BBFILES + # Now join this to the path where the bbappend is going and check bitbake will find it there appendpath = os.path.join(destlayerdir, os.path.relpath(os.path.dirname(recipefile), origlayerdir), appendfn) - closepath = '' pathok = True - for bbfilespec in confdata.getVar('BBFILES').split(): - if fnmatch.fnmatchcase(appendpath, bbfilespec): - # Our append path works, we're done - break - elif bbfilespec.startswith(destlayerdir) and fnmatch.fnmatchcase('test.bbappend', os.path.basename(bbfilespec)): - # Try to find the longest matching path - if len(bbfilespec) > len(closepath): - closepath = bbfilespec - else: - # Unfortunately the bbappend layer and the original recipe's layer don't have the same structure - if closepath: - # bbappend layer's layer.conf at least has a spec that picks up .bbappend files - # Now we just need to substitute out any wildcards - appendsubdir = os.path.relpath(os.path.dirname(closepath), destlayerdir) - if 'recipes-*' in appendsubdir: - # Try to copy this part from the original recipe path - res = re.search('/recipes-[^/]+/', recipefile) - if res: - appendsubdir = appendsubdir.replace('/recipes-*/', res.group(0)) - # This is crude, but we have to do something - appendsubdir = appendsubdir.replace('*', recipefn.split('_')[0]) - appendsubdir = appendsubdir.replace('?', 'a') - appendpath = os.path.join(destlayerdir, appendsubdir, appendfn) - else: - pathok = False + if not any(fnmatch.fnmatchcase(appendpath, spec) for spec in get_layer_bbfile_specs(d, destlayerdir, '.bbappend')): + # The recipe isn't in a location which maps to one bitbake will search + # in the destination layer (e.g. it is under dynamic-recipes/ for a + # layer which isn't configured), so put the bbappend under a + # recipes-* directory, using the original recipe's category if possible + res = re.search('/(recipes-[^/]+)/', recipefile) + category = res.group(1) if res else 'recipes' + appendpath = os.path.join(destlayerdir, category, recipefn.split('_')[0], appendfn) return (appendpath, pathok) @@ -723,7 +702,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, bb.error('Unable to determine layer directory containing %s' % recipefile) return (None, None) if not pathok: - bb.warn('Unable to determine correct subdirectory path for bbappend file - check that what %s adds to BBFILES also matches .bbappend files. Using %s for now, but until you fix this the bbappend will not be applied.' % (os.path.join(destlayerdir, 'conf', 'layer.conf'), os.path.dirname(appendpath))) + bb.warn('Unable to determine correct subdirectory path for bbappend file. Using %s for now, but it may not be applied.' % os.path.dirname(appendpath)) appenddir = os.path.dirname(appendpath) if not redirect_output: