mirror of
https://git.yoctoproject.org/git/poky
synced 2026-01-01 13:58:04 +00:00
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>
This commit is contained in:
parent
39af683c76
commit
60d995ccc4
|
|
@ -162,8 +162,31 @@ def setup_bitbake_build(bitbake_config, layerdir, builddir, thisdir):
|
|||
builddir = os.path.realpath(builddir)
|
||||
cmd = "cd {}\nset {}\n. ./oe-init-build-env\n".format(oeinitbuildenvdir, builddir)
|
||||
initbuild_in_builddir = os.path.join(builddir, 'init-build-env')
|
||||
|
||||
with open(initbuild_in_builddir, 'w') as f:
|
||||
f.write(cmd)
|
||||
f.write("# init-build-env wrapper created by bitbake-setup\n")
|
||||
f.write(cmd + '\n')
|
||||
|
||||
def _prepend_passthrough_to_init_build_env(builddir):
|
||||
env = bitbake_config.get("bb-env-passthrough-additions")
|
||||
if not env:
|
||||
return
|
||||
|
||||
initbuild_in_builddir = os.path.join(builddir, 'init-build-env')
|
||||
with open(initbuild_in_builddir) as f:
|
||||
content = f.read()
|
||||
|
||||
joined = " \\\n".join(env)
|
||||
env = "export BB_ENV_PASSTHROUGH_ADDITIONS=\" \\\n"
|
||||
env += "${BB_ENV_PASSTHROUGH_ADDITIONS} \\\n"
|
||||
env += joined
|
||||
env += '"'
|
||||
|
||||
with open(initbuild_in_builddir, 'w') as f:
|
||||
f.write("# environment passthrough added by bitbake-setup\n")
|
||||
f.write(env + '\n')
|
||||
f.write('\n')
|
||||
f.write(content)
|
||||
|
||||
bitbake_builddir = os.path.join(builddir, "build")
|
||||
print("Setting up bitbake configuration in\n {}\n".format(bitbake_builddir))
|
||||
|
|
@ -194,6 +217,8 @@ def setup_bitbake_build(bitbake_config, layerdir, builddir, thisdir):
|
|||
return
|
||||
_make_init_build_env(bitbake_builddir, os.path.realpath(oeinitbuildenvdir))
|
||||
|
||||
_prepend_passthrough_to_init_build_env(bitbake_builddir)
|
||||
|
||||
siteconf_symlink = os.path.join(bitbake_confdir, "site.conf")
|
||||
siteconf = os.path.normpath(os.path.join(builddir, '..', "site.conf"))
|
||||
if os.path.lexists(siteconf_symlink):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user