From: Alexander Kanavin <alex.kanavin@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Alexander Kanavin <alex@linutronix.de>
Subject: [PATCH 4/5] scripts/oe-setup-layers: write a list of layer paths into the checkout's top dir
Date: Fri, 16 Feb 2024 12:52:21 +0100 [thread overview]
Message-ID: <20240216115222.3545462-4-alex@linutronix.de> (raw)
In-Reply-To: <20240216115222.3545462-1-alex@linutronix.de>
This is beneficial for setting up builds, as this list can be used
to determine reliably where the actual layers are, and discover
available configurations from them.
Also adjust the selftest to check the presence of that file rather
than any specific layer in a hardcoded location.
Sample output (paths are written relative to the file for relocatability
and ease of reading):
{
"layers": [
"meta-openembedded/meta-filesystems",
"meta-openembedded/meta-gnome",
"meta-openembedded/meta-initramfs",
"meta-openembedded/meta-multimedia",
"meta-openembedded/meta-networking",
"meta-openembedded/meta-oe",
"meta-openembedded/meta-perl",
"meta-openembedded/meta-python",
"meta-openembedded/meta-webserver",
"meta-openembedded/meta-xfce",
"poky/bitbake/lib/layerindexlib/tests/testdata/layer1",
"poky/bitbake/lib/layerindexlib/tests/testdata/layer2",
"poky/bitbake/lib/layerindexlib/tests/testdata/layer3",
"poky/bitbake/lib/layerindexlib/tests/testdata/layer4",
"poky/meta-poky",
"poky/meta-selftest",
"poky/meta-skeleton",
"poky/meta-yocto-bsp",
"poky/meta"
],
"version": "1.0"
}
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
meta/lib/oeqa/selftest/cases/bblayers.py | 6 ++----
scripts/oe-setup-layers | 15 +++++++++++++++
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py
index ca1470ced0a..f2460cb451b 100644
--- a/meta/lib/oeqa/selftest/cases/bblayers.py
+++ b/meta/lib/oeqa/selftest/cases/bblayers.py
@@ -163,7 +163,5 @@ class BitbakeLayers(OESelftestTestCase):
testcheckoutdir = os.path.join(self.builddir, 'test-layer-checkout')
result = runCmd('{}/setup-layers --destdir {}'.format(self.testlayer_path, testcheckoutdir))
- # May not necessarily be named 'poky' or 'openembedded-core'
- oecoredir = os.listdir(testcheckoutdir)[0]
- testcheckoutfile = os.path.join(testcheckoutdir, oecoredir, "oe-init-build-env")
- self.assertTrue(os.path.exists(testcheckoutfile), "File {} not found in test layer checkout".format(testcheckoutfile))
+ layers_json = os.path.join(testcheckoutdir, ".oe-layers.json")
+ self.assertTrue(os.path.exists(layers_json), "File {} not found in test layer checkout".format(layers_json))
diff --git a/scripts/oe-setup-layers b/scripts/oe-setup-layers
index 6d49688a32c..bee4ef0fec8 100755
--- a/scripts/oe-setup-layers
+++ b/scripts/oe-setup-layers
@@ -49,11 +49,24 @@ def _is_repo_at_remote_uri(repodir, remote, uri):
def _contains_submodules(repodir):
return os.path.exists(os.path.join(repodir,".gitmodules"))
+def _write_layer_list(dest, repodirs):
+ layers = []
+ for r in repodirs:
+ for root, dirs, files in os.walk(r):
+ if os.path.basename(root) == 'conf' and 'layer.conf' in files:
+ layers.append(os.path.relpath(os.path.dirname(root), dest))
+ layers_f = os.path.join(dest, ".oe-layers.json")
+ print("Writing list of layers into {}".format(layers_f))
+ with open(layers_f, 'w') as f:
+ json.dump({"version":"1.0","layers":layers}, f, sort_keys=True, indent=4)
+
def _do_checkout(args, json):
repos = json['sources']
+ repodirs = []
for r_name in repos:
r_data = repos[r_name]
repodir = os.path.abspath(os.path.join(args['destdir'], r_data['path']))
+ repodirs.append(repodir)
if 'contains_this_file' in r_data.keys():
force_arg = 'force_bootstraplayer_checkout'
@@ -96,6 +109,8 @@ def _do_checkout(args, json):
if _contains_submodules(repodir):
print("Repo {} contains submodules, use 'git submodule update' to ensure they are up to date".format(repodir))
+ _write_layer_list(args['destdir'], repodirs)
+
parser = argparse.ArgumentParser(description="A self contained python script that fetches all the needed layers and sets them to correct revisions using data in a json format from a separate file. The json data can be created from an active build directory with 'bitbake-layers create-layers-setup destdir' and there's a sample file and a schema in meta/files/")
parser.add_argument('--force-bootstraplayer-checkout', action='store_true',
--
2.39.2
next prev parent reply other threads:[~2024-02-16 11:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 11:52 [PATCH 1/5] meta/conf/templates/default/conf-summary.txt: add a template summary Alexander Kanavin
2024-02-16 11:52 ` [PATCH 2/5] meta/lib/bblayers/buildconf.py: add support for configuration summaries Alexander Kanavin
2024-02-16 13:57 ` Patchtest results for " patchtest
2024-02-16 14:26 ` [OE-core] " Trevor Gamblin
2024-02-17 0:20 ` Alexandre Belloni
2024-02-16 11:52 ` [PATCH 3/5] scripts/oe-setup-builddir: " Alexander Kanavin
2024-02-16 11:52 ` Alexander Kanavin [this message]
2024-02-16 11:52 ` [PATCH 5/5] oe-setup-build: add a tool for discovering config templates and setting up builds Alexander Kanavin
-- strict thread matches above, loose matches on Subject: below --
2024-01-31 12:39 [PATCH 1/5] meta/conf/templates/default/conf-description.txt: add a template description Alexander Kanavin
2024-01-31 12:39 ` [PATCH 4/5] scripts/oe-setup-layers: write a list of layer paths into the checkout's top dir Alexander Kanavin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240216115222.3545462-4-alex@linutronix.de \
--to=alex.kanavin@gmail.com \
--cc=alex@linutronix.de \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox