Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: adrian.freihofer@siemens.com, openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH 06/15] runqemu-extract-sdk: refactor in Python
Date: Thu, 10 Sep 2026 18:45:55 +0100	[thread overview]
Message-ID: <e96a5c72b21a10328862ebfd760d16a57cdc2d71.camel@linuxfoundation.org> (raw)
In-Reply-To: <20260909215337.89106-7-adrian.freihofer@siemens.com>

On Wed, 2026-09-09 at 23:53 +0200, Adrian Freihofer via lists.openembedded.org wrote:
> From: Adrian Freihofer <adrian.freihofer@siemens.com>
> 
> Move the pseudo-backed rootfs extraction logic into a reusable Python
> module while preserving the existing command interface.
> Install the module with qemu-helper so the wrapper also works from an SDK.
> 
> Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
> ---
>  .../qemu/nativesdk-qemu-helper_1.0.bb         |   3 +
>  scripts/lib/pseudo_rootfs_utils.py            | 113 +++++++++++++++++
>  scripts/runqemu-extract-sdk                   | 116 ++++--------------
>  3 files changed, 137 insertions(+), 95 deletions(-)
>  create mode 100644 scripts/lib/pseudo_rootfs_utils.py
> 
> diff --git a/meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb b/meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb
> index e1f343989a..0558a564bb 100644
> --- a/meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb
> +++ b/meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb
> @@ -9,6 +9,7 @@ RDEPENDS:${PN} = "nativesdk-qemu nativesdk-unfs3 nativesdk-pseudo \
>  LIC_FILES_CHKSUM = "file://${COREBASE}/scripts/runqemu;beginline=5;endline=10;md5=ac2b489a58739c7628a2604698db5e7f"
>  
>  SRC_URI = "file://${COREBASE}/scripts/runqemu \
> +           file://${COREBASE}/scripts/lib/pseudo_rootfs_utils.py \
>             file://${COREBASE}/scripts/runqemu-addptable2image \
>             file://${COREBASE}/scripts/runqemu-gen-tapdevs \
>             file://${COREBASE}/scripts/runqemu-ifup \
> @@ -30,4 +31,6 @@ do_install() {
>  	install -d ${D}${bindir}
>  	install -m 0755 ${S}${COREBASE}/scripts/oe-* ${D}${bindir}/
>  	install -m 0755 ${S}${COREBASE}/scripts/runqemu* ${D}${bindir}/
> +	# The runqemu-* wrappers import this module from their own directory.
> +	install -m 0644 ${S}${COREBASE}/scripts/lib/pseudo_rootfs_utils.py ${D}${bindir}/
>  }
> diff --git a/scripts/lib/pseudo_rootfs_utils.py b/scripts/lib/pseudo_rootfs_utils.py
> new file mode 100644
> index 0000000000..89d082f672
> --- /dev/null
> +++ b/scripts/lib/pseudo_rootfs_utils.py
> @@ -0,0 +1,113 @@
> +#!/usr/bin/env python3
> +#
> +# Helpers for preparing pseudo-managed rootfs trees (NFS booting, SDK/rootfs
> +# extraction, target deploy).
> +#
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +"""Extract rootfs tarballs and locate their pseudo state for NFS booting."""
> +
> +import os
> +import subprocess
> +from pathlib import Path
> +
> +
> +class PseudoRootfsError(Exception):
> +    """Raised when a pseudo-managed rootfs cannot be prepared or exported."""
> +
> +
> +def pseudo_native_environment():
> +    """Return the pseudo native environment (PSEUDO and OECORE_NATIVE_SYSROOT), from the
> +    qemu-helper-native recipe which provides a pseudo binary usable outside a recipe sysroot."""
> +    native_sysroot = os.environ.get('OECORE_NATIVE_SYSROOT')
> +    if not native_sysroot:
> +        try:
> +            import bb.tinfoil
> +        except ImportError as exc:
> +            raise PseudoRootfsError(
> +                'Unable to import bitbake.\n'
> +                'Did you forget to source your build system environment setup script?') from exc
> +        try:
> +            with bb.tinfoil.Tinfoil() as tinfoil:
> +                tinfoil.prepare(quiet=2)
> +                native_sysroot = tinfoil.parse_recipe('qemu-helper-native').getVar('STAGING_DIR_NATIVE')
> +        except Exception as exc:
> +            raise PseudoRootfsError('Unable to set up the qemu-helper-native sysroot') from exc
> +
> +    if not native_sysroot or not os.path.exists(native_sysroot):
> +        raise PseudoRootfsError("%s doesn't exist" % native_sysroot)
> +
> +    environment = {'OECORE_NATIVE_SYSROOT': native_sysroot}
> +    environment['PSEUDO'] = os.path.join(native_sysroot, 'usr', 'bin', 'pseudo')
> +    return environment
> +
> +
> +def _tar_options(rootfs_tarball):
> +    tar_extract_options = {
> +        '.tar.xz': '-xJf',
> +        '.tar.bz2': '-xjf',
> +        '.tar.gz': '-xzf',
> +        '.tar.zst': '--zstd -xf',
> +        '.tar': '-xf',
> +    }
> +    for extension, option in tar_extract_options.items():
> +        if rootfs_tarball.endswith(extension):
> +            return ['--numeric-owner', *option.split()]
> +    raise PseudoRootfsError(
> +        'Unable to determine sdk tarball format\n'
> +        'Accepted types: .tar / .tar.gz / .tar.bz2 / .tar.xz / .tar.zst')

