cookerdata: Include "originating" recipe data when parsing
RFC 1/1 cookerdata: Include "originating" recipe data when parsing
Parse out PN, PV, and PR from the "originating" recipe (the .bb file being parsed) and provide them at parse time. This allows .bbappends, .inc, etc. files to know what recipe is currently being parsed.
--- lib/bb/cookerdata.py | 6 ++++++ 1 file changed, 6 insertions(+)
lib/bb/cookerdata.py +6 -0
@@ -504,6 +504,12 @@ class CookerDataBuilder(object): bb_data.setVar("__BBMULTICONFIG", mc) bb_data.setVar("FILE_LAYERNAME", layername) + pn, pv, pr = bb.parse.vars_from_file(bbfile, bb_data) + + bb_data.setVar("ORIG_PN", pn or "defaultpkgname") + bb_data.setVar("ORIG_PV", pv or "1.0") + bb_data.setVar("ORIG_PR", pr or "r0") + bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) bb.parse.cached_mtime_noerror(bbfile_loc)
Signature · 1 line
2.51.1
Quoted 34 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Joshua Watt via lists.openembedded.org
Sent: den 30 oktober 2025 15:19
To: [email protected]
Cc: Joshua Watt <[email protected]>
Subject: [bitbake-devel][RFC] cookerdata: Include "originating" recipe data when parsingParse out PN, PV, and PR from the "originating" recipe (the .bb file being parsed) and provide them at parse time. This allows .bbappends, .inc, etc. files to know what recipe is currently being parsed.
Signed-off-by Joshua Watt <[email protected]>--- lib/bb/cookerdata.py | 6 ++++++ 1 file changed, 6 insertions(+)lib/bb/cookerdata.py +6
-1@@ -504,6 +504,12 @@ class CookerDataBuilder(object): bb_data.setVar("__BBMULTICONFIG", mc) bb_data.setVar("FILE_LAYERNAME", layername) + pn, pv, pr = bb.parse.vars_from_file(bbfile, bb_data) + + bb_data.setVar("ORIG_PN", pn or "defaultpkgname") + bb_data.setVar("ORIG_PV", pv or "1.0") + bb_data.setVar("ORIG_PR", pr or "r0") + bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) bb.parse.cached_mtime_noerror(bbfile_loc) --
Quoted 1 line
2.51.1
You want to include PE as well.
//Peter
Quoted 34 lines · Peter Kjellerstedt
Quoted 34 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Joshua Watt via lists.openembedded.org
Sent: den 30 oktober 2025 15:19
To: [email protected]
Cc: Joshua Watt <[email protected]>
Subject: [bitbake-devel][RFC] cookerdata: Include "originating" recipe data when parsingParse out PN, PV, and PR from the "originating" recipe (the .bb file being parsed) and provide them at parse time. This allows .bbappends, .inc, etc. files to know what recipe is currently being parsed.
Signed-off-by Joshua Watt <[email protected]>--- lib/bb/cookerdata.py | 6 ++++++ 1 file changed, 6 insertions(+)lib/bb/cookerdata.py +6
-0@@ -504,6 +504,12 @@ class CookerDataBuilder(object): bb_data.setVar("__BBMULTICONFIG", mc) bb_data.setVar("FILE_LAYERNAME", layername) + pn, pv, pr = bb.parse.vars_from_file(bbfile, bb_data) + + bb_data.setVar("ORIG_PN", pn or "defaultpkgname") + bb_data.setVar("ORIG_PV", pv or "1.0") + bb_data.setVar("ORIG_PR", pr or "r0") + bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) bb.parse.cached_mtime_noerror(bbfile_loc)
Quoted 4 lines
Quoted 2 lines
--
2.51.1You want to include PE as well.
Ya. The other option would just be to do:
bb_data.setVar("ORIG_BBFILE", bbfile)
And let users parse it out for themselves if necessary.
Quoted 3 lines
//Peter
PATCH 1/1 toaster: support bitbake-setup
In reply to Joshua WattFrom c063178ab0971fe297a9e9bca6e6b04eafc5149c Mon Sep 17 00:00:00 2001
From: David Reyna <[email protected]>
Date: Thu, 30 Oct 2025 14:03:35 -0700
Subject: [PATCH] toaster: support bitbake-setup
This adds support for the new bitbake-setup:
* Maintain backwards compatibility for poky-classic releases
* Assume bitbake-setup for all releases 'master' and forward
* When no ".templateconf" assume Poky and not OE
* Generate and use "init-build-env" script instead of 'oe-init-build-env' directly, but "cd" to the clone and not the local installation.
* Include "bblayers.conf" because "cookerdata.py" now explicitly required it, and let it be over-ridden by the usual "toaster-bblayers.conf".
* Force the value "TOPDIR" in "toaster.conf" to the local project's directory.
Normally "cookerdata.py" sets TOPDIR from getcwd(), but somehow in bitbake-setup mode the CWD at this point has become ".../layers/openembedded-core", so "bitbake.conf and all other files cannot be found. This non-obvious problem was hard to discover. Until this is understood, the forced value will make things work.
[YOCTO #16012]
--- bin/toaster | 21 ++-- .../bldcontrol/localhostbecontroller.py | 99 ++++++++++++++----- 2 files changed, 89 insertions(+), 31 deletions(-)
bin/toaster +14 -7
@@ -164,14 +164,20 @@ fi # in the local layers that currently make using an arbitrary # toasterconf.json difficult. -. $OE_ROOT/.templateconf -if [ -n "$TEMPLATECONF" ]; then - if [ ! -d "$TEMPLATECONF" ]; then - # Allow TEMPLATECONF=meta-xyz/conf as a shortcut - if [ -d "$OE_ROOT/$TEMPLATECONF" ]; then - TEMPLATECONF="$OE_ROOT/$TEMPLATECONF" +# BBSETUP no longer supports .templateconf +if [ -f $OE_ROOT/.templateconf ] ; then + . $OE_ROOT/.templateconf + if [ -n "$TEMPLATECONF" ]; then + if [ ! -d "$TEMPLATECONF" ]; then + # Allow TEMPLATECONF=meta-xyz/conf as a shortcut + if [ -d "$OE_ROOT/$TEMPLATECONF" ]; then + TEMPLATECONF="$OE_ROOT/$TEMPLATECONF" + fi fi fi +else + # Force poky + TEMPLATECONF="layers/meta-yocto/meta-poky/conf/templates/default" fi unset OE_ROOT
@@ -255,7 +261,8 @@ fi # 2) the build dir (in build) # 3) the sqlite db if that is being used. # 4) pid's we need to clean up on exit/shutdown -export TOASTER_DIR=$TOASTERDIR +# By default we move this all into the Toaster's parent build directory +export TOASTER_DIR=$BUILDDIR export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS TOASTER_DIR" # Determine the action. If specified by arguments, fine, if not, toggle it
lib/toaster/bldcontrol/localhostbecontroller.py +75 -24
157 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 1/1 toaster: remove dependency on poky distro
In reply to a message not in the archiveFrom 12b96eba959f298bb8edcbcbd9b35a53d104ecea Mon Sep 17 00:00:00 2001
From: David Reyna <[email protected]>
Date: Wed, 12 Nov 2025 00:04:24 -0800
Subject: [PATCH] toaster: remove dependency on poky distro
The poky distro is now stripped of its repositories. Toaster had used that repo as both a quick way to get the three core layers (openembedded-code, meta-poky, and meta-yocto-bsp) but also a way to get the related bitbake, which was important because bitbake is not in the Layer Index. Now, Toaster must explicitly clone each of the core layers plus the proper bitbake layer.
Notes on "orm/fixtures":
* The "orm/fixtures" files used to hard code the three core layers to point to the poky distro, ignoring the Layer Index values
* The script "lsupdates.py" is now allowed to use the Layer Index to properly initialize these layers.
* The fixture files are still used because (a) they define the supported releases for Toaster, plus (b) they now define the proper bitbake repo path and branches to associate with the YP releases.
Notes on "localhostbecontroller.py":
* Always insert the proper bitbake into the layer clone list
* Insure that both 'BBBASEDIR' and 'BITBAKEDIR' are defined in the sub-shells so that oe-init finds the right bitbake (e.g. 'oe-buildenv-internal')
[YOCTO #16012]
--- .../bldcontrol/localhostbecontroller.py | 67 ++++++++----------- lib/toaster/orm/fixtures/gen_fixtures.py | 10 +-- lib/toaster/orm/fixtures/poky.xml | 38 +++++------ .../orm/management/commands/lsupdates.py | 6 +- 4 files changed, 55 insertions(+), 66 deletions(-)
lib/toaster/bldcontrol/localhostbecontroller.py +29 -38
@@ -40,7 +40,8 @@ class LocalhostBEController(BuildEnvironmentController): def __init__(self, be): super(LocalhostBEController, self).__init__(be) - self.pokydirname = None + self.bitbake_dirname = None + self.oecore_dirname = None self.islayerset = False def _shellcmd(self, command, cwd=None, nowait=False,env=None):
@@ -100,7 +101,7 @@ class LocalhostBEController(BuildEnvironmentController): # 1. get a list of repos with branches, and map dirpaths for each layer gitrepos = {} - # if we're using a remotely fetched version of bitbake add its git + # We are using a remotely fetched version of bitbake - add its git # details to the list of repos to clone if bitbake.giturl and bitbake.commit: gitrepos[(bitbake.giturl, bitbake.commit)] = []
@@ -154,12 +155,20 @@ class LocalhostBEController(BuildEnvironmentController): clone_total=len(gitrepos.keys()) self.setCloneStatus(bitbake,'Started',clone_total,clone_count,'') for giturl, commit in gitrepos.keys(): - self.setCloneStatus(bitbake,'progress',clone_total,clone_count,gitrepos[(giturl, commit)][0][0]) + layer_name = gitrepos[(giturl, commit)][0][0] + self.setCloneStatus(bitbake,'progress',clone_total,clone_count,layer_name) clone_count += 1 localdirname = os.path.join(self.be.sourcedir, self.getGitCloneDirectory(giturl, commit)) logger.debug("localhostbecontroller: giturl %s:%s checking out in current directory %s" % (giturl, commit, localdirname)) + # Capture local paths to release's bitbake and openembedded-core layers + if 'bitbake' == layer_name: + self.bitbake_dirname = localdirname + # Capture local path to release's openembedded-core layer (for 'oe-init-build-env') + if 'openembedded-core' == layer_name: + self.oecore_dirname = localdirname + # see if our directory is a git repository if os.path.exists(localdirname): try:
@@ -192,16 +201,6 @@ class LocalhostBEController(BuildEnvironmentController): # prevent inserted debugging commands from being lost self._shellcmd('git fetch && git reset --hard "%s"' % ref, localdirname,env=git_env) - # take the localdirname as poky dir if we can find the oe-init-build-env - if self.pokydirname is None and os.path.exists(os.path.join(localdirname, "oe-init-build-env")): - logger.debug("localhostbecontroller: selected poky dir name %s" % localdirname) - self.pokydirname = localdirname - - # make sure we have a working bitbake - if not os.path.exists(os.path.join(self.pokydirname, 'bitbake')): - logger.debug("localhostbecontroller: checking bitbake into the poky dirname %s " % self.pokydirname) - self._shellcmd("git clone -b \"%s\" \"%s\" \"%s\" " % (bitbake.commit, bitbake.giturl, os.path.join(self.pokydirname, 'bitbake')),env=git_env) - # verify our repositories for name, dirpath, index in gitrepos[(giturl, commit)]: localdirpath = os.path.join(localdirname, dirpath)
@@ -215,21 +214,11 @@ class LocalhostBEController(BuildEnvironmentController): self.setCloneStatus(bitbake,'complete',clone_total,clone_count,'') logger.debug("localhostbecontroller: current layer list %s " % pformat(layerlist)) - # Resolve self.pokydirname if not resolved yet, consider the scenario - # where all layers are local, that's the else clause - if self.pokydirname is None: - if os.path.exists(os.path.join(self.be.sourcedir, "oe-init-build-env")): - logger.debug("localhostbecontroller: selected poky dir name %s" % self.be.sourcedir) - self.pokydirname = self.be.sourcedir - else: - # Alternatively, scan local layers for relative "oe-init-build-env" location - for layer in layers: - if os.path.exists(os.path.join(layer.layer_version.layer.local_source_dir,"..","oe-init-build-env")): - logger.debug("localhostbecontroller, setting pokydirname to %s" % (layer.layer_version.layer.local_source_dir)) - self.pokydirname = os.path.join(layer.layer_version.layer.local_source_dir,"..") - break - else: - logger.error("pokydirname is not set, you will run into trouble!") + # If self.bitbake_dirname still missing (e.g. 'local' build), use local bitbake + if not self.bitbake_dirname: + self.bitbake_dirname = os.environ.get('BBBASEDIR','') + if not self.bitbake_dirname: + logger.error("bitbake_dirname is not set, you will run into trouble!") # 5. create custom layer and add custom recipes to it for target in targets:
@@ -352,8 +341,11 @@ class LocalhostBEController(BuildEnvironmentController): try: # insure that the project init/build uses the selected bitbake, and not Toaster's del git_env['TEMPLATECONF'] - del git_env['BBBASEDIR'] del git_env['BUILDDIR'] + # Insure that oe-init finds the right bitbake (e.g. 'oe-buildenv-internal') + git_env['BBBASEDIR'] = self.bitbake_dirname + git_env['BITBAKEDIR'] = self.bitbake_dirname + except KeyError: pass
@@ -362,7 +354,7 @@ class LocalhostBEController(BuildEnvironmentController): builddir = bitbake.req.project.builddir else: builddir = '%s-toaster-%d' % (self.be.builddir, bitbake.req.project.id) - oe_init = os.path.join(self.pokydirname, 'oe-init-build-env') + oe_init = os.path.join(self.oecore_dirname, 'oe-init-build-env') setup_init = os.path.join(builddir, 'init-build-env') # init build environment and build directory structure try:
@@ -376,7 +368,7 @@ class LocalhostBEController(BuildEnvironmentController): os.makedirs(builddir, exist_ok = True) build_init_script = os.path.join(builddir,'init-build-env') os.system(f"cp {os.path.join(toaster_run_dir,'init-build-env')} {build_init_script}") - os.system(f"sed -i -e 's|^cd .*$|cd {self.pokydirname}|g' {build_init_script}") + os.system(f"sed -i -e 's|^cd .*$|cd {self.oecore_dirname}|g' {build_init_script}") os.system(f"sed -i -e 's|^set .*$|set {builddir}|g' {build_init_script}") # Execute the init self._shellcmd(f"bash -c 'source {build_init_script}'", env=git_env)
@@ -476,10 +468,10 @@ class LocalhostBEController(BuildEnvironmentController): # run bitbake server from the clone if available # otherwise pick it from the PATH - bitbake = os.path.join(self.pokydirname, 'bitbake', 'bin', 'bitbake') + bitbake = os.path.join(self.bitbake_dirname, 'bin', 'bitbake') if not os.path.exists(bitbake): logger.info("Bitbake not available under %s, will try to use it from PATH" % - self.pokydirname) + self.bitbake_dirname) for path in os.environ["PATH"].split(os.pathsep): if os.path.exists(os.path.join(path, 'bitbake')): bitbake = os.path.join(path, 'bitbake')
@@ -494,18 +486,18 @@ class LocalhostBEController(BuildEnvironmentController): # Use 'init-build-env' model if not is_merged_attr: self._shellcmd(f'{env_clean} bash -c \"source {setup_init}; BITBAKE_UI="knotty" {bitbake} --read {confpath} --read {bblayers} --read {toasterlayers} ' - '--server-only -B 0.0.0.0:0\"', self.be.sourcedir) + '--server-only -B 0.0.0.0:0\"', self.be.sourcedir,env=git_env) else: self._shellcmd(f'{env_clean} bash -c \"source {setup_init}; BITBAKE_UI="knotty" {bitbake} ' - '--server-only -B 0.0.0.0:0\"', self.be.sourcedir) + '--server-only -B 0.0.0.0:0\"', self.be.sourcedir,env=git_env) else: # Use 'oe-init-build-env' model if not is_merged_attr: self._shellcmd(f'{env_clean} bash -c \"source {oe_init} {builddir}; BITBAKE_UI="knotty" {bitbake} --read {confpath} --read {bblayers} --read {toasterlayers} ' - '--server-only -B 0.0.0.0:0\"', self.be.sourcedir) + '--server-only -B 0.0.0.0:0\"', self.be.sourcedir,env=git_env) else: self._shellcmd(f'{env_clean} bash -c \"source {oe_init} {builddir}; BITBAKE_UI="knotty" {bitbake} ' - '--server-only -B 0.0.0.0:0\"', self.be.sourcedir) + '--server-only -B 0.0.0.0:0\"', self.be.sourcedir,env=git_env) # read port number from bitbake.lock self.be.bbport = -1
@@ -551,7 +543,6 @@ class LocalhostBEController(BuildEnvironmentController): log = os.path.join(builddir, 'toaster_ui.log') local_bitbake = os.path.join(os.path.dirname(os.getenv('BBBASEDIR')), 'bitbake') - if not is_merged_attr: self._shellcmd([f'{env_clean} bash -c \"(TOASTER_BRBE="{brbe}" BBSERVER="0.0.0.0:{self.be.bbport}" ' f'{bitbake} {bbtargets} -u toasterui --read {confpath} --read {bblayers} --read {toasterlayers} --token="" >>{log} 2>&1;'
lib/toaster/orm/fixtures/gen_fixtures.py +5 -5
@@ -32,7 +32,7 @@ verbose = False # It is also policy to include all active LTS releases. # -# [Codename, Yocto Project Version, Release Date, Current Version, Support Level, Poky Version, BitBake branch] +# [0=Codename, 1=Yocto Project Version, 2=Release Date, 3=Current Version, 4=Support Level, 5=Poky Version, 6=BitBake branch] current_releases = [ # Release slot #1 ['Scarthgap','5.0','April 2024','5.0.0 (April 2024)','Long Term Support (until April 2028)','','2.8'],
@@ -43,7 +43,7 @@ current_releases = [ # Release slot #4 ['Whinlatter','5.3','October 2025','5.3.0 (October 2024)','Support for 7 months (until May 2026)','','2.14'], ['Walnascar','5.2','April 2025','5.2.0 (April 2025)','Support for 7 months (until October 2025)','','2.12'], - #['Styhead','5.1','November 2024','5.1.0 (November 2024)','Support for 7 months (until May 2025)','','2.10'], + ['Styhead','5.1','November 2024','5.1.0 (November 2024)','Support for 7 months (until May 2025)','','2.10'], #['Nanbield','4.3','November 2023','4.3.0 (November 2023)','Support for 7 months (until May 2024)','','2.6'], #['Mickledore','4.2','April 2023','4.2.0 (April 2023)','Support for 7 months (until October 2023)','','2.4'], #['Langdale','4.1','October 2022','4.1.2 (January 2023)','Support for 7 months (until May 2023)','','2.2'],
@@ -81,9 +81,9 @@ prolog_template = '''\ bitbakeversion_poky_template = '''\ <object model="orm.bitbakeversion" pk="{{bitbake_id}}"> <field type="CharField" name="name">{{name}}</field> - <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> <field type="CharField" name="branch">{{branch}}</field> - <field type="CharField" name="dirpath">bitbake</field> + <field type="CharField" name="dirpath"></field> </object> ''' bitbakeversion_oecore_template = '''\
@@ -224,7 +224,7 @@ def generate_poky(): params['release'] = params['release'][0].lower() + params['release'][1:] params['name'] = params['release'] params['bitbake_id'] = str(i+1) - params['branch'] = params['release'] + params['branch'] = release[6] # Bitbake branch print_template(bitbakeversion_poky_template,params,fd) print_str('',fd)
lib/toaster/orm/fixtures/poky.xml +19 -19
@@ -9,45 +9,45 @@ <!-- Bitbake versions which correspond to the metadata release --> <object model="orm.bitbakeversion" pk="1"> <field type="CharField" name="name">scarthgap</field> - <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field> - <field type="CharField" name="branch">scarthgap</field> - <field type="CharField" name="dirpath">bitbake</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> + <field type="CharField" name="branch">2.8</field> + <field type="CharField" name="dirpath"></field> </object> <object model="orm.bitbakeversion" pk="2"> <field type="CharField" name="name">HEAD</field> - <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> <field type="CharField" name="branch">HEAD</field> - <field type="CharField" name="dirpath">bitbake</field> + <field type="CharField" name="dirpath"></field> </object> <object model="orm.bitbakeversion" pk="3"> <field type="CharField" name="name">master</field> - <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> <field type="CharField" name="branch">master</field> - <field type="CharField" name="dirpath">bitbake</field> + <field type="CharField" name="dirpath"></field> </object> <object model="orm.bitbakeversion" pk="4"> <field type="CharField" name="name">whinlatter</field> - <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field> - <field type="CharField" name="branch">whinlatter</field> - <field type="CharField" name="dirpath">bitbake</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> + <field type="CharField" name="branch">2.14</field> + <field type="CharField" name="dirpath"></field> </object> <object model="orm.bitbakeversion" pk="5"> <field type="CharField" name="name">walnascar</field> - <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field> - <field type="CharField" name="branch">walnascar</field> - <field type="CharField" name="dirpath">bitbake</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> + <field type="CharField" name="branch">2.12</field> + <field type="CharField" name="dirpath"></field> </object> <object model="orm.bitbakeversion" pk="6"> <field type="CharField" name="name">styhead</field> - <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field> - <field type="CharField" name="branch">styhead</field> - <field type="CharField" name="dirpath">bitbake</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> + <field type="CharField" name="branch">2.10</field> + <field type="CharField" name="dirpath"></field> </object> <object model="orm.bitbakeversion" pk="7"> <field type="CharField" name="name">kirkstone</field> - <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field> - <field type="CharField" name="branch">kirkstone</field> - <field type="CharField" name="dirpath">bitbake</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> + <field type="CharField" name="branch">2.0</field> + <field type="CharField" name="dirpath"></field> </object>
lib/toaster/orm/management/commands/lsupdates.py +2 -4
@@ -138,9 +138,7 @@ class Command(BaseCommand): l.summary = index.layerItems[id].summary l.description = index.layerItems[id].description - if created: - # predefined layers in the fixtures (for example poky.xml) - # always preempt the Layer Index for these values + if True: # (if created:) always override fixture defaults now that poky distro is stripped l.vcs_url = index.layerItems[id].vcs_url l.vcs_web_url = index.layerItems[id].vcs_web_url l.vcs_web_tree_base_url = index.layerItems[id].vcs_web_tree_base_url
@@ -179,7 +177,7 @@ class Command(BaseCommand): index.layerBranches[id].layer_id) continue - if created: + if True: # (if created:) always override fixture defaults now that poky distro is stripped lv.release = li_branch_id_to_toaster_release[index.layerBranches[id].branch_id] lv.up_date = index.layerBranches[id].updated lv.commit = index.layerBranches[id].actual_branch
Signature · 1 line
2.43.0
PATCH v2 1/1 cookerdata: Include "originating" recipe name when parsing
In reply to Joshua WattWhen a bbappend file is parsed, the FILE variable is set to the name of the actual file being parsed (e.g. the name of the bbappend). Since PN/PV etc. are derived from FILE, this means that they can be misleading in the event that bbappend is using wildcards (e.g. PV might have the value of "%" instead of the actual version number).
In order to allow bbappends to derived the actual information of the recipe, capture the name of the original recipe being parsed as ORIG_FILE when parsing a new recipe.
--- lib/bb/cookerdata.py | 2 ++ 1 file changed, 2 insertions(+)
lib/bb/cookerdata.py +2 -0
@@ -512,6 +512,8 @@ class CookerDataBuilder(object): bb_data.setVar("__BBMULTICONFIG", mc) bb_data.setVar("FILE_LAYERNAME", layername) + bb_data.setVar("ORIG_FILE", bbfile) + bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) bb.parse.cached_mtime_noerror(bbfile_loc)
Signature · 1 line
2.52.0
Re: [bitbake-devel][PATCH v2] cookerdata: Include "originating" recipe name when parsing
Quoted 22 lines · Joshua Watt via lists.openembedded.org
When a bbappend file is parsed, the FILE variable is set to the name of the actual file being parsed (e.g. the name of the bbappend). Since PN/PV etc. are derived from FILE, this means that they can be misleading in the event that bbappend is using wildcards (e.g. PV might have the value of "%" instead of the actual version number).
In order to allow bbappends to derived the actual information of the recipe, capture the name of the original recipe being parsed as
ORIG_FILEwhen parsing a new recipe.Signed-off-by Joshua Watt <[email protected]>---
lib/bb/cookerdata.py | 2 ++1 file changed, 2 insertions(+)lib/bb/cookerdata.py +0
-0@@ -512,6 +512,8 @@ class CookerDataBuilder(object): bb_data.setVar("__BBMULTICONFIG", mc) bb_data.setVar("FILE_LAYERNAME", layername)
Quoted 5 lines
+bb_data.setVar("ORIG_FILE", bbfile)
+
bbfile_loc= os.path.abspath(os.path.dirname(bbfile))bb.parse.cached_mtime_noerror(bbfile_loc)
We discussed this a bit on the review call today, I appreciate Joshua wasn't there but it made sense to try and unblock this.
In brief, the concerns mentioned were:
* no tests/docs
* not wanting to encourage wide use of this
(conflicting with the above)
* whether the name is right
The idea of using a __ prefix for the variable was mentioned. That would allow Joshua to address the issues he has but not make it 'official' recommended API. That might be the compromise we need.
For the name itself, I'm really torn. For variables which bitbake itself responds to, I've tried to standardise on a BB_ prefix. This is more a variable bitbake exposes for use elsewhere and we have the FILE_ prefix already being used but I'm torn on whether we should continue that theme or use something with BB_...
Cheers,
Richard
Re: [bitbake-devel][PATCH v2] cookerdata: Include "originating" recipe name when parsing
Quoted 33 lines · Richard Purdie
Quoted 20 lines · Joshua Watt via lists.openembedded.org
When a bbappend file is parsed, the FILE variable is set to the name of the actual file being parsed (e.g. the name of the bbappend). Since PN/PV etc. are derived from FILE, this means that they can be misleading in the event that bbappend is using wildcards (e.g. PV might have the value of "%" instead of the actual version number).
In order to allow bbappends to derived the actual information of the recipe, capture the name of the original recipe being parsed as
ORIG_FILEwhen parsing a new recipe.Signed-off-by Joshua Watt <[email protected]>--- lib/bb/cookerdata.py | 2 ++ 1 file changed, 2 insertions(+)lib/bb/cookerdata.py +0
-0lib/bb/cookerdata.py class CookerDataBuilder(object): · line 518
Quoted 7 lines
lib/bb/cookerdata.py +2
-0@@ -512,6 +512,8 @@ class CookerDataBuilder(object): bb_data.setVar("__BBMULTICONFIG", mc) bb_data.setVar("FILE_LAYERNAME", layername) + bb_data.setVar("ORIG_FILE", bbfile) + bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) bb.parse.cached_mtime_noerror(bbfile_loc)We discussed this a bit on the review call today, I appreciate Joshua wasn't there but it made sense to try and unblock this.
Quoted 3 lines
In brief, the concerns mentioned were:
* no tests/docs
A test should be pretty easy to do, I'll see if I can write one up; I can try to write some docs also.
Quoted 8 lines
* not wanting to encourage wide use of this
(conflicting with the above)
* whether the name is rightThe idea of using a __ prefix for the variable was mentioned. That would allow Joshua to address the issues he has but not make it 'official' recommended API. That might be the compromise we need.
Quoted 5 lines
For the name itself, I'm really torn. For variables which bitbake itself responds to, I've tried to standardise on a
BB_prefix. This is more a variable bitbake exposes for use elsewhere and we have theFILE_prefix already being used but I'm torn on whether we should continue that theme or use something withBB_...
BB_ORIG_FILE then? I'd probably avoid the __BB prefix since that is reserved for variables which bitbake used internally (only).
Alternatively, if we want to set a new convention of "hidden" variables, we could perhaps to do something like "bb_ORIG_FILE", but that is kinda hard on the eyes :)
Quoted 13 lines
Cheers,
Richard
Re: [bitbake-devel][PATCH v2] cookerdata: Include "originating" recipe name when parsing
Quoted 35 lines · Joshua Watt
Quoted 33 lines · Richard Purdie
Quoted 20 lines · Joshua Watt via lists.openembedded.org
When a bbappend file is parsed, the FILE variable is set to the name of the actual file being parsed (e.g. the name of the bbappend). Since PN/PV etc. are derived from FILE, this means that they can be misleading in the event that bbappend is using wildcards (e.g. PV might have the value of "%" instead of the actual version number).
In order to allow bbappends to derived the actual information of the recipe, capture the name of the original recipe being parsed as
ORIG_FILEwhen parsing a new recipe.Signed-off-by Joshua Watt <[email protected]>---
lib/bb/cookerdata.py | 2 ++1 file changed, 2 insertions(+)lib/bb/cookerdata.py +0
-0lib/bb/cookerdata.py class CookerDataBuilder(object): · line 518
Quoted 7 lines
lib/bb/cookerdata.py +2
-0@@ -512,6 +512,8 @@ class CookerDataBuilder(object): bb_data.setVar("__BBMULTICONFIG", mc) bb_data.setVar("FILE_LAYERNAME", layername) + bb_data.setVar("ORIG_FILE", bbfile) + bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) bb.parse.cached_mtime_noerror(bbfile_loc)We discussed this a bit on the review call today, I appreciate Joshua wasn't there but it made sense to try and unblock this.
Quoted 6 lines
Quoted 3 lines
In brief, the concerns mentioned were:
* no tests/docs
A test should be pretty easy to do, I'll see if I can write one up; I can try to write some docs also.
Right, those are straightforward in many ways but it also establishes official API which is a concern. That isn't what is holding this up.
Quoted 9 lines
Quoted 9 lines
* not wanting to encourage wide use of this
(conflicting with the above)
* whether the name is rightThe idea of using a __ prefix for the variable was mentioned. That would allow Joshua to address the issues he has but not make it 'official' recommended API. That might be the compromise we need.
Quoted 8 lines
Quoted 5 lines
For the name itself, I'm really torn. For variables which bitbake itself responds to, I've tried to standardise on a
BB_prefix. This is more a variable bitbake exposes for use elsewhere and we have theFILE_prefix already being used but I'm torn on whether we should continue that theme or use something withBB_...
BB_ORIG_FILEthen? I'd probably avoid the__BBprefix since that is reserved for variables which bitbake used internally (only).
Someone did mention "recipe" instead of "file" might be an idea so more like BB_RECIPE_FILE maybe?
Quoted 3 lines
Alternatively, if we want to set a new convention of "hidden" variables, we could perhaps to do something like "
bb_ORIG_FILE", but that is kinda hard on the eyes :)
I want to try and unblock you, yet at the same time discourage people from using this. '__' is the best chance of that we have. I really don't want to do bb_ as that is horrible on the eyes. Part of me realises it is completely futile to even try and do that and thinks I may as well not try.
I think the horrors people could implement with this are problematic but I really am not sure we have many other good choices. Layer specific dangling bbappend controls aren't particularly nice either.
Cheers,
Richard
Re: [bitbake-devel][PATCH v2] cookerdata: Include "originating" recipe name when parsing
Quoted 72 lines · Richard Purdie
Quoted 35 lines · Joshua Watt
Quoted 33 lines · Richard Purdie
Quoted 20 lines · Joshua Watt via lists.openembedded.org
When a bbappend file is parsed, the FILE variable is set to the name of the actual file being parsed (e.g. the name of the bbappend). Since PN/PV etc. are derived from FILE, this means that they can be misleading in the event that bbappend is using wildcards (e.g. PV might have the value of "%" instead of the actual version number).
In order to allow bbappends to derived the actual information of the recipe, capture the name of the original recipe being parsed as
ORIG_FILEwhen parsing a new recipe.Signed-off-by Joshua Watt <[email protected]>--- lib/bb/cookerdata.py | 2 ++ 1 file changed, 2 insertions(+)lib/bb/cookerdata.py +0
-0lib/bb/cookerdata.py class CookerDataBuilder(object): · line 518
Quoted 7 lines
lib/bb/cookerdata.py +2
-0@@ -512,6 +512,8 @@ class CookerDataBuilder(object): bb_data.setVar("__BBMULTICONFIG", mc) bb_data.setVar("FILE_LAYERNAME", layername) + bb_data.setVar("ORIG_FILE", bbfile) + bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) bb.parse.cached_mtime_noerror(bbfile_loc)We discussed this a bit on the review call today, I appreciate Joshua wasn't there but it made sense to try and unblock this.
Quoted 6 lines
Quoted 3 lines
In brief, the concerns mentioned were:
* no tests/docs
A test should be pretty easy to do, I'll see if I can write one up; I can try to write some docs also.
Right, those are straightforward in many ways but it also establishes official API which is a concern. That isn't what is holding this up.
Quoted 9 lines
Quoted 9 lines
* not wanting to encourage wide use of this
(conflicting with the above)
* whether the name is rightThe idea of using a __ prefix for the variable was mentioned. That would allow Joshua to address the issues he has but not make it 'official' recommended API. That might be the compromise we need.
Quoted 8 lines
Quoted 5 lines
For the name itself, I'm really torn. For variables which bitbake itself responds to, I've tried to standardise on a
BB_prefix. This is more a variable bitbake exposes for use elsewhere and we have theFILE_prefix already being used but I'm torn on whether we should continue that theme or use something withBB_...
BB_ORIG_FILEthen? I'd probably avoid the__BBprefix since that is reserved for variables which bitbake used internally (only).Someone did mention "recipe" instead of "file" might be an idea so more like
BB_RECIPE_FILEmaybe?Quoted 3 lines
Alternatively, if we want to set a new convention of "hidden" variables, we could perhaps to do something like "
bb_ORIG_FILE", but that is kinda hard on the eyes :)
Quoted 5 lines
I want to try and unblock you, yet at the same time discourage people from using this. '__' is the best chance of that we have. I really don't want to do
bb_as that is horrible on the eyes. Part of me realises it is completely futile to even try and do that and thinks I may as well not try.
Fair enough. __BB_RECIPE_FILE works for me
Quoted 11 lines
I think the horrors people could implement with this are problematic but I really am not sure we have many other good choices. Layer specific dangling bbappend controls aren't particularly nice either.
Cheers,
Richard
PATCH v3 1/1 cookerdata: Include "originating" recipe name when parsing
In reply to Joshua WattFrom: Joshua Watt <[email protected]>
When a bbappend file is parsed, the FILE variable is set to the name of the actual file being parsed (e.g. the name of the bbappend). Since PN/PV etc. are derived from FILE, this means that they can be misleading in the event that bbappend is using wildcards (e.g. PV might have the value of "%" instead of the actual version number).
In order to allow bbappends to derived the actual information of the recipe, capture the name of the original recipe being parsed as __BB_RECIPE_FILE when parsing a new recipe. The value of this variable doesn't change when parsing .bbappend or .inc file associated with the recipe
---
V3: Rename to __BB_RECIPE_FILE, add documentation and tests
.../bitbake-user-manual-ref-variables.rst | 4 + lib/bb/cookerdata.py | 2 + lib/bb/tests/parse-tests/classes/base.bbclass | 5 + .../classes/recipe-file-class.bbclass | 2 + lib/bb/tests/parse-tests/conf/bitbake.conf | 15 ++ lib/bb/tests/parse.py | 132 +++++++++++++++++- 6 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 lib/bb/tests/parse-tests/classes/base.bbclass create mode 100644 lib/bb/tests/parse-tests/classes/recipe-file-class.bbclass create mode 100644 lib/bb/tests/parse-tests/conf/bitbake.conf
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +4 -0
@@ -720,6 +720,10 @@ overview of their function and contents. pressure on the system. Monitor the varying value after ``Mem:`` above to set a sensible value. + :term:`__BB_RECIPE_FILE` + Specifies the name of the recipe file that is being parsed. This is the + same even if when evalated in a bbappend, include or bbclass file. + :term:`BB_RUNFMT` Specifies the name of the executable script files (i.e. run files) saved into ``${``\ :term:`T`\ ``}``. By default, the
lib/bb/cookerdata.py +2 -0
@@ -512,6 +512,8 @@ class CookerDataBuilder(object): bb_data.setVar("__BBMULTICONFIG", mc) bb_data.setVar("FILE_LAYERNAME", layername) + bb_data.setVar("__BB_RECIPE_FILE", bbfile) + bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) bb.parse.cached_mtime_noerror(bbfile_loc)
lib/bb/tests/parse-tests/classes/base.bbclass new file +5 -0
@@ -0,0 +1,5 @@ +# At least one task is required for bitbake to parse +do_fetch() { + : +} +addtask do_fetch
lib/bb/tests/parse-tests/classes/recipe-file-class.bbclass new file +2 -0
@@ -0,0 +1,2 @@ +BBCLASS_RECIPE_FILE := "${@os.path.basename(d.getVar('__BB_RECIPE_FILE'))}" +BBCLASS_FILE := "${@os.path.basename(d.getVar('FILE'))}"
lib/bb/tests/parse-tests/conf/bitbake.conf new file +15 -0
@@ -0,0 +1,15 @@ +CACHE = "${TOPDIR}/cache" +THISDIR = "${@os.path.dirname(d.getVar('FILE'))}" +COREBASE := "${@os.path.normpath(os.path.dirname(d.getVar('FILE')+'/../../'))}" +EXTRA_BBFILES ?= "" +BBFILES = "${COREBASE}/recipes/*.bb ${COREBASE}/recipes/*.bbappend ${EXTRA_BBFILES}" +PROVIDES = "${PN}" +PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0]}" +PF = "${BB_CURRENT_MC}:${PN}" +export PATH +TMPDIR ??= "${TOPDIR}" +STAMP = "${TMPDIR}/stamps/${PN}" +T = "${TMPDIR}/workdir/${PN}/temp" +BB_NUMBER_THREADS = "4" + +BB_BASEHASH_IGNORE_VARS = "BB_CURRENT_MC BB_HASHSERVE TMPDIR TOPDIR SLOWTASKS SSTATEVALID FILE BB_CURRENTTASK"
lib/bb/tests/parse.py +131 -1
147 lines not on this page · raw message
Signature · 1 line
2.53.0