diff options
| author | Johannes Schneider <johannes.schneider@leica-geosystems.com> | 2025-10-08 18:56:56 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-10-14 11:24:57 +0100 |
| commit | 60d995ccc49ee817dfdb1f2988357f9a9250d11f (patch) | |
| tree | a0af04ab7595c3d9cfa5c5552708abef1b3c47f9 /bitbake/bin/bitbake-setup | |
| parent | 39af683c763490867e20f05ec1a0d195f1384735 (diff) | |
| download | poky-60d995ccc49ee817dfdb1f2988357f9a9250d11f.tar.gz | |
bitbake: bitbake-setup: support adding environment-passthroughs to the init-build-env
This patch adds support for extending the BB_ENV_PASSTHROUGH_ADDITIONS
environment variable from within the `init-build-env` wrapper script -
generated by either oe-core's oe-setup-build, or by `bitbake-setup` -
based on per-configuration JSON settings.
This enables CI workflows to inject environment-specific data - such
as build number, host, build type, or credentials required to fetch
from certain SRC_URIs - which cannot be captured via configuration
fragments alone. These variables are now handled early in the setup
process and exported directly into the build environment.
Example:
"bb-env-passthrough-additions": [
"ACME_DIR",
"ARTIFACTORY_TOKEN",
"ARTIFACTORY_USERNAME",
"GITHUB_TOKEN",
"GITHUB_PROTOCOL",
"KEY"
]
<snip>
the resulting 'init-build-env' would then be:
# environment passthrough added by bitbake-setup
export BB_ENV_PASSTHROUGH_ADDITIONS=" \
$BB_ENV_PASSTHROUGH_ADDITIONS \
ACME_DIR \
ARTIFACTORY_TOKEN \
ARTIFACTORY_USERNAME \
GITHUB_TOKEN \
GITHUB_PROTOCOL \
KEY"
# init-build-env wrapper created by bitbake-setup
. /tmp/acme_master-acme-distro_acme-machine_bang/layers/openembedded-core/oe-init-build-env /tmp/bitbake-setup/gs/acme_master-acme-distro_acme-machine_bang/build
(Bitbake rev: 782ab99e7a04fba43bdcf5763a6280785944ae3f)
Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin/bitbake-setup')
| -rwxr-xr-x | bitbake/bin/bitbake-setup | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/bitbake/bin/bitbake-setup b/bitbake/bin/bitbake-setup index e7b955213e..7878cd9394 100755 --- a/bitbake/bin/bitbake-setup +++ b/bitbake/bin/bitbake-setup | |||
| @@ -162,8 +162,31 @@ def setup_bitbake_build(bitbake_config, layerdir, builddir, thisdir): | |||
| 162 | builddir = os.path.realpath(builddir) | 162 | builddir = os.path.realpath(builddir) |
| 163 | cmd = "cd {}\nset {}\n. ./oe-init-build-env\n".format(oeinitbuildenvdir, builddir) | 163 | cmd = "cd {}\nset {}\n. ./oe-init-build-env\n".format(oeinitbuildenvdir, builddir) |
| 164 | initbuild_in_builddir = os.path.join(builddir, 'init-build-env') | 164 | initbuild_in_builddir = os.path.join(builddir, 'init-build-env') |
| 165 | |||
| 165 | with open(initbuild_in_builddir, 'w') as f: | 166 | with open(initbuild_in_builddir, 'w') as f: |
| 166 | f.write(cmd) | 167 | f.write("# init-build-env wrapper created by bitbake-setup\n") |
| 168 | f.write(cmd + '\n') | ||
| 169 | |||
| 170 | def _prepend_passthrough_to_init_build_env(builddir): | ||
| 171 | env = bitbake_config.get("bb-env-passthrough-additions") | ||
| 172 | if not env: | ||
| 173 | return | ||
| 174 | |||
| 175 | initbuild_in_builddir = os.path.join(builddir, 'init-build-env') | ||
| 176 | with open(initbuild_in_builddir) as f: | ||
| 177 | content = f.read() | ||
| 178 | |||
| 179 | joined = " \\\n".join(env) | ||
| 180 | env = "export BB_ENV_PASSTHROUGH_ADDITIONS=\" \\\n" | ||
| 181 | env += "${BB_ENV_PASSTHROUGH_ADDITIONS} \\\n" | ||
| 182 | env += joined | ||
| 183 | env += '"' | ||
| 184 | |||
| 185 | with open(initbuild_in_builddir, 'w') as f: | ||
| 186 | f.write("# environment passthrough added by bitbake-setup\n") | ||
| 187 | f.write(env + '\n') | ||
| 188 | f.write('\n') | ||
| 189 | f.write(content) | ||
| 167 | 190 | ||
| 168 | bitbake_builddir = os.path.join(builddir, "build") | 191 | bitbake_builddir = os.path.join(builddir, "build") |
| 169 | print("Setting up bitbake configuration in\n {}\n".format(bitbake_builddir)) | 192 | print("Setting up bitbake configuration in\n {}\n".format(bitbake_builddir)) |
| @@ -194,6 +217,8 @@ def setup_bitbake_build(bitbake_config, layerdir, builddir, thisdir): | |||
| 194 | return | 217 | return |
| 195 | _make_init_build_env(bitbake_builddir, os.path.realpath(oeinitbuildenvdir)) | 218 | _make_init_build_env(bitbake_builddir, os.path.realpath(oeinitbuildenvdir)) |
| 196 | 219 | ||
| 220 | _prepend_passthrough_to_init_build_env(bitbake_builddir) | ||
| 221 | |||
| 197 | siteconf_symlink = os.path.join(bitbake_confdir, "site.conf") | 222 | siteconf_symlink = os.path.join(bitbake_confdir, "site.conf") |
| 198 | siteconf = os.path.normpath(os.path.join(builddir, '..', "site.conf")) | 223 | siteconf = os.path.normpath(os.path.join(builddir, '..', "site.conf")) |
| 199 | if os.path.lexists(siteconf_symlink): | 224 | if os.path.lexists(siteconf_symlink): |
