summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2024-02-16 12:52:22 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-02-19 11:47:53 +0000
commitc390b2e615930b60db0d7f3e72d056e0c67ef5bc (patch)
tree1b23fb12a523e91ae3762b63fbb00608fd3cd694 /meta/lib/oeqa
parent01d0ee1b834ef58fbb1f6a69a81c0e9a4e2a83d9 (diff)
downloadpoky-c390b2e615930b60db0d7f3e72d056e0c67ef5bc.tar.gz
oe-setup-build: add a tool for discovering config templates and setting up builds
This is another piece of the puzzle in setting up builds from nothing without having to write custom scripts or use external tools. After layers have been fetched and placed into their respective locations by oe-setup-layers, one would surely want to proceed to the actual build, and here's how: 1. Without arguments the tool reads available layers from .oe-layers.json file (written out by oe-setup-layers or a fallback under scripts/), prints what templates it has found, and asks the user to select one, as seen below. This will land the user in a shell ready to run bitbake: ============================================= alex@Zen2:/srv/work/alex$ ./setup-build Available build configurations: 1. alex-configuration-gadget This configuration will set up a build for the purposes of supporting gadget. 2. alex-configuration-gizmo This configuration allows building a gizmo. 3. poky-default This is the default build configuration for the Poky reference distribution. Re-run with 'list -v' to see additional information. Please choose a configuration by its number: 1 Running: TEMPLATECONF=/srv/work/alex/meta-alex/conf/templates/configuration-gadget . /srv/work/alex/poky/oe-init-build-env /srv/work/alex/build-alex-configuration-gadget && /bin/bash You had no conf/local.conf file. This configuration file has therefore been created for you from /srv/work/alex/meta-alex/conf/templates/configuration-gadget/local.conf.sample You may wish to edit it to, for example, select a different MACHINE (target hardware). You had no conf/bblayers.conf file. This configuration file has therefore been created for you from /srv/work/alex/meta-alex/conf/templates/configuration-gadget/bblayers.conf.sample To add additional metadata layers into your configuration please add entries to conf/bblayers.conf. The Yocto Project has extensive documentation about OE including a reference manual which can be found at: https://docs.yoctoproject.org For more information about OpenEmbedded see the website: https://www.openembedded.org/ This configuration will set up a build for the purposes of supporting gadget. Please refer to meta-alex/README for additional details and available bitbake targets. ============================================== 2. It is also possible to list available configurations without selecting one using 'setup-build list' or to select and setup one non-interactively with 'setup-build setup'. 3. The full set of command line options is: $ ./setup-build --help usage: setup-build [-h] [--layerlist LAYERLIST] {list,setup} ... A script that discovers available build configurations and sets up a build environment based on one of them. Run without arguments to choose one interactively. positional arguments: {list,setup} list List available configurations setup Set up a build environment and open a shell session with it, ready to run builds. optional arguments: -h, --help show this help message and exit --layerlist LAYERLIST Where to look for available layers (as written out by setup-layers script) (default is /srv/work/alex/.oe-layers.json). $ ./setup-build list --help usage: setup-build list [-h] [-v] optional arguments: -h, --help show this help message and exit -v Print detailed information and usage notes for each available build configuration. $ ./setup-build setup --help usage: setup-build setup [-h] [-c configuration_name] [-b build_path] [--no-shell] optional arguments: -h, --help show this help message and exit -c configuration_name Use a build configuration configuration_name to set up a build environment (run this script with 'list' to see what is available) -b build_path Set up a build directory in build_path (run this script with 'list -v' to see where it would be by default) --no-shell Create a build directory but do not start a shell session with the build environment from it. 4. There's an an added hint in oe-setup-layers about how to proceed (as it is really not user-friendly to fetch the layer repos successfully and then exit without a word), and a symlink to the script from the top level layer checkout directory. 5. The selftest to check layer setup has been adjusted to run a basic check for template discovery and build setup. The revision of poky to be cloned has been bumped to 4.1, as that's the first version with a default template in a standard location. (From OE-Core rev: 1360b64e88cda7dddfb0eca6a64f70c13dafb890) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/selftest/cases/bblayers.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py
index f2460cb451..e2009496ad 100644
--- a/meta/lib/oeqa/selftest/cases/bblayers.py
+++ b/meta/lib/oeqa/selftest/cases/bblayers.py
@@ -152,12 +152,12 @@ class BitbakeLayers(OESelftestTestCase):
152 self.validate_layersjson(jsonfile) 152 self.validate_layersjson(jsonfile)
153 153
154 # The revision-under-test may not necessarily be available on the remote server, 154 # The revision-under-test may not necessarily be available on the remote server,
155 # so replace it with a revision that has a yocto-4.0 tag. 155 # so replace it with a revision that has a yocto-4.1 tag.
156 import json 156 import json
157 with open(jsonfile) as f: 157 with open(jsonfile) as f:
158 data = json.load(f) 158 data = json.load(f)
159 for s in data['sources']: 159 for s in data['sources']:
160 data['sources'][s]['git-remote']['rev'] = '00cfdde791a0176c134f31e5a09eff725e75b905' 160 data['sources'][s]['git-remote']['rev'] = '5200799866b92259e855051112520006e1aaaac0'
161 with open(jsonfile, 'w') as f: 161 with open(jsonfile, 'w') as f:
162 json.dump(data, f) 162 json.dump(data, f)
163 163
@@ -165,3 +165,25 @@ class BitbakeLayers(OESelftestTestCase):
165 result = runCmd('{}/setup-layers --destdir {}'.format(self.testlayer_path, testcheckoutdir)) 165 result = runCmd('{}/setup-layers --destdir {}'.format(self.testlayer_path, testcheckoutdir))
166 layers_json = os.path.join(testcheckoutdir, ".oe-layers.json") 166 layers_json = os.path.join(testcheckoutdir, ".oe-layers.json")
167 self.assertTrue(os.path.exists(layers_json), "File {} not found in test layer checkout".format(layers_json)) 167 self.assertTrue(os.path.exists(layers_json), "File {} not found in test layer checkout".format(layers_json))
168
169 # As setup-layers checkout out an old revision of poky, there is no setup-build symlink,
170 # and we need to run oe-setup-build directly from the current poky tree under test
171 oe_setup_build = os.path.join(get_bb_var('COREBASE'), 'scripts/oe-setup-build')
172 oe_setup_build_l = os.path.join(testcheckoutdir, 'setup-build')
173 os.symlink(oe_setup_build,oe_setup_build_l)
174
175 cmd = '{} --layerlist {} list -v'.format(oe_setup_build_l, layers_json)
176 result = runCmd(cmd)
177 cond = "conf/templates/default" in result.output
178 self.assertTrue(cond, "Incorrect output from {}: {}".format(cmd, result.output))
179
180 # rather than hardcode the build setup cmdline here, let's actually run what the tool suggests to the user
181 conf = None
182 if 'poky-default' in result.output:
183 conf = 'poky-default'
184 elif 'meta-default' in result.output:
185 conf = 'meta-default'
186 self.assertIsNotNone(conf, "Could not find the configuration to set up a build in the output: {}".format(result.output))
187
188 cmd = '{} --layerlist {} setup -c {} --no-shell'.format(oe_setup_build_l, layers_json, conf)
189 result = runCmd(cmd)