bitbake-setup: pass install-buildtools options from config and CLI
PATCH 1/1 bitbake-setup: pass install-buildtools options from config and CLI
Allow distro-specific buildtools to be configured with a custom URL, filename, and SDK name via an install-buildtools section in config-upstream.json. Expose the same options as CLI arguments: --url, --filename, --sdk-name, --no-check. CLI arguments take precedence over config values.
This requires the --sdk-name option to be available in oe-scripts/install-buildtools from openembedded-core.
AI-Generated: Kiro with Claude Opus 4.6
--- bin/bitbake-setup | 49 +++++++++++- .../bitbake-user-manual-environment-setup.rst | 33 ++++++++ lib/bb/tests/setup.py | 80 ++++++++++++++++++- setup-schema/bitbake-setup.schema.json | 30 +++++++ 4 files changed, 188 insertions(+), 4 deletions(-)
bin/bitbake-setup +47 -2
@@ -1052,10 +1052,49 @@ def install_buildtools(top_dir, settings, args, d): return shutil.rmtree(buildtools_install_dir) - install_buildtools = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') + install_buildtools_script = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') buildtools_download_dir = add_unique_timestamp_to_path(os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) + + buildtools_config = {} + upstream_config_path = os.path.join(args.setup_dir, 'config', 'config-upstream.json') + try: + with open(upstream_config_path) as f: + upstream_config = json.load(f) + buildtools_config = upstream_config.get('data', {}).get('bitbake-setup', {}).get('install-buildtools', {}) + except FileNotFoundError: + pass + except json.JSONDecodeError as e: + logger.error("Failed to parse %s: %s" % (upstream_config_path, e)) + sys.exit(1) + + url = args.url if args.url is not None else buildtools_config.get('url') + filename = args.filename if args.filename is not None else buildtools_config.get('filename') + sdk_name = args.sdk_name if args.sdk_name is not None else buildtools_config.get('sdk-name') + + for name, value in (("url", url), ("filename", filename), ("sdk-name", sdk_name)): + if value == "": + logger.error("%s is empty" % name) + sys.exit(1) + no_check = args.no_check if args.no_check is not None else buildtools_config.get('no-check', False) + + if (url is None) != (filename is None): + logger.error("url and filename must both be set (from CLI or config) or both omitted") + sys.exit(1) + + cmd = [ + install_buildtools_script, + '-d', buildtools_install_dir, + '--downloads-directory', buildtools_download_dir, + ] + if url and filename: + cmd += ['--url', url, '--filename', filename] + if sdk_name: + cmd += ['--sdk-name', sdk_name] + if no_check: + cmd.append('--no-check') + logger.plain("Buildtools archive is downloaded into {} and its content installed into {}".format(buildtools_download_dir, buildtools_install_dir)) - subprocess.check_call("{} -d {} --downloads-directory {}".format(install_buildtools, buildtools_install_dir, buildtools_download_dir), shell=True) + subprocess.check_call(cmd) def create_siteconf(top_dir, non_interactive, settings): siteconfpath = os.path.join(top_dir, 'site.conf')
@@ -1285,6 +1324,12 @@ def main(): parser_install_buildtools = subparsers.add_parser('install-buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine') add_setup_dir_arg(parser_install_buildtools) parser_install_buildtools.add_argument('--force', action='store_true', help='Force a reinstall of buildtools over the previous installation.') + parser_install_buildtools.add_argument('--url', action='store', help='URL from where to fetch the buildtools SDK installer, not including filename. Requires --filename. Overrides config value.') + parser_install_buildtools.add_argument('--filename', action='store', help='Filename for the buildtools SDK installer. Requires --url. Overrides config value.') + parser_install_buildtools.add_argument('--sdk-name', action='store', default=None, help='SDK name used in the environment setup script (e.g. customsdk). Overrides config value.') + check_group = parser_install_buildtools.add_mutually_exclusive_group() + check_group.add_argument('--no-check', action='store_const', const=True, default=None, dest='no_check', help='Disable checksum validation. Overrides config value.') + check_group.add_argument('--check', action='store_const', const=False, dest='no_check', help='Enable checksum validation. Overrides config no-check: true.') parser_install_buildtools.set_defaults(func=install_buildtools) parser_settings_arg_global = argparse.ArgumentParser(add_help=False)
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +33 -0
@@ -660,6 +660,39 @@ In addition, the command can take the following arguments: - ``--setup-dir``: path to the :term:`Setup` to check to status for. Not required if :term:`BBPATH` is already configured. +- ``--url``: URL from where to fetch the buildtools SDK installer, not + including filename. Requires ``--filename``. Overrides the value from the + configuration file. + +- ``--filename``: filename of the buildtools installer. Requires ``--url``. + Overrides the value from the configuration file. + +- ``--sdk-name``: SDK name used in the environment setup script installed + by the buildtools tarball (e.g. ``customsdk`` for + ``environment-setup-<arch>-customsdk-linux``). Defaults to ``pokysdk``. + Overrides the value from the configuration file. + +- ``--no-check``: disable checksum validation when the server does not + provide a ``.sha256sum`` file alongside the installer. Checksum + validation is enabled by default. + +The ``url``, ``filename``, ``sdk-name`` and ``no-check`` options can also be +set in the :term:`Configuration File` under the ``bitbake-setup`` section:: + + "bitbake-setup": { + "install-buildtools": { + "url": "https://example.com/buildtools", + "filename": "x86_64-buildtools-extended-nativesdk-standalone-5.0.sh", + "sdk-name": "customsdk", + "no-check": true + }, + "configurations": [ ... ] + } + +CLI arguments take precedence over values in the configuration file. +Note that setting ``no-check`` to ``false`` in the configuration file has no +effect; omit the key to use the default (enabled). + .. _ref-bbsetup-command-settings: ``bitbake-setup settings``
lib/bb/tests/setup.py +78 -2
103 lines not on this page · raw message
setup-schema/bitbake-setup.schema.json +30 -0
@@ -141,6 +141,36 @@ }, "additionalProperties": false } + }, + "install-buildtools": { + "type": "object", + "description": "Optional settings passed through to oe-scripts/install-buildtools", + "properties": { + "url": { + "type": "string", + "minLength": 1, + "description": "URL from where to fetch the buildtools SDK installer, not including filename. Requires 'filename'." + }, + "filename": { + "type": "string", + "minLength": 1, + "description": "Filename for the buildtools SDK installer. Requires 'url'." + }, + "sdk-name": { + "type": "string", + "minLength": 1, + "description": "SDK name in the environment setup script (e.g. 'customsdk'). Defaults to 'pokysdk'." + }, + "no-check": { + "type": "boolean", + "description": "Set to true to disable checksum validation when the server does not provide a .sha256sum file. no-check: false is equivalent to omitting the key." + } + }, + "dependencies": { + "url": ["filename"], + "filename": ["url"] + }, + "additionalProperties": false } }, "additionalProperties": false
Signature · 1 line
2.34.1
Quoted 8 lines · Jaipaul Cheernam via lists.openembedded.org
Allow distro-specific buildtools to be configured with a custom URL, filename, and SDK name via an install-buildtools section in config-upstream.json. Expose the same options as CLI arguments: --url, --filename, --sdk-name, --no-check. CLI arguments take precedence over config values.
This requires the --sdk-name option to be available in oe-scripts/install-buildtools from openembedded-core.
Can you please describe the use case? Presumably this is useful in your environment, I'd like to understand the specifics of what you put in the custom buildtools archive and why it has to be there and not built via recipes.
Alex
Hi Alex,
Any downstream distro that builds its own extended buildtools tarball under a non-Poky distro name hits a FileNotFoundError because install-buildtools hardcodes pokysdk when looking for environment-setup-<arch>-pokysdk-linux. The --sdk-name option fixes that hardcoded assumption.
The archive itself contains the same tools as upstream extended buildtools — it can't be provided via recipes because buildtools exist specifically to bootstrap the host environment before BitBake can run.
The --url and --filename options are needed for projects that host their buildtools on an internal server rather than yoctoproject.org, and want to pin a specific version across the team without requiring manual arguments on every invocation.
The workaround today is to pass arguments manually or modify wrapper scripts, which is probably why this hasn't surfaced as a bug report before.
The --sdk-name option itself is introduced in a companion patch to oe-scripts/install-buildtools in openembedded-core:
https://lists.openembedded.org/g/openembedded-core/topic/patch_install_buildtools/119814299
Thanks,
Jaipaul Cheernam
From: Alexander Kanavin <[email protected]>
Date: Monday, 15 June 2026 at 15:32
To: Jaipaul Cheernam <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [bitbake-devel] [PATCH] bitbake-setup: pass install-buildtools options from config and CLI
Quoted 8 lines · Jaipaul Cheernam via lists.openembedded.org
Allow distro-specific buildtools to be configured with a custom URL, filename, and SDK name via an install-buildtools section in config-upstream.json. Expose the same options as CLI arguments: --url, --filename, --sdk-name, --no-check. CLI arguments take precedence over config values.
This requires the --sdk-name option to be available in oe-scripts/install-buildtools from openembedded-core.
Can you please describe the use case? Presumably this is useful in your environment, I'd like to understand the specifics of what you put in the custom buildtools archive and why it has to be there and not built via recipes.
Alex
Quoted 10 lines · Jaipaul Cheernam
The archive itself contains the same tools as upstream extended buildtools — it can't be provided via recipes because buildtools exist specifically to bootstrap the host environment before BitBake can run.
The --url and --filename options are needed for projects that host their buildtools on an internal server rather than yoctoproject.org, and want to pin a specific version across the team without requiring manual arguments on every invocation.
The workaround today is to pass arguments manually or modify wrapper scripts, which is probably why this hasn't surfaced as a bug report before.
The --sdk-name option itself is introduced in a companion patch to oe-scripts/install-buildtools in openembedded-core:
https://lists.openembedded.org/g/openembedded-core/topic/patch_install_buildtools/119814299
Thanks. I'm broadly in favor of this, but I don't know what the bitbake patch reviewers will say, and especially RP :) Buildtools can be used to do isolated, reproducible 'container builds' without actual containers, and I like that.
I wonder if the archive should be downloaded by bitbake-setup itself using bitbake fetchers (similar to how layers are obtained), and then given to install-buildtools as a local file, or even executed directly. There are benefits to this: it will be preserved in the download cache together with the layers and upstream components (which helps if upstream server isn't available or altogether disappears), and checksummed against sha256sum provided in the config (which adds a reproducibility check, and protection against supply chain attacks, similar to tarball recipes). What you think?
Alex
Quoted 8 lines · Jaipaul Cheernam via lists.openembedded.org
Allow distro-specific buildtools to be configured with a custom URL, filename, and SDK name via an install-buildtools section in config-upstream.json. Expose the same options as CLI arguments: --url, --filename, --sdk-name, --no-check. CLI arguments take precedence over config values.
This requires the --sdk-name option to be available in oe-scripts/install-buildtools from openembedded-core.
I replied to the oe-core patch, lets just remove the need to have -- sdk-name, I don't think we need that. I also don't understand why you want/need the --no-check option, we should be able to tell if we should be checking the checksum or not? If that means fixing the install script, so be it.
Cheers,
Richard
Hi Richard,
Agreed on removing --sdk-name and I have sent Patch v2 for review in oe-core.
For --no-check — I'm fine removing it and having the install-buildtools auto-detect, but we need to decide on the failure mode: if the checksum file can't be fetched (404 or network error), should we:
(a) warn and continue the install without verification, or
(b) hard fail and refuse to install?
If (a), we're effectively auto---no-check on failure, which may silently skip validation on transient network issues. If (b), users with custom/local URLs that don't host checksum files would have no way to install without us re-adding an override flag or having them to add checksum file.
I checked the history why "--no-check” was added and it was part of bf902a810f98f55dd9e8cb9e6c6b0903f9902157
What's your preference?
Based on review verdict on oe-core patch, I will send patch v2 here.
Regards,
Jaipaul Cheernam
From: Richard Purdie <[email protected]>
Date: Tuesday, 16 June 2026 at 12:07
To: Jaipaul Cheernam <[email protected]>; [email protected] <[email protected]>
Subject: Re: [bitbake-devel] [PATCH] bitbake-setup: pass install-buildtools options from config and CLI
Quoted 8 lines · Jaipaul Cheernam via lists.openembedded.org
Allow distro-specific buildtools to be configured with a custom URL, filename, and SDK name via an install-buildtools section in config-upstream.json. Expose the same options as CLI arguments: --url, --filename, --sdk-name, --no-check. CLI arguments take precedence over config values.
This requires the --sdk-name option to be available in oe-scripts/install-buildtools from openembedded-core.
I replied to the oe-core patch, lets just remove the need to have -- sdk-name, I don't think we need that. I also don't understand why you want/need the --no-check option, we should be able to tell if we should be checking the checksum or not? If that means fixing the install script, so be it.
Cheers,
Richard
Quoted 8 lines · Jaipaul Cheernam via lists.openembedded.org
Agreed on removing --sdk-name and I have sent Patch v2 for review in oe-core.
For --no-check — I'm fine removing it and having the install-buildtools auto-detect, but we need to decide on the failure mode: if the checksum file can't be fetched (404 or network error), should we:
(a) warn and continue the install without verification, or
(b) hard fail and refuse to install?
Quoted 6 lines
If (a), we're effectively auto---no-check on failure, which may silently skip validation on transient network issues. If (b), users with custom/local URLs that don't host checksum files would have no way to install without us re-adding an override flag or having them to add checksum file.
I checked the history why "--no-check” was added and it was part of
bf902a810f98f55dd9e8cb9e6c6b0903f9902157What's your preference?
Please note my comment in this thread. If we use bitbake fetcher with checksum in a bitbake-setup config file, then the checksum would be enforced in a way that is secure against tampering or accidental replacement.
Alex
Hi Alex and Richard,
I am in favour of this approach. Here's what I'm thinking for the implementation:
1. bitbake-setup downloads the buildtools installer using bb.fetch, with sha256sum specified in the bitbake-setup config (same mechanism as layers). This gives us download caching in DL_DIR and checksum enforcement for free.
2. bitbake-setup then calls install-buildtools --url file://<DL_DIR> --filename <name> --no-check — the --no-check is safe because bb.fetch already validated the sha256. (By writing sha256sum from config into DL_DIR , we can avoid --no-check as well but bit a hacky )
Two options for install-buildtools here:
(a) Update install-buildtools to handle file:// URLs natively — uses the file in-place, avoids a redundant copy of a potentially large (~500MB)
installer to a temp directory.
(b) Leave install-buildtools unchanged — wget already supports file:// and will copy the file to temp. t requires zero changes to
install-buildtools, making this a bitbake-only patch.
I'm fine with either. What's your preference?
Pros:
- Buildtools installer is cached in DL_DIR alongside layers and source tarballs — survives upstream disappearing
- Checksum is in a trusted config file, not fetched from the same server as the installer — protects against supply chain attacks
- Consistent with how everything else is fetched in bitbake-setup
- --no-check remains in install-buildtools but is justified — the caller (bitbake-setup) has already done validation via bb.fetch
Concerns:
- If sha256sum is omitted from config, bb.fetch still downloads but prints a warning about missing checksum (respects BB_STRICT_CHECKSUM if set)
Flow when user runs bitbake-setup install-buildtools --setup-dir ./my-setup:
1. bitbake-setup reads config → gets url, filename, sha256sum
2. Constructs SRC_URI: "https://downloads.../x86_64-buildtools-...5.3.2.sh;sha256sum=a1b2c3..."
3. bb.fetch.Fetch downloads to DL_DIR, validates sha256 (hard fail if mismatch)
4. Calls: install-buildtools --url file://<DL_DIR> --filename <name> --no-check -d ./my-setup/buildtools
5. install-buildtools uses file, makes executable, runs it, sets up env
Config format:
"install-buildtools": {
"url": "https://downloads.yoctoproject.org/releases/yocto/yocto-5.3.2/buildtools",
"filename": "x86_64-buildtools-extended-nativesdk-standalone-5.3.2.sh",
"sha256sum": "a1b2c3d4..."
} If sha256sum is omitted — bb.fetch downloads with a warning (user's choice).
If sha256sum doesn't match — bb.fetch raises FetchError before install-buildtools is ever called.
Standalone usage of install-buildtools remains unchanged.
Does this match what you had in mind?
Regards,
Jaipaul Cheernam
From: Alexander Kanavin <[email protected]>
Date: Tuesday, 16 June 2026 at 16:26
To: Jaipaul Cheernam <[email protected]>
Cc: Richard Purdie <[email protected]>; [email protected] <[email protected]>
Subject: Re: [bitbake-devel] [PATCH] bitbake-setup: pass install-buildtools options from config and CLI
Quoted 8 lines · Jaipaul Cheernam via lists.openembedded.org
Agreed on removing --sdk-name and I have sent Patch v2 for review in oe-core.
For --no-check — I'm fine removing it and having the install-buildtools auto-detect, but we need to decide on the failure mode: if the checksum file can't be fetched (404 or network error), should we:
(a) warn and continue the install without verification, or
(b) hard fail and refuse to install?
Quoted 6 lines
If (a), we're effectively auto---no-check on failure, which may silently skip validation on transient network issues. If (b), users with custom/local URLs that don't host checksum files would have no way to install without us re-adding an override flag or having them to add checksum file.
I checked the history why "--no-check” was added and it was part of
bf902a810f98f55dd9e8cb9e6c6b0903f9902157What's your preference?
Please note my comment in this thread. If we use bitbake fetcher with checksum in a bitbake-setup config file, then the checksum would be enforced in a way that is secure against tampering or accidental replacement.
Alex
Quoted 9 lines · Jaipaul Cheernam
Two options for install-buildtools here:
(a) Update install-buildtools to handle file:// URLs natively — uses the file in-place, avoids a redundant copy of a potentially large (~500MB)
installer to a temp directory.(b) Leave install-buildtools unchanged — wget already supports file:// and will copy the file to temp. t requires zero changes to
install-buildtools, making this a bitbake-only patch.I'm fine with either. What's your preference?
I like option (a). install-buildtools is in oe-core, and can be changed if there's a use case. It can be modified to take a new option --local-file that simply takes a file path and doesn't perform checksum verification at all.
Quoted 7 lines
Config format:
"install-buildtools": { "url": "https://downloads.yoctoproject.org/releases/yocto/yocto-5.3.2/buildtools", "filename": "x86_64-buildtools-extended-nativesdk-standalone-5.3.2.sh", "sha256sum": "a1b2c3d4..." }
url and filename could be combined into one complete url field, no need to split them, as they're not anymore given to install-buildtools script.
Quoted 1 line
If sha256sum is omitted — bb.fetch downloads with a warning (user's choice).
I'd say absence of sha256sum should be a hard error, with a hint about how to add the sum to the file.
Quoted 5 lines
If sha256sum doesn't match — bb.fetch raises FetchError before install-buildtools is ever called.
Standalone usage of install-buildtools remains unchanged.
Does this match what you had in mind?
Yes, more or less :-)
Alex
PATCH v2 1/1 bitbake-setup: use bb.fetch for buildtools installer download
In reply to Jaipaul CheernamWhen url and sha256sum are configured, download the buildtools installer via bb.fetch with checksum enforcement. The file is cached in DL_DIR and passed to install-buildtools via --local-file.
If no install-buildtools config is present, fall back to calling install-buildtools directly (preserving existing default behaviour).
CLI overrides available via --url and --sha256.
Depends: [oe-core] install-buildtools: add --local-file option
AI-Generated: Kiro with Claude Opus 4.6
---
Changes since v1:
- Use bb.fetch with mandatory sha256sum when configured
- Fall back to install-buildtools defaults when no config present
- Explicit sha256 verification after download (covers file:// and all fetchers)
- Combined url+filename into single url field
- Removed --sdk-name, --filename, --no-check/--check
- Added --url and --sha256 CLI overrides
- Updated schema, docs, and tests
bin/bitbake-setup | 91 ++++++++++++++++++- .../bitbake-user-manual-environment-setup.rst | 19 ++++ lib/bb/tests/setup.py | 85 ++++++++++++++++- setup-schema/bitbake-setup.schema.json | 21 +++++ 4 files changed, 208 insertions(+), 8 deletions(-)
bin/bitbake-setup +87 -4
@@ -1053,10 +1053,91 @@ def install_buildtools(top_dir, settings, args, d): return shutil.rmtree(buildtools_install_dir) - install_buildtools = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') - buildtools_download_dir = add_unique_timestamp_to_path(os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) - logger.plain("Buildtools archive is downloaded into {} and its content installed into {}".format(buildtools_download_dir, buildtools_install_dir)) - subprocess.check_call("{} -d {} --downloads-directory {}".format(install_buildtools, buildtools_install_dir, buildtools_download_dir), shell=True) + install_buildtools_script = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') + + buildtools_config = {} + upstream_config_path = os.path.join(args.setup_dir, 'config', 'config-upstream.json') + try: + with open(upstream_config_path) as f: + upstream_config = json.load(f) + buildtools_config = upstream_config.get('data', {}).get( + 'bitbake-setup', {}).get('install-buildtools', {}) + except FileNotFoundError: + pass + except json.JSONDecodeError as e: + logger.error("Failed to parse %s: %s" % (upstream_config_path, e)) + sys.exit(1) + + url = args.url if args.url is not None else buildtools_config.get('url') + sha256 = args.sha256 if args.sha256 is not None else buildtools_config.get('sha256sum') + + if not url and not sha256: + # No config provided -- fall back to install-buildtools defaults + logger.plain("No install-buildtools config found, using script defaults") + buildtools_download_dir = add_unique_timestamp_to_path( + os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) + subprocess.check_call([install_buildtools_script, + '-d', buildtools_install_dir, + '--downloads-directory', buildtools_download_dir]) + return + + if not url: + logger.error("No buildtools URL configured. " + "Set 'url' in the install-buildtools config section or pass --url.") + sys.exit(1) + + if not sha256: + logger.error("No sha256sum configured for buildtools installer. " + "Add 'sha256sum' to the install-buildtools config section or pass --sha256.\n" + "You can obtain it with: sha256sum <installer-file>") + sys.exit(1) + + # Download using bb.fetch with sha256 validation + src_uri = "{};sha256sum={}".format(url, sha256) + + logger.plain("Fetching buildtools installer using bitbake fetcher") + logger.plain(" {}".format(url)) + + fetcher = bb.fetch.Fetch([src_uri], d) + try: + fetcher.download() + except bb.fetch2.ChecksumError as e: + logger.error("Checksum mismatch for buildtools installer. " + "Verify the URL and downloaded file.\n%s" % str(e)) + sys.exit(1) + except bb.fetch2.FetchError as e: + logger.error("Failed to download buildtools installer: %s" % str(e)) + sys.exit(1) + + # Locate the downloaded file + local_path = fetcher.localpath(src_uri) + + if not os.path.exists(local_path): + logger.error("Downloaded file not found at expected location") + sys.exit(1) + + # Verify checksum explicitly (file:// fetcher does not enforce checksums) + actual_sha256 = bb.utils.sha256_file(local_path) + if actual_sha256 != sha256: + logger.error("Checksum mismatch for buildtools installer:\n" + " expected: %s\n" + " actual: %s" % (sha256, actual_sha256)) + sys.exit(1) + + logger.plain("Buildtools installer cached in {} and will be installed into {}".format( + os.path.dirname(local_path), buildtools_install_dir)) + + cmd = [ + install_buildtools_script, + '--local-file', local_path, + '-d', buildtools_install_dir, + ] + + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError as e: + logger.error("install-buildtools failed with exit code %d" % e.returncode) + sys.exit(1) def create_siteconf(top_dir, non_interactive, settings): siteconfpath = os.path.join(top_dir, 'site.conf')
@@ -1286,6 +1367,8 @@ def main(): parser_install_buildtools = subparsers.add_parser('install-buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine') add_setup_dir_arg(parser_install_buildtools) parser_install_buildtools.add_argument('--force', action='store_true', help='Force a reinstall of buildtools over the previous installation.') + parser_install_buildtools.add_argument('--url', help='Full URL to the buildtools SDK installer. Overrides config value.') + parser_install_buildtools.add_argument('--sha256', help='SHA256 checksum of the buildtools installer. Overrides config value.') parser_install_buildtools.set_defaults(func=install_buildtools) parser_settings_arg_global = argparse.ArgumentParser(add_help=False)
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +19 -0
@@ -660,6 +660,25 @@ In addition, the command can take the following arguments: - ``--setup-dir``: path to the :term:`Setup` to check to status for. Not required if :term:`BBPATH` is already configured. +- ``--url``: full URL to the buildtools SDK installer. Overrides the value + from the configuration file. + +- ``--sha256``: SHA256 checksum of the buildtools installer. Overrides the + value from the configuration file. + +When ``url`` and ``sha256sum`` are set in the :term:`Configuration File`, +the installer is downloaded via ``bb.fetch`` (cached in ``DL_DIR``) and its +checksum is enforced. If no configuration is present, the script falls back +to its built-in defaults:: + + "bitbake-setup": { + "install-buildtools": { + "url": "https://example.com/buildtools/x86_64-buildtools-extended-nativesdk-standalone-5.0.sh", + "sha256sum": "af76648b..." + }, + "configurations": [ ... ] + } + .. _ref-bbsetup-command-settings: ``bitbake-setup settings``
lib/bb/tests/setup.py +81 -4
114 lines not on this page · raw message
setup-schema/bitbake-setup.schema.json +21 -0
@@ -141,6 +141,27 @@ }, "additionalProperties": false } + }, + "install-buildtools": { + "type": "object", + "description": "Settings for downloading buildtools via bb.fetch", + "properties": { + "url": { + "type": "string", + "minLength": 1, + "description": "Full URL to the buildtools SDK installer." + }, + "sha256sum": { + "type": "string", + "minLength": 1, + "description": "SHA256 checksum of the buildtools installer." + } + }, + "required": [ + "url", + "sha256sum" + ], + "additionalProperties": false } }, "additionalProperties": false
Signature · 1 line
2.34.1
Re: [bitbake-devel] [PATCH v2] bitbake-setup: use bb.fetch for buildtools installer download
Quoted 3 lines · Jaipaul Cheernam via lists.openembedded.org
When url and sha256sum are configured, download the buildtools installer via bb.fetch with checksum enforcement. The file is cached in
DL_DIRand passed to install-buildtools via --local-file.
Thanks, this basically looks ok, but I have a few review points.
Quoted 4 lines
If no install-buildtools config is present, fall back to calling install-buildtools directly (preserving existing default behaviour).
CLI overrides available via --url and --sha256.
I think there should also be a --default command line option, which would similarly fall back to getting and installing the default buildtools even if config file specifies something else.
bin/bitbake-setup def install_buildtools(top_dir, settings, args, d): · line 1117
Quoted 6 lines
bin/bitbake-setup +6
-0+ # Locate the downloaded file + local_path = fetcher.localpath(src_uri) + + if not os.path.exists(local_path): + logger.error("Downloaded file not found at expected location") + sys.exit(1)
I would rather use fetcher.unpack(), than use the file directly from DL_DIR. It's better to only allow the fetcher to touch content of DL_DIR.
bin/bitbake-setup def install_buildtools(top_dir, settings, args, d): · line 1125
Quoted 7 lines
bin/bitbake-setup +7
-0+ # Verify checksum explicitly (file:// fetcher does not enforce checksums) + actual_sha256 = bb.utils.sha256_file(local_path) + if actual_sha256 != sha256: + logger.error("Checksum mismatch for buildtools installer:\n" + " expected: %s\n" + " actual: %s" % (sha256, actual_sha256)) + sys.exit(1)
This I don't quite understand. Why is the checksum verified again if the fetcher already did it? Why is file:// fetcher mentioned? AI confusion?
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst In addition, the command can take the following arguments: · line 680
Quoted 7 lines
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +7
-0+ "bitbake-setup": { + "install-buildtools": { + "url": "https://example.com/buildtools/x86_64-buildtools-extended-nativesdk-standalone-5.0.sh", + "sha256sum": "af76648b..." + }, + "configurations": [ ... ] + }
I wonder if the 'install-buildtools' block should be defined inside a particular configuration. Configurations can be nested, so that still allows defining a single buildtools for all of them, but this would also allow specifying separate buildtools for particular configurations. I'm not sure if a use case for that will arise, but at least bitbake-setup will be ready for it. What you think?
Alex
Re: [bitbake-devel] [PATCH v2] bitbake-setup: use bb.fetch for buildtools installer download
Hi Alex,
Thanks for the review.
1. --default — sure, will add.
2. fetcher. Unpack() — good point, I'll use that instead of reaching into DL_DIR directly
3. The explicit sha256 check — you're right, this was added because automated reviewers pointed out that file:// doesn't enforce checksums. I'll drop the explicit check
4. Putting install-buildtools inside configurations — makes sense for the future. Want me to do that now or as a follow-up?
I will send v3 with above corrections.
Regards,
Jaipaul Cheernam
🔗 EST Website<https://www.est.tech/>
🔗 EST LinkedIn<https://www.linkedin.com/company/ericsson-software-technology/>
From: Alexander Kanavin <[email protected]>
Date: Friday, 26 June 2026 at 18:48
To: Jaipaul Cheernam <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [bitbake-devel] [PATCH v2] bitbake-setup: use bb.fetch for buildtools installer download
Quoted 3 lines · Jaipaul Cheernam via lists.openembedded.org
When url and sha256sum are configured, download the buildtools installer via bb.fetch with checksum enforcement. The file is cached in
DL_DIRand passed to install-buildtools via --local-file.
Thanks, this basically looks ok, but I have a few review points.
Quoted 4 lines
If no install-buildtools config is present, fall back to calling install-buildtools directly (preserving existing default behaviour).
CLI overrides available via --url and --sha256.
I think there should also be a --default command line option, which would similarly fall back to getting and installing the default buildtools even if config file specifies something else.
bin/bitbake-setup def install_buildtools(top_dir, settings, args, d): · line 1117
Quoted 6 lines
bin/bitbake-setup +6
-0+ # Locate the downloaded file + local_path = fetcher.localpath(src_uri) + + if not os.path.exists(local_path): + logger.error("Downloaded file not found at expected location") + sys.exit(1)
I would rather use fetcher.unpack(), than use the file directly from DL_DIR. It's better to only allow the fetcher to touch content of DL_DIR.
bin/bitbake-setup def install_buildtools(top_dir, settings, args, d): · line 1125
Quoted 7 lines
bin/bitbake-setup +7
-0+ # Verify checksum explicitly (file:// fetcher does not enforce checksums) + actual_sha256 = bb.utils.sha256_file(local_path) + if actual_sha256 != sha256: + logger.error("Checksum mismatch for buildtools installer:\n" + " expected: %s\n" + " actual: %s" % (sha256, actual_sha256)) + sys.exit(1)
This I don't quite understand. Why is the checksum verified again if the fetcher already did it? Why is file:// fetcher mentioned? AI confusion?
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst In addition, the command can take the following arguments: · line 680
Quoted 7 lines
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +7
-0+ "bitbake-setup": { + "install-buildtools": { + "url": "https://example.com/buildtools/x86_64-buildtools-extended-nativesdk-standalone-5.0.sh", + "sha256sum": "af76648b..." + }, + "configurations": [ ... ] + }
I wonder if the 'install-buildtools' block should be defined inside a particular configuration. Configurations can be nested, so that still allows defining a single buildtools for all of them, but this would also allow specifying separate buildtools for particular configurations. I'm not sure if a use case for that will arise, but at least bitbake-setup will be ready for it. What you think?
Alex
PATCH v3 1/1 bitbake-setup: use bb.fetch for buildtools installer download
In reply to Jaipaul CheernamWhen url and sha256sum are configured, download the buildtools installer via bb.fetch with checksum enforcement. The file is unpacked to a working directory and passed to install-buildtools via --local-file.
If no config is present or --default is passed, fall back to calling install-buildtools directly with its built-in defaults.
CLI overrides available via --url and --sha256.
Depends: [oe-core] install-buildtools: add --local-file option
AI-Generated: Kiro with Claude Opus 4.6
---
Changes since v2:
- Added --default to bypass config and use script defaults
- Use fetcher.unpack() instead of reading from DL_DIR directly
- Removed explicit sha256 verification (fetcher handles it for https)
- Per-configuration install-buildtools config takes precedence over top-level
Changes since v1:
- Use bb.fetch with mandatory sha256sum when configured
- Fall back to install-buildtools defaults when no config present
- Combined url+filename into single url field
- Removed --sdk-name, --filename, --no-check/--check
- Added --url and --sha256 CLI overrides
- Updated schema, docs, and tests
bin/bitbake-setup | 94 ++++++++++++++++++- .../bitbake-user-manual-environment-setup.rst | 19 ++++ lib/bb/tests/setup.py | 77 ++++++++++++++- setup-schema/bitbake-setup.schema.json | 21 +++++ 4 files changed, 203 insertions(+), 8 deletions(-)
bin/bitbake-setup +90 -4
@@ -1053,10 +1053,93 @@ def install_buildtools(top_dir, settings, args, d): return shutil.rmtree(buildtools_install_dir) - install_buildtools = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') - buildtools_download_dir = add_unique_timestamp_to_path(os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) - logger.plain("Buildtools archive is downloaded into {} and its content installed into {}".format(buildtools_download_dir, buildtools_install_dir)) - subprocess.check_call("{} -d {} --downloads-directory {}".format(install_buildtools, buildtools_install_dir, buildtools_download_dir), shell=True) + install_buildtools_script = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') + + buildtools_config = {} + upstream_config_path = os.path.join(args.setup_dir, 'config', 'config-upstream.json') + try: + with open(upstream_config_path) as f: + upstream_config = json.load(f) + # Per-configuration takes precedence over top-level + buildtools_config = upstream_config.get('bitbake-config', {}).get('install-buildtools', {}) + if not buildtools_config: + buildtools_config = upstream_config.get('data', {}).get( + 'bitbake-setup', {}).get('install-buildtools', {}) + except FileNotFoundError: + pass + except json.JSONDecodeError as e: + logger.error("Failed to parse %s: %s" % (upstream_config_path, e)) + sys.exit(1) + + url = args.url if args.url is not None else buildtools_config.get('url') + sha256 = args.sha256 if args.sha256 is not None else buildtools_config.get('sha256sum') + + if args.default or (not url and not sha256): + # No config or --default: fall back to install-buildtools defaults + logger.plain("Using install-buildtools script defaults") + buildtools_download_dir = add_unique_timestamp_to_path( + os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) + subprocess.check_call([install_buildtools_script, + '-d', buildtools_install_dir, + '--downloads-directory', buildtools_download_dir]) + return + + if not url: + logger.error("No buildtools URL configured. " + "Set 'url' in the install-buildtools config section or pass --url.") + sys.exit(1) + + if not sha256: + logger.error("No sha256sum configured for buildtools installer. " + "Add 'sha256sum' to the install-buildtools config section or pass --sha256.\n" + "You can obtain it with: sha256sum <installer-file>") + sys.exit(1) + + # Download using bb.fetch with sha256 validation + src_uri = "{};sha256sum={}".format(url, sha256) + + logger.plain("Fetching buildtools installer using bitbake fetcher") + logger.plain(" {}".format(url)) + + fetcher = bb.fetch.Fetch([src_uri], d) + try: + fetcher.download() + except bb.fetch2.ChecksumError as e: + logger.error("Checksum mismatch for buildtools installer. " + "Verify the URL and downloaded file.\n%s" % str(e)) + sys.exit(1) + except bb.fetch2.FetchError as e: + logger.error("Failed to download buildtools installer: %s" % str(e)) + sys.exit(1) + + # Unpack into a working directory (avoid touching DL_DIR directly) + import tempfile + unpack_base = os.path.join(args.setup_dir, 'buildtools-downloads') + os.makedirs(unpack_base, exist_ok=True) + unpackdir = tempfile.mkdtemp(dir=unpack_base) + fetcher.unpack(unpackdir) + + filename = os.path.basename(url.rstrip('/')) + matches = glob.glob(os.path.join(unpackdir, '**', filename), recursive=True) + if not matches: + logger.error("Unpacked file not found: %s" % filename) + sys.exit(1) + local_path = matches[0] + + logger.plain("Buildtools installer will be installed into {}".format( + buildtools_install_dir)) + + cmd = [ + install_buildtools_script, + '--local-file', local_path, + '-d', buildtools_install_dir, + ] + + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError as e: + logger.error("install-buildtools failed with exit code %d" % e.returncode) + sys.exit(1) def create_siteconf(top_dir, non_interactive, settings): siteconfpath = os.path.join(top_dir, 'site.conf')
@@ -1286,6 +1369,9 @@ def main(): parser_install_buildtools = subparsers.add_parser('install-buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine') add_setup_dir_arg(parser_install_buildtools) parser_install_buildtools.add_argument('--force', action='store_true', help='Force a reinstall of buildtools over the previous installation.') + parser_install_buildtools.add_argument('--default', action='store_true', help='Use install-buildtools script defaults, ignoring any config.') + parser_install_buildtools.add_argument('--url', help='Full URL to the buildtools SDK installer. Overrides config value.') + parser_install_buildtools.add_argument('--sha256', help='SHA256 checksum of the buildtools installer. Overrides config value.') parser_install_buildtools.set_defaults(func=install_buildtools) parser_settings_arg_global = argparse.ArgumentParser(add_help=False)
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +19 -0
@@ -660,6 +660,25 @@ In addition, the command can take the following arguments: - ``--setup-dir``: path to the :term:`Setup` to check to status for. Not required if :term:`BBPATH` is already configured. +- ``--url``: full URL to the buildtools SDK installer. Overrides the value + from the configuration file. + +- ``--sha256``: SHA256 checksum of the buildtools installer. Overrides the + value from the configuration file. + +When ``url`` and ``sha256sum`` are set in the :term:`Configuration File`, +the installer is downloaded via ``bb.fetch`` (cached in ``DL_DIR``) and its +checksum is enforced. If no configuration is present, the script falls back +to its built-in defaults:: + + "bitbake-setup": { + "install-buildtools": { + "url": "https://example.com/buildtools/x86_64-buildtools-extended-nativesdk-standalone-5.0.sh", + "sha256sum": "af76648b..." + }, + "configurations": [ ... ] + } + .. _ref-bbsetup-command-settings: ``bitbake-setup settings``
lib/bb/tests/setup.py +73 -4
106 lines not on this page · raw message
setup-schema/bitbake-setup.schema.json +21 -0
@@ -141,6 +141,27 @@ }, "additionalProperties": false } + }, + "install-buildtools": { + "type": "object", + "description": "Settings for downloading buildtools via bb.fetch", + "properties": { + "url": { + "type": "string", + "minLength": 1, + "description": "Full URL to the buildtools SDK installer." + }, + "sha256sum": { + "type": "string", + "minLength": 1, + "description": "SHA256 checksum of the buildtools installer." + } + }, + "required": [ + "url", + "sha256sum" + ], + "additionalProperties": false } }, "additionalProperties": false
Signature · 1 line
2.34.1
Re: [bitbake-devel] [PATCH v3] bitbake-setup: use bb.fetch for buildtools installer download
bin/bitbake-setup def install_buildtools(top_dir, settings, args, d): · line 1067
Quoted 5 lines · Jaipaul Cheernam via lists.openembedded.org
bin/bitbake-setup +5
-0+ # Per-configuration takes precedence over top-level + buildtools_config = upstream_config.get('bitbake-config', {}).get('install-buildtools', {}) + if not buildtools_config: + buildtools_config = upstream_config.get('data', {}).get( + 'bitbake-setup', {}).get('install-buildtools', {})
This wasn't quite the idea. I wanted to make per-configuration the only place to specify custom buildtools, so no top level support at all.
bin/bitbake-setup def install_buildtools(top_dir, settings, args, d): · line 1120
Quoted 6 lines
bin/bitbake-setup +6
-0+ # Unpack into a working directory (avoid touching DL_DIR directly) + import tempfile + unpack_base = os.path.join(args.setup_dir, 'buildtools-downloads') + os.makedirs(unpack_base, exist_ok=True) + unpackdir = tempfile.mkdtemp(dir=unpack_base) + fetcher.unpack(unpackdir)
This should be using the same location as default buildtools, e.g. fecher.unpack(buildtools_download_dir). So it's consistent, if someone is expecting to find the buildtools archive there.
Alex
PATCH v4 1/1 bitbake-setup: use bb.fetch for buildtools installer download
In reply to Jaipaul CheernamWhen url and sha256sum are configured in the selected configuration, download the buildtools installer via bb.fetch with checksum enforcement. The file is unpacked to the standard buildtools download location and passed to install-buildtools via --local-file.
If no config is present or --default is passed, fall back to calling install-buildtools directly with its built-in defaults.
CLI overrides available via --url and --sha256.
Depends: [oe-core] install-buildtools: add --local-file option
AI-Generated: Kiro with Claude Opus 4.6
---
Changes since v3:
- install-buildtools config is per-configuration only (no top-level)
- Use buildtools_download_dir for unpack (consistent with default path)
- Updated schema, docs, and tests to match
Changes since v2:
- Added --default to bypass config and use script defaults
- Use fetcher.unpack() instead of reading from DL_DIR directly
- Removed explicit sha256 verification (fetcher handles it for https)
Changes since v1:
- Use bb.fetch with mandatory sha256sum when configured
- Fall back to install-buildtools defaults when no config present
- Combined url+filename into single url field
- Removed --sdk-name, --filename, --no-check/--check
- Added --url and --sha256 CLI overrides
- Updated schema, docs, and tests
bin/bitbake-setup | 89 ++++++++++++++++++- .../bitbake-user-manual-environment-setup.rst | 24 +++++ lib/bb/tests/setup.py | 77 +++++++++++++++- setup-schema/bitbake-setup.schema.json | 21 +++++ 4 files changed, 203 insertions(+), 8 deletions(-)
bin/bitbake-setup +85 -4
@@ -1053,10 +1053,88 @@ def install_buildtools(top_dir, settings, args, d): return shutil.rmtree(buildtools_install_dir) - install_buildtools = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') - buildtools_download_dir = add_unique_timestamp_to_path(os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) - logger.plain("Buildtools archive is downloaded into {} and its content installed into {}".format(buildtools_download_dir, buildtools_install_dir)) - subprocess.check_call("{} -d {} --downloads-directory {}".format(install_buildtools, buildtools_install_dir, buildtools_download_dir), shell=True) + install_buildtools_script = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') + + buildtools_config = {} + upstream_config_path = os.path.join(args.setup_dir, 'config', 'config-upstream.json') + try: + with open(upstream_config_path) as f: + upstream_config = json.load(f) + buildtools_config = upstream_config.get('bitbake-config', {}).get('install-buildtools', {}) + except FileNotFoundError: + pass + except json.JSONDecodeError as e: + logger.error("Failed to parse %s: %s" % (upstream_config_path, e)) + sys.exit(1) + + url = args.url if args.url is not None else buildtools_config.get('url') + sha256 = args.sha256 if args.sha256 is not None else buildtools_config.get('sha256sum') + + if args.default or (not url and not sha256): + # No config or --default: fall back to install-buildtools defaults + logger.plain("Using install-buildtools script defaults") + buildtools_download_dir = add_unique_timestamp_to_path( + os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) + subprocess.check_call([install_buildtools_script, + '-d', buildtools_install_dir, + '--downloads-directory', buildtools_download_dir]) + return + + if not url: + logger.error("No buildtools URL configured. " + "Set 'url' in the install-buildtools config section or pass --url.") + sys.exit(1) + + if not sha256: + logger.error("No sha256sum configured for buildtools installer. " + "Add 'sha256sum' to the install-buildtools config section or pass --sha256.\n" + "You can obtain it with: sha256sum <installer-file>") + sys.exit(1) + + # Download using bb.fetch with sha256 validation + src_uri = "{};sha256sum={}".format(url, sha256) + + logger.plain("Fetching buildtools installer using bitbake fetcher") + logger.plain(" {}".format(url)) + + fetcher = bb.fetch.Fetch([src_uri], d) + try: + fetcher.download() + except bb.fetch2.ChecksumError as e: + logger.error("Checksum mismatch for buildtools installer. " + "Verify the URL and downloaded file.\n%s" % str(e)) + sys.exit(1) + except bb.fetch2.FetchError as e: + logger.error("Failed to download buildtools installer: %s" % str(e)) + sys.exit(1) + + # Unpack into the standard buildtools download location + buildtools_download_dir = add_unique_timestamp_to_path( + os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) + os.makedirs(buildtools_download_dir, exist_ok=True) + fetcher.unpack(buildtools_download_dir) + + filename = os.path.basename(url.rstrip('/')) + matches = glob.glob(os.path.join(buildtools_download_dir, '**', filename), recursive=True) + if not matches: + logger.error("Unpacked file not found: %s" % filename) + sys.exit(1) + local_path = matches[0] + + logger.plain("Buildtools installer will be installed into {}".format( + buildtools_install_dir)) + + cmd = [ + install_buildtools_script, + '--local-file', local_path, + '-d', buildtools_install_dir, + ] + + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError as e: + logger.error("install-buildtools failed with exit code %d" % e.returncode) + sys.exit(1) def create_siteconf(top_dir, non_interactive, settings): siteconfpath = os.path.join(top_dir, 'site.conf')
@@ -1286,6 +1364,9 @@ def main(): parser_install_buildtools = subparsers.add_parser('install-buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine') add_setup_dir_arg(parser_install_buildtools) parser_install_buildtools.add_argument('--force', action='store_true', help='Force a reinstall of buildtools over the previous installation.') + parser_install_buildtools.add_argument('--default', action='store_true', help='Use install-buildtools script defaults, ignoring any config.') + parser_install_buildtools.add_argument('--url', help='Full URL to the buildtools SDK installer. Overrides config value.') + parser_install_buildtools.add_argument('--sha256', help='SHA256 checksum of the buildtools installer. Overrides config value.') parser_install_buildtools.set_defaults(func=install_buildtools) parser_settings_arg_global = argparse.ArgumentParser(add_help=False)
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +24 -0
@@ -660,6 +660,30 @@ In addition, the command can take the following arguments: - ``--setup-dir``: path to the :term:`Setup` to check to status for. Not required if :term:`BBPATH` is already configured. +- ``--url``: full URL to the buildtools SDK installer. Overrides the value + from the configuration file. + +- ``--sha256``: SHA256 checksum of the buildtools installer. Overrides the + value from the configuration file. + +When ``url`` and ``sha256sum`` are set in the :term:`Configuration File`, +the installer is downloaded via ``bb.fetch`` (cached in ``DL_DIR``) and its +checksum is enforced. If no configuration is present, the script falls back +to its built-in defaults:: + + "bitbake-setup": { + "configurations": [ + { + "name": "my-config", + "install-buildtools": { + "url": "https://example.com/buildtools/x86_64-buildtools-extended-nativesdk-standalone-5.0.sh", + "sha256sum": "af76648b..." + }, + ... + } + ] + } + .. _ref-bbsetup-command-settings: ``bitbake-setup settings``
lib/bb/tests/setup.py +73 -4
109 lines not on this page · raw message
setup-schema/bitbake-setup.schema.json +21 -0
@@ -137,6 +137,27 @@ "setup-dir-name": { "type": "string", "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections." + }, + "install-buildtools": { + "type": "object", + "description": "Settings for downloading buildtools via bb.fetch", + "properties": { + "url": { + "type": "string", + "minLength": 1, + "description": "Full URL to the buildtools SDK installer." + }, + "sha256sum": { + "type": "string", + "minLength": 1, + "description": "SHA256 checksum of the buildtools installer." + } + }, + "required": [ + "url", + "sha256sum" + ], + "additionalProperties": false } }, "additionalProperties": false
Signature · 1 line
2.34.1
Re: [bitbake-devel] [PATCH v4] bitbake-setup: use bb.fetch for buildtools installer download
Thanks, I think this is good overall. Perhaps there's no need to set buildtools_download_dir twice in the same way in two different code paths, but that's a minor issue. The patch should go to general review and CI now.
Alex
Quoted 342 lines · Jaipaul Cheernam via lists.openembedded.org
When url and sha256sum are configured in the selected configuration, download the buildtools installer via bb.fetch with checksum enforcement. The file is unpacked to the standard buildtools download location and passed to install-buildtools via --local-file.
If no config is present or --default is passed, fall back to calling install-buildtools directly with its built-in defaults.
CLI overrides available via --url and --sha256.
Depends: [oe-core] install-buildtools: add --local-file option
AI-Generated: Kiro with Claude Opus 4.6Signed-off-by Jaipaul Cheernam <[email protected]>---
Changes since v3:
- install-buildtools config is per-configuration only (no top-level)
- Usebuildtools_download_dirfor unpack (consistent with default path)
- Updated schema, docs, and tests to matchChanges since v2:
- Added --default to bypass config and use script defaults
- Usefetcher.unpack()instead of reading fromDL_DIRdirectly
- Removed explicit sha256 verification (fetcher handles it for https)Changes since v1:
- Use bb.fetch with mandatory sha256sum when configured
- Fall back to install-buildtools defaults when no config present
- Combined url+filename into single url field
- Removed --sdk-name, --filename, --no-check/--check
- Added --url and --sha256 CLI overrides
- Updated schema, docs, and testsbin/bitbake-setup | 89 ++++++++++++++++++- .../bitbake-user-manual-environment-setup.rst | 24 +++++ lib/bb/tests/setup.py | 77 +++++++++++++++- setup-schema/bitbake-setup.schema.json | 21 +++++ 4 files changed, 203 insertions(+), 8 deletions(-)bin/bitbake-setup +85
-4@@ -1053,10 +1053,88 @@ def install_buildtools(top_dir, settings, args, d): return shutil.rmtree(buildtools_install_dir) - install_buildtools = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') - buildtools_download_dir = add_unique_timestamp_to_path(os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) - logger.plain("Buildtools archive is downloaded into {} and its content installed into {}".format(buildtools_download_dir, buildtools_install_dir)) - subprocess.check_call("{} -d {} --downloads-directory {}".format(install_buildtools, buildtools_install_dir, buildtools_download_dir), shell=True) + install_buildtools_script = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') + + buildtools_config = {} + upstream_config_path = os.path.join(args.setup_dir, 'config', 'config-upstream.json') + try: + with open(upstream_config_path) as f: + upstream_config = json.load(f) + buildtools_config = upstream_config.get('bitbake-config', {}).get('install-buildtools', {}) + except FileNotFoundError: + pass + except json.JSONDecodeError as e: + logger.error("Failed to parse %s: %s" % (upstream_config_path, e)) + sys.exit(1) + + url = args.url if args.url is not None else buildtools_config.get('url') + sha256 = args.sha256 if args.sha256 is not None else buildtools_config.get('sha256sum') + + if args.default or (not url and not sha256): + # No config or --default: fall back to install-buildtools defaults + logger.plain("Using install-buildtools script defaults") + buildtools_download_dir = add_unique_timestamp_to_path( + os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) + subprocess.check_call([install_buildtools_script, + '-d', buildtools_install_dir, + '--downloads-directory', buildtools_download_dir]) + return + + if not url: + logger.error("No buildtools URL configured. " + "Set 'url' in the install-buildtools config section or pass --url.") + sys.exit(1) + + if not sha256: + logger.error("No sha256sum configured for buildtools installer. " + "Add 'sha256sum' to the install-buildtools config section or pass --sha256.\n" + "You can obtain it with: sha256sum <installer-file>") + sys.exit(1) + + # Download using bb.fetch with sha256 validation + src_uri = "{};sha256sum={}".format(url, sha256) + + logger.plain("Fetching buildtools installer using bitbake fetcher") + logger.plain(" {}".format(url)) + + fetcher = bb.fetch.Fetch([src_uri], d) + try: + fetcher.download() + except bb.fetch2.ChecksumError as e: + logger.error("Checksum mismatch for buildtools installer. " + "Verify the URL and downloaded file.\n%s" % str(e)) + sys.exit(1) + except bb.fetch2.FetchError as e: + logger.error("Failed to download buildtools installer: %s" % str(e)) + sys.exit(1) + + # Unpack into the standard buildtools download location + buildtools_download_dir = add_unique_timestamp_to_path( + os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) + os.makedirs(buildtools_download_dir, exist_ok=True) + fetcher.unpack(buildtools_download_dir) + + filename = os.path.basename(url.rstrip('/')) + matches = glob.glob(os.path.join(buildtools_download_dir, '**', filename), recursive=True) + if not matches: + logger.error("Unpacked file not found: %s" % filename) + sys.exit(1) + local_path = matches[0] + + logger.plain("Buildtools installer will be installed into {}".format( + buildtools_install_dir)) + + cmd = [ + install_buildtools_script, + '--local-file', local_path, + '-d', buildtools_install_dir, + ] + + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError as e: + logger.error("install-buildtools failed with exit code %d" % e.returncode) + sys.exit(1) def create_siteconf(top_dir, non_interactive, settings): siteconfpath = os.path.join(top_dir, 'site.conf')@@ -1286,6 +1364,9 @@ def main(): parser_install_buildtools = subparsers.add_parser('install-buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine') add_setup_dir_arg(parser_install_buildtools) parser_install_buildtools.add_argument('--force', action='store_true', help='Force a reinstall of buildtools over the previous installation.') + parser_install_buildtools.add_argument('--default', action='store_true', help='Use install-buildtools script defaults, ignoring any config.') + parser_install_buildtools.add_argument('--url', help='Full URL to the buildtools SDK installer. Overrides config value.') + parser_install_buildtools.add_argument('--sha256', help='SHA256 checksum of the buildtools installer. Overrides config value.') parser_install_buildtools.set_defaults(func=install_buildtools) parser_settings_arg_global = argparse.ArgumentParser(add_help=False)doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +24
-0@@ -660,6 +660,30 @@ In addition, the command can take the following arguments: - ``--setup-dir``: path to the :term:`Setup` to check to status for. Not required if :term:`BBPATH` is already configured. +- ``--url``: full URL to the buildtools SDK installer. Overrides the value + from the configuration file. + +- ``--sha256``: SHA256 checksum of the buildtools installer. Overrides the + value from the configuration file. + +When ``url`` and ``sha256sum`` are set in the :term:`Configuration File`, +the installer is downloaded via ``bb.fetch`` (cached in ``DL_DIR``) and its +checksum is enforced. If no configuration is present, the script falls back +to its built-in defaults:: + + "bitbake-setup": { + "configurations": [ + { + "name": "my-config", + "install-buildtools": { + "url": "https://example.com/buildtools/x86_64-buildtools-extended-nativesdk-standalone-5.0.sh", + "sha256sum": "af76648b..." + }, + ... + } + ] + } + .. _ref-bbsetup-command-settings: ``bitbake-setup settings``lib/bb/tests/setup.py +73
-4@@ -61,16 +61,31 @@ import getopt import sys import os -opts, args = getopt.getopt(sys.argv[1:], "d:", ["downloads-directory="]) +opts, args = getopt.getopt(sys.argv[1:], "d:", ["downloads-directory=", "local-file="]) +installdir = None +local_file = None for option, value in opts: if option == '-d': installdir = value + elif option == '--local-file': + local_file = value + print("install-buildtools local-file={}".format(value)) print("Buildtools installed into {}".format(installdir)) -os.makedirs(installdir) +os.makedirs(installdir, exist_ok=True) """ self.add_file_to_testrepo('scripts/install-buildtools', installbuildtools, script=True) + # Dummy buildtools installer for bb.fetch testing + self.buildtools_dir = os.path.join(self.tempdir, "buildtools-dl") + os.makedirs(self.buildtools_dir) + self.buildtools_filename = "x86_64-buildtools-nativesdk-standalone-test.sh" + buildtools_filepath = os.path.join(self.buildtools_dir, self.buildtools_filename) + with open(buildtools_filepath, 'w') as f: + f.write("#!/bin/sh\necho dummy\n") + with open(buildtools_filepath, 'rb') as f: + self.buildtools_sha256 = hashlib.sha256(f.read()).hexdigest() + bitbakeconfigbuild = """#!/usr/bin/env python3 import os import sys@@ -108,7 +123,11 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) "name": "gadget", "description": "Gadget configuration", "oe-template": "test-configuration-gadget", - "oe-fragments": ["test-fragment-1"] + "oe-fragments": ["test-fragment-1"], + "install-buildtools": { + "url": "file://%s/%s", + "sha256sum": "%s" + } }, { "name": "gizmo",@@ -176,7 +195,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) }, "version": "1.0" } -""" % (sources) +""" % (sources, self.buildtools_dir, self.buildtools_filename, self.buildtools_sha256) os.makedirs(os.path.join(self.registrypath, os.path.dirname(name)), exist_ok=True) with open(os.path.join(self.registrypath, name), 'w') as f: f.write(config)@@ -644,6 +663,56 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) def _count_layer_backups(self, layers_path): return len([f for f in os.listdir(layers_path) if 'backup' in f]) + def test_install_buildtools_fetch(self): + """Test that install-buildtools uses bb.fetch with sha256 and passes --local-file""" + import shutil + + if 'BBPATH' in os.environ: + del os.environ['BBPATH'] + os.chdir(self.tempdir) + + registry_uri = "git://{};protocol=file;branch=master;rev=master".format( + self.registrypath) + self.runbbsetup(["settings", "set", "default", "registry", registry_uri]) + self.add_file_to_testrepo('test-file', 'initial\n') + self.add_json_config_to_registry('test-config-bt.conf.json', 'master', 'master') + self.runbbsetup(["init", "--non-interactive", "test-config-bt", "gadget"]) + setuppath = self.get_setup_path('test-config-bt', 'gadget') + + # test config-driven install (url + sha256sum from config) + out = self.runbbsetup(["install-buildtools", "--setup-dir", setuppath]) + self.assertIn("Buildtools installed into", out[0]) + self.assertIn("install-buildtools local-file=", out[0]) + self.assertTrue(os.path.exists(os.path.join(setuppath, 'buildtools'))) + + # test CLI overrides (use a different file to prove precedence) + shutil.rmtree(os.path.join(setuppath, 'buildtools')) + alt_filename = "alt-buildtools-test.sh" + alt_filepath = os.path.join(self.buildtools_dir, alt_filename) + with open(alt_filepath, 'w') as f: + f.write("#!/bin/sh\necho alt\n") + with open(alt_filepath, 'rb') as f: + alt_sha256 = hashlib.sha256(f.read()).hexdigest() + alt_url = "file://{}/{}".format(self.buildtools_dir, alt_filename) + out = self.runbbsetup(["install-buildtools", "--setup-dir", setuppath, + "--url", alt_url, + "--sha256", alt_sha256]) + self.assertIn("Buildtools installed into", out[0]) + self.assertIn("install-buildtools local-file=", out[0]) + self.assertIn(alt_filename, out[0]) + + # test missing sha256sum is a hard error + shutil.rmtree(os.path.join(setuppath, 'buildtools'), ignore_errors=True) + with open(os.path.join(setuppath, 'config', 'config-upstream.json')) as f: + config_upstream = json.load(f) + config_upstream['bitbake-config']['install-buildtools'] = { + 'url': 'file://{}/{}'.format(self.buildtools_dir, self.buildtools_filename) + } + with open(os.path.join(setuppath, 'config', 'config-upstream.json'), 'w') as f: + json.dump(config_upstream, f) + with self.assertRaises(bb.process.ExecutionError): + self.runbbsetup(["install-buildtools", "--setup-dir", setuppath, "--force"]) + def test_update_rebase_conflicts_strategy(self): """Test the --rebase-conflicts-strategy option for the update command.setup-schema/bitbake-setup.schema.json +21
-1@@ -137,6 +137,27 @@ "setup-dir-name": { "type": "string", "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections." + }, + "install-buildtools": { + "type": "object", + "description": "Settings for downloading buildtools via bb.fetch", + "properties": { + "url": { + "type": "string", + "minLength": 1, + "description": "Full URL to the buildtools SDK installer." + }, + "sha256sum": { + "type": "string", + "minLength": 1, + "description": "SHA256 checksum of the buildtools installer." + } + }, + "required": [ + "url", + "sha256sum" + ], + "additionalProperties": false } }, "additionalProperties": false --2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#19808): https://lists.openembedded.org/g/bitbake-devel/message/19808
Mute This Topic: https://lists.openembedded.org/mt/120037327/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
PATCH v5 1/1 bitbake-setup: use bb.fetch for buildtools installer download
In reply to Jaipaul CheernamWhen url and sha256sum are configured in the selected configuration, download the buildtools installer via bb.fetch with checksum enforcement. The file is unpacked to the standard buildtools download location and passed to install-buildtools via --local-file.
If no config is present or --default is passed, fall back to calling install-buildtools directly with its built-in defaults.
CLI overrides available via --url and --sha256.
Depends: [oe-core] install-buildtools: add --local-file option
AI-Generated: Kiro with Claude Opus 4.6
---
Changes since v4:
- Rebased on latest master
- Deduplicate buildtools_download_dir definition
Changes since v3:
- install-buildtools config is per-configuration only (no top-level)
- Use buildtools_download_dir for unpack (consistent with default path)
- Updated schema, docs, and tests to match
Changes since v2:
- Added --default to bypass config and use script defaults
- Use fetcher.unpack() instead of reading from DL_DIR directly
- Removed explicit sha256 verification (fetcher handles it for https)
Changes since v1:
- Use bb.fetch with mandatory sha256sum when configured
- Fall back to install-buildtools defaults when no config present
- Combined url+filename into single url field
- Removed --sdk-name, --filename, --no-check/--check
- Added --url and --sha256 CLI overrides
- Updated schema, docs, and tests
bin/bitbake-setup | 88 ++++++++++++++++++- .../bitbake-user-manual-environment-setup.rst | 24 +++++ lib/bb/tests/setup.py | 77 +++++++++++++++- setup-schema/bitbake-setup.schema.json | 23 ++++- 4 files changed, 203 insertions(+), 9 deletions(-)
bin/bitbake-setup +84 -4
@@ -1053,10 +1053,87 @@ def install_buildtools(top_dir, settings, args, d): return shutil.rmtree(buildtools_install_dir) - install_buildtools = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') - buildtools_download_dir = add_unique_timestamp_to_path(os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) - logger.plain("Buildtools archive is downloaded into {} and its content installed into {}".format(buildtools_download_dir, buildtools_install_dir)) - subprocess.check_call("{} -d {} --downloads-directory {}".format(install_buildtools, buildtools_install_dir, buildtools_download_dir), shell=True) + install_buildtools_script = os.path.join(args.setup_dir, 'layers/oe-scripts/install-buildtools') + + buildtools_config = {} + upstream_config_path = os.path.join(args.setup_dir, 'config', 'config-upstream.json') + try: + with open(upstream_config_path) as f: + upstream_config = json.load(f) + buildtools_config = upstream_config.get('bitbake-config', {}).get('install-buildtools', {}) + except FileNotFoundError: + pass + except json.JSONDecodeError as e: + logger.error("Failed to parse %s: %s" % (upstream_config_path, e)) + sys.exit(1) + + url = args.url if args.url is not None else buildtools_config.get('url') + sha256 = args.sha256 if args.sha256 is not None else buildtools_config.get('sha256sum') + + buildtools_download_dir = add_unique_timestamp_to_path( + os.path.join(args.setup_dir, 'buildtools-downloads/buildtools')) + + if args.default or (not url and not sha256): + # No config or --default: fall back to install-buildtools defaults + logger.plain("Using install-buildtools script defaults") + subprocess.check_call([install_buildtools_script, + '-d', buildtools_install_dir, + '--downloads-directory', buildtools_download_dir]) + return + + if not url: + logger.error("No buildtools URL configured. " + "Set 'url' in the install-buildtools config section or pass --url.") + sys.exit(1) + + if not sha256: + logger.error("No sha256sum configured for buildtools installer. " + "Add 'sha256sum' to the install-buildtools config section or pass --sha256.\n" + "You can obtain it with: sha256sum <installer-file>") + sys.exit(1) + + # Download using bb.fetch with sha256 validation + src_uri = "{};sha256sum={}".format(url, sha256) + + logger.plain("Fetching buildtools installer using bitbake fetcher") + logger.plain(" {}".format(url)) + + fetcher = bb.fetch.Fetch([src_uri], d) + try: + fetcher.download() + except bb.fetch2.ChecksumError as e: + logger.error("Checksum mismatch for buildtools installer. " + "Verify the URL and downloaded file.\n%s" % str(e)) + sys.exit(1) + except bb.fetch2.FetchError as e: + logger.error("Failed to download buildtools installer: %s" % str(e)) + sys.exit(1) + + # Unpack into the standard buildtools download location + os.makedirs(buildtools_download_dir, exist_ok=True) + fetcher.unpack(buildtools_download_dir) + + filename = os.path.basename(url.rstrip('/')) + matches = glob.glob(os.path.join(buildtools_download_dir, '**', filename), recursive=True) + if not matches: + logger.error("Unpacked file not found: %s" % filename) + sys.exit(1) + local_path = matches[0] + + logger.plain("Buildtools installer will be installed into {}".format( + buildtools_install_dir)) + + cmd = [ + install_buildtools_script, + '--local-file', local_path, + '-d', buildtools_install_dir, + ] + + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError as e: + logger.error("install-buildtools failed with exit code %d" % e.returncode) + sys.exit(1) def create_siteconf(top_dir, non_interactive, settings): siteconfpath = os.path.join(top_dir, 'site.conf')
@@ -1286,6 +1363,9 @@ def main(): parser_install_buildtools = subparsers.add_parser('install-buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine') add_setup_dir_arg(parser_install_buildtools) parser_install_buildtools.add_argument('--force', action='store_true', help='Force a reinstall of buildtools over the previous installation.') + parser_install_buildtools.add_argument('--default', action='store_true', help='Use install-buildtools script defaults, ignoring any config.') + parser_install_buildtools.add_argument('--url', help='Full URL to the buildtools SDK installer. Overrides config value.') + parser_install_buildtools.add_argument('--sha256', help='SHA256 checksum of the buildtools installer. Overrides config value.') parser_install_buildtools.set_defaults(func=install_buildtools) parser_settings_arg_global = argparse.ArgumentParser(add_help=False)
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +24 -0
@@ -660,6 +660,30 @@ In addition, the command can take the following arguments: - ``--setup-dir``: path to the :term:`Setup` to check to status for. Not required if :term:`BBPATH` is already configured. +- ``--url``: full URL to the buildtools SDK installer. Overrides the value + from the configuration file. + +- ``--sha256``: SHA256 checksum of the buildtools installer. Overrides the + value from the configuration file. + +When ``url`` and ``sha256sum`` are set in the :term:`Configuration File`, +the installer is downloaded via ``bb.fetch`` (cached in ``DL_DIR``) and its +checksum is enforced. If no configuration is present, the script falls back +to its built-in defaults:: + + "bitbake-setup": { + "configurations": [ + { + "name": "my-config", + "install-buildtools": { + "url": "https://example.com/buildtools/x86_64-buildtools-extended-nativesdk-standalone-5.0.sh", + "sha256sum": "af76648b..." + }, + ... + } + ] + } + .. _ref-bbsetup-command-settings: ``bitbake-setup settings``
lib/bb/tests/setup.py +73 -4
109 lines not on this page · raw message
setup-schema/bitbake-setup.schema.json +22 -1
@@ -170,7 +170,28 @@ }, "setup-dir-name": { "type": "string", - "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections" + "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections." + }, + "install-buildtools": { + "type": "object", + "description": "Settings for downloading buildtools via bb.fetch", + "properties": { + "url": { + "type": "string", + "minLength": 1, + "description": "Full URL to the buildtools SDK installer." + }, + "sha256sum": { + "type": "string", + "minLength": 1, + "description": "SHA256 checksum of the buildtools installer." + } + }, + "required": [ + "url", + "sha256sum" + ], + "additionalProperties": false } }, "additionalProperties": false
Signature · 1 line
2.34.1
Re: [PATCH v5] bitbake-setup: use bb.fetch for buildtools installer download
Hi ,
Could you please share feedback on my patch ?
Regards,
Jaipaul
Re: [bitbake-devel] [PATCH v5] bitbake-setup: use bb.fetch for buildtools installer download
Quoted 1 line · Jaipaul Cheernam via lists.openembedded.org
Could you please share feedback on my patch ?
It's in master-next and due for review. If everything is okay, it will be quietly merged.
Alex