new file mode 100644
@@ -0,0 +1,41 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import logging
+import json
+
+logger = logging.getLogger('bitbake-layers')
+
+def plugin_init(plugins):
+ return OeLocalCopyWriter()
+
+class OeLocalCopyWriter():
+
+ def __str__(self):
+ return "oe-local-copy"
+
+ def do_write(self, parent, args):
+ """ Writes out a local copy of all the metadata layers (and bitbake) included in a current build. """
+ if not os.path.exists(args.destdir):
+ os.makedirs(args.destdir)
+ repos = parent.make_repo_config(args.destdir)
+ if not repos:
+ raise Exception("Could not determine layer sources")
+ output = os.path.join(os.path.abspath(args.destdir), args.output_prefix or "layers")
+ json_f = os.path.join(os.path.abspath(args.destdir), "bundle-repos.json")
+
+ for r in repos.values():
+ r['git-remote']['remotes'] = {"origin":{"uri":r["originpath"]}}
+
+ json_data = {"version":"1.0","sources":repos}
+ with open(json_f, 'w') as f:
+ json.dump(json_data, f, sort_keys=True, indent=4)
+
+ logger.info("Cloning repositories into {}".format(output))
+ bb.process.run('oe-setup-layers --force-bootstraplayer-checkout --destdir {} --jsondata {}'.format(output, json_f))
+
+ def register_arguments(self, parser):
+ pass
@@ -240,3 +240,16 @@ class BitbakeLayers(OESelftestTestCase):
self.assertEqual(first_desc_2, '', "Describe not cleared: '{}'".format(first_desc_2))
self.assertEqual(second_rev_2, second_rev_1, "Revision should not be updated: '{}'".format(second_rev_2))
self.assertEqual(second_desc_2, second_desc_1, "Describe should not be updated: '{}'".format(second_desc_2))
+
+ def test_bitbakelayers_setup_localcopy(self):
+ testcopydir = os.path.join(self.builddir, 'test-layer-copy')
+ result = runCmd('bitbake-layers create-layers-setup --writer oe-local-copy {}'.format(testcopydir))
+ oe_core_found = False
+ meta_selftest_found = False
+ for topdir, subdirs, files in os.walk(testcopydir):
+ if topdir.endswith('meta/conf') and 'layer.conf' in files:
+ oe_core_found = True
+ if topdir.endswith('meta-selftest/conf') and 'layer.conf' in files:
+ meta_selftest_found = True
+ self.assertTrue(oe_core_found, "meta/conf/layer.conf not found in {}".format(testcopydir))
+ self.assertTrue(meta_selftest_found, "meta-selftest/conf/layer.conf not found in {}".format(testcopydir))
This plugin copies all currently configured layer respositories into a dedicated location on local disk. This is useful for entirely offline layer replication, when the layers are packed and then unpacked from an archive, rather than fetched from git (there can be situations where fetching from git is undesirable or impossible). This plugin will also be used when replicating an entire yocto build (with build config and sstate cache), and is an element of that. This plugin is similar to what esdk does, and it provides that functionality outside of populate_sdk_ext task. It does not reuse esdk code, as that simply copies the layer tree; it's better to use 'git clone' with a path to original repo on local disk, as that will preserve commit history in the copy. Signed-off-by: Alexander Kanavin <alex@linutronix.de> --- .../bblayers/setupwriters/oe-local-copy.py | 41 +++++++++++++++++++ meta/lib/oeqa/selftest/cases/bblayers.py | 13 ++++++ 2 files changed, 54 insertions(+) create mode 100644 meta/lib/bblayers/setupwriters/oe-local-copy.py