This is breaking on RHEL8 era hosts, e.g.:

https://autobuilder.yoctoproject.org/valkyrie/#/builders/42/builds/4591

"tar: unrecognized option '--zstd'"

:(

Cheers,

Richard




  reply	other threads:[~2026-09-10 17:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 21:53 [PATCH 00/15] devtool ide-sdk: support booting from NFS, VSCode clangd AdrianF
2026-09-09 21:53 ` [PATCH 01/15] devtool: deploy: split ssh deployment into a separate function AdrianF
2026-09-09 21:53 ` [PATCH 02/15] devtool: deploy: allow deploying directly into a local rootfs directory AdrianF
2026-09-09 21:53 ` [PATCH 03/15] oe-selftest: devtool deploy-target: test deploying into a local rootfs path AdrianF
2026-09-09 21:53 ` [PATCH 04/15] devtool: ide-sdk: support NFS rootfs AdrianF
2026-09-09 21:53 ` [PATCH 05/15] oe-selftest: devtool ide-sdk: test NFS debug rootfs AdrianF
2026-09-09 21:53 ` [PATCH 06/15] runqemu-extract-sdk: refactor in Python AdrianF
2026-09-10 17:45   ` Richard Purdie [this message]
2026-09-09 21:53 ` [PATCH 07/15] devtool: ide-sdk: reuse pseudo_rootfs_utils for SDK rootfs extraction AdrianF
2026-09-09 21:53 ` [PATCH 08/15] cpp-example: update formatting and code style AdrianF
2026-09-09 21:53 ` [PATCH 09/15] cpp-example: fix clang-tidy warnings AdrianF
2026-09-09 21:53 ` [PATCH 10/15] devtool: ide-sdk: add clangd support for VSCode IntelliSense AdrianF
2026-09-09 21:53 ` [PATCH 11/15] devtool: ide-sdk: support clangd for non-clang toolchain recipes AdrianF
2026-09-09 21:53 ` [PATCH 12/15] devtool: ide-sdk: format C/C++ with clangd when .clang-format is present AdrianF
2026-09-09 21:53 ` [PATCH 13/15] devtool: ide-sdk: support LLDB ATTACH mode AdrianF
2026-09-09 21:53 ` [PATCH 14/15] devtool: ide-sdk: pin BBPATH in generated do_install script AdrianF
2026-09-09 21:53 ` [PATCH 15/15] buildstats: close proc/disk log files via weakref.finalize safety net AdrianF

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e96a5c72b21a10328862ebfd760d16a57cdc2d71.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=adrian.freihofer@siemens.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox