On Wed, 2026-09-09 at 23:53 +0200, Adrian Freihofer via lists.openembedded.org 
wrote:
> From: Adrian Freihofer <[email protected]>
> 
> 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 <[email protected]>
> ---
>  .../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


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#245590): 
https://lists.openembedded.org/g/openembedded-core/message/245590
Mute This Topic: https://lists.openembedded.org/mt/121171406/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to