Skip to contentSkip to conversation

bitbake-setup: add the proof of concept implementation

RFC PATCH In review Alexander Kanavin 2 participants 3 messages Dec 18, 2024 – Dec 23, 2024

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 bitbake-setup: add the proof of concept implementation

From: Alexander Kanavin <[email protected]>

For the rationale and design guidelines please see this message:
https://lists.openembedded.org/g/openembedded-architecture/message/1913

Left out for now but will be done later:
- tighten the terminology: 'build' and 'configuration' are each used to refer to several distinct things, and should be replaced by specific, unambigous terms
- tests
- documentation
- official configuration repository

1. If you don't know where to start, list available configurations, and pick one:

===

alex@Zen2:/srv/work/alex/bitbake$ bin/bitbake-setup list
Default parameter values are in /home/alex/.bitbake-setup/config - adjust as needed.

Fetching configuration repository git://github.com/kanavin/bitbake-setup-configurations.git;protocol=https;branch=main;rev=main into /home/alex/.bitbake-setup/configurations

Available configurations:
poky-alex Poky reference distribution, with alex fixes
poky-kirkstone Poky reference distribution, kirkstone long term support release (supported until April 2026)
poky-ng Poky-ng configuration: like poky but built from individual repositories
===

2. Then build is initialized this way:
===

alex@Zen2:/srv/work/alex/bitbake$ bin/bitbake-setup init poky-ng
Default parameter values are in /home/alex/.bitbake-setup/config - adjust as needed.

Initializing a poky-ng build in /home/alex/builds/poky-ng
Fetching configuration repository git://github.com/kanavin/bitbake-setup-configurations.git;protocol=https;branch=main;rev=main into /home/alex/.bitbake-setup/configurations Fetching layer/tool repository bitbake into /home/alex/builds/poky-ng/layers/bitbake
Fetching layer/tool repository openembedded-core into /home/alex/builds/poky-ng/layers/openembedded-core
Fetching layer/tool repository meta-yocto into /home/alex/builds/poky-ng/layers/meta-yocto
Fetching layer/tool repository yocto-docs into /home/alex/builds/poky-ng/layers/yocto-docs

Setting up configuration in /home/alex/builds/poky-ng/build-default Configuration summary:
This is the default build configuration for the openembedded-core layer.

Additional information is in /home/alex/builds/poky-ng/build-default/conf/conf-notes.txt

Run /home/alex/builds/poky-ng/build-default/build.sh to execute the default build targets for this configuration. Source the environment using '. /home/alex/builds/poky-ng/build-default/init-build-env' to run builds from the command line. The bitbake build configuration (local.conf, bblayers.conf and more) can be found in /home/alex/builds/poky-ng/build-default/conf
===

Note: 'init' sub-command can also take a path or a URL with a configuration file directly. You can see how those files look like here:
https://github.com/kanavin/bitbake-setup-configurations

3. The above message refers to a one-liner shell script that would build the targets specified in the chosen configuration:
===

alex@Zen2:/srv/work/alex/bitbake$ cat /home/alex/builds/poky-alex/build-gadget/build.sh
. /home/alex/builds/poky-alex/build-gadget/init-build-env && bitbake core-image-minimal
===

4. You should also source the environment, and then subsequent status/update commands will not require a parameter telling bitbake-setup where the initialized build is.

5. To check if the build configuration needs to be updated, run:
===
Default parameter values are in /home/alex/.bitbake-setup/config - adjust as needed.

Fetching configuration repository git://github.com/kanavin/bitbake-setup-configurations.git;protocol=https;branch=main;rev=main into /home/alex/.bitbake-setup/configurations Configuration in /home/alex/builds/poky-ng/ has not changed.
===

If the configuration has changed, you will see the difference:
===

alex@Zen2:/srv/work/alex/bitbake$ bin/bitbake-setup status
...
Top level configuration in /home/alex/builds/poky-alex has changed:
--- /home/alex/builds/poky-alex/config/poky-alex.conf.json	2024-12-16 11:43:24.077446096 +0100
+++ /home/alex/builds/poky-alex/config-tmp-asoubw5u/poky-alex.conf.json	2024-12-16 11:47:43.237104405 +0100
@@ -7,7 +7,7 @@
                         "uri": "git://git.yoctoproject.org/poky-contrib"
                     }
                 },
-                "rev": "akanavin/sstate-for-all"
+                "rev": "akanavin/bitbake-setup-testing"
             },
             "path": "poky"
         }
===

If the configuration has not changed, but layer revisions referred to it have (for example if the configuration specifies a tip of a branch), you will see that too:
===

alex@Zen2:/srv/work/alex/bitbake$ bin/bitbake-setup status
...
Layer repository git://git.yoctoproject.org/poky-contrib checked out into /home/alex/builds/poky-alex/layers/poky updated revision akanavin/sstate-for-all from 6b842ba55f996b27c900e3de78ceac8cb3b1c492 to aeb73e29379fe6007a8adc8d94c1ac18a93e68de
===

6. If the configuration has changed, you can bring it in sync with:
===

alex@Zen2:/srv/work/alex/bitbake$ bin/bitbake-setup update ~/builds/poky-alex/
Default parameter values are in /home/alex/.bitbake-setup/config - adjust as needed.

Fetching configuration repository git://github.com/kanavin/bitbake-setup-configurations.git;protocol=https;branch=main;rev=main into /home/alex/.bitbake-setup/configurations
Layer repository git://git.yoctoproject.org/poky-contrib checked out into /home/alex/builds/poky-alex/layers/poky updated revision akanavin/bitbake-setup-testing from d174acad934f8ad1fe303abc5705733e15542859 to a3d2ee10045f8c1151d680ad97994c5d6cf51ece Fetching layer/tool repository poky into /home/alex/builds/poky-alex/layers/poky

Setting up configuration in /home/alex/builds/poky-alex/build-gadget
Existing bitbake congfiguration directory renamed to /home/alex/builds/poky-alex/build-gadget/conf-backup.20241216115007 The bitbake configuration has changed:

home/alex/builds/poky-alex/build-gadget/conf/local.conf renamed from home/alex/builds/poky-alex/build-gadget/conf-backup.20241216115007/local.conf +0 -2
diff -uNr /home/alex/builds/poky-alex/build-gadget/conf-backup.20241216115007/local.conf /home/alex/builds/poky-alex/build-gadget/conf/local.conf
@@ -287,5 +287,3 @@
 # track the version of this file when it was generated. This can safely be ignored if
 # this doesn't mean anything to you.
 CONF_VERSION = "2"
-
-TCLIBC = "musl"

Configuration summary:
This is the default build configuration for the Poky reference distribution.

Additional information is in /home/alex/builds/poky-alex/build-gadget/conf/conf-notes.txt

Run /home/alex/builds/poky-alex/build-gadget/build.sh to execute the default build targets for this configuration. Source the environment using '. /home/alex/builds/poky-alex/build-gadget/init-build-env' to run builds from the command line. The bitbake build configuration (local.conf, bblayers.conf and more) can be found in /home/alex/builds/poky-alex/build-gadget/conf
===

Note that it will also rename/preserve the existing build/conf directory, and print changes in bitbake configuration (diff of content of build/conf/) if that has changed. I can't at the moment think of anything more clever that is also not much more brittle or complex to implement, but open to suggestions.

7. To make it easier to review the code, please also review the data it's operating on:
===

alex@Zen2:/srv/work/alex/bitbake$ ls ~/.bitbake-setup/
cache  configurations  downloads
alex@Zen2:/srv/work/alex/bitbake$ ls ~/builds/poky-alex/
build  config  config-upstream.json  layers
===

This commit includes a fix by Ryan Eatmon <[email protected]>:
https://github.com/kanavin/bitbake/pull/1

---
 bin/bitbake-setup | 404 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 404 insertions(+)
 create mode 100755 bin/bitbake-setup
bin/bitbake-setup new file +404 -0

404 lines not on this page · raw message

Signature · 1 line
2.39.5
#1 lore raw
Quoted 9 lines · Alexander Kanavin via lists.openembedded.org

From: Alexander Kanavin <[email protected]>

%< SNIP %<

3. The above message refers to a one-liner shell script that would build the targets
specified in the chosen configuration:
===

Quoted 6 lines
alex@Zen2:/srv/work/alex/bitbake$ cat
/home/alex/builds/poky-alex/build-gadget/build.sh
. /home/alex/builds/poky-alex/build-gadget/init-build-env && bitbake
core-image-minimal
===

Would it be possible to change that to just "build" rather than "build.sh"? For
an executable, there really is no need to telegraph the language it was written
in. It also makes things very difficult later on if a more sophisticated implementation in a different language is warranted.

Related: https://google.github.io/styleguide/shellguide.html#file-extensions

..Ch:W..

Signature · 2 lines
*"Perfection must be reached by degrees; she requires the slow hand of
time." - Voltaire*
#2 lore raw
Quoted 6 lines · Chuck Wolber

Would it be possible to change that to just "build" rather than "build.sh"? For an executable, there really is no need to telegraph the language it was written in. It also makes things very difficult later on if a more sophisticated implementation in a different language is warranted.

Related: https://google.github.io/styleguide/shellguide.html#file-extensions

Sure. I changed that to 'build-targets'. It might be good to consider if that should be even called 'build-default-targets' in case we might want to support 'other' kinds of targets as well, and how that should be reflected in the json structure.

Alex