Skip to contentSkip to conversation

Initial functional vcontainer --config feature for CI auth

RFC PATCH In review Tim Orling 2 participants 8 messages Apr 28

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

cover Initial functional vcontainer --config feature for CI auth

This is an initial attempt to share a new feature for vcontainer which mounts credentials (e.g. ~/.docker/config.json or podman's auth.json) into QEMU as a 9p mount. This avoids some ugly hoops we would have to jump through to pass the credentials with --password-stdin.

This series was heavily reliant on Claude Cowork, and hence is a bit verbose in places. I chose to share it as is (and as tested) for this initial RFC.

The tests (test_vcontainer_auth_config.py) all pass in a local Yocto AutoBuilder test run.

The feature itself was also tested on a local Yocto AutoBuilder 'containers-library' run which successfully pushed a 'python' container to registry.yocto.io[1] and quay.io/yocto[2] with the "Robot Account" or equivalent credentials.

Once we agree upon a functional state of this patch series, the changes for yocto-autobuilder2 and yocto-autobuilder-helper can be shared in a meaningful way, since they are dependent upon this feature.

[1] https://registry.yocto.io/account/sign-in?globalSearch=library
[2] https://quay.io/repository/yocto/python?tab=tags

Tim Orling (4):
vcontainer: add --config / VDKR_CONFIG for docker/podman auth
credentials
tests: add vcontainer --config / VDKR_CONFIG auth plumbing tests vcontainer-initramfs-create.inc: depend on virtual/kernel:do_deploy
vcontainer-tarball: fix SDK environment script for CI

 .gitignore                                    |   1 +
 recipes-containers/vcontainer/README.md       |  54 ++
 .../vcontainer/files/vcontainer-common.sh     |  18 +
 .../files/vcontainer-init-common.sh           |  54 ++
 .../vcontainer/files/vdkr-init.sh             |  58 ++
 .../vcontainer/files/vpdmn-init.sh            |  61 ++
 .../vcontainer/files/vrunner.sh               | 147 ++++
 .../vcontainer-initramfs-create.inc           |  19 +-
 .../vcontainer/vcontainer-tarball.bb          |  69 +-
 tests/test_vcontainer_auth_config.py          | 642 ++++++++++++++++++
 10 files changed, 1106 insertions(+), 17 deletions(-)
 create mode 100644 tests/test_vcontainer_auth_config.py
Signature · 1 line
2.50.1 (Apple Git-155)
author
#1 lore raw

RFC PATCH 1/4 vcontainer: add --config / VDKR_CONFIG for docker/podman auth credentials

Add a VDKR_CONFIG / VPDMN_CONFIG env var and a matching --config <path> CLI flag that passes an existing docker config.json / podman auth.json into the QEMU-hosted container runtime so pulls from private registries work without having to retype --registry-user / --registry-pass on every command.

Security posture (defence in depth):
- Host-side pre-flight validation in vrunner.sh (validate_auth_config):
reject symlinks, non-regular files, missing / unreadable files, files smaller than 2 bytes (minimum "{}") or larger than 1 MiB, and any permissions other than 0400 / 0600 / 0200. WARN if not owned by the invoking user.
- Stage the file into a dedicated per-invocation directory under $TEMP_DIR at mode 0400 inside a 0700 parent; auto-cleanup rides the existing EXIT/INT/TERM trap.
- Expose the staged file over a *separate* read-only virtio-9p tag ("${TOOL_NAME}_auth") so credentials cannot leak into the general /mnt/share input/output directory or into storage.tar outputs.
- Only a boolean flag ("${CMDLINE_PREFIX}_auth=1") is appended to the kernel cmdline - never the path, the env var name, or the contents.
- Guest mounts /mnt/auth ro,nosuid,nodev,noexec, copies to the runtime's canonical path, then unmounts immediately so neither the runtime nor user workloads keep a reference to the host staging directory.

vrunner.sh:
- Initialise AUTH_CONFIG from $VDKR_CONFIG / $VPDMN_CONFIG
- Parse --config <path> (overrides the env vars)
- Add validate_auth_config() and setup_auth_share() with the rules above
- Call setup_auth_share in both the daemon start path and the non-daemon / batch-import path

vcontainer-init-common.sh:
- Default RUNTIME_AUTH="0" and parse ${VCONTAINER_RUNTIME_PREFIX}_auth=* from the kernel cmdline
- Define mount_auth_share() / unmount_auth_share() using the per-runtime "${VCONTAINER_RUNTIME_NAME}_auth" 9p tag, mounted at /mnt/auth with ro,nosuid,nodev,noexec

vdkr-init.sh:
- install_auth_config() copies /mnt/auth/config.json to /root/.docker/config.json (mode 0600; parent dir 0700)
- Called after install_registry_ca in main flow so --config takes precedence over --registry-user / --registry-pass; logs a NOTE when both mechanisms are supplied
- Unmounts /mnt/auth after copy

vpdmn-init.sh:
- install_auth_config() copies to /run/containers/0/auth.json (the rootful podman canonical path) and exports REGISTRY_AUTH_FILE so the creds are picked up regardless of podman's search order
- Mode 0600 on the file, 0700 on the containing directory
- Unmounts /mnt/auth after copy

vcontainer-common.sh:
- Honour $VDKR_CONFIG / $VPDMN_CONFIG, parse --config, and forward AUTH_CONFIG to vrunner.sh via --config in build_runner_args
- Document the flag and env vars in show_usage

README.md:
- New "Passing an existing docker/podman auth file (--config)" section with examples for both runtimes, a table of target paths, and the full security model

AI-Generated: Claude Cowork Opus 4.7

---
 recipes-containers/vcontainer/README.md       |  54 +++++++
 .../vcontainer/files/vcontainer-common.sh     |  18 +++
 .../files/vcontainer-init-common.sh           |  54 +++++++
 .../vcontainer/files/vdkr-init.sh             |  58 +++++++
 .../vcontainer/files/vpdmn-init.sh            |  61 ++++++++
 .../vcontainer/files/vrunner.sh               | 147 ++++++++++++++++++
 6 files changed, 392 insertions(+)
recipes-containers/vcontainer/README.md +54 -0
index 657dd02e..e44616f4 100644
@@ -317,6 +317,60 @@ use `--secure-registry --ca-cert`:
 vdkr --secure-registry --ca-cert /path/to/ca.crt pull myimage
 ```
 
+### Passing an existing docker/podman auth file (`--config`)
+
+If you already have credentials set up on the host (for example, from
+running `docker login` locally), you can pass the resulting auth file
+straight through into the emulated environment instead of re-entering
+credentials with `--registry-user`/`--registry-pass`:
+
+```bash
+# Docker (vdkr): uses ~/.docker/config.json by default
+vdkr --config ~/.docker/config.json pull registry.example.com/myimage
+
+# Podman (vpdmn): uses $XDG_RUNTIME_DIR/containers/auth.json
+vpdmn --config $XDG_RUNTIME_DIR/containers/auth.json pull registry.example.com/myimage
+```
+
+The path can also be supplied via environment:
+
+```bash
+export VDKR_CONFIG=$HOME/.docker/config.json
+vdkr pull registry.example.com/myimage
+```
+
+(`VPDMN_CONFIG` is honoured identically by `vpdmn`.)
+
+**What the file ends up as inside the VM:**
+
+| Tool  | Target path                       | Notes                                             |
+| ----- | --------------------------------- | ------------------------------------------------- |
+| vdkr  | `/root/.docker/config.json`       | Mode 0600; containing dir 0700                    |
+| vpdmn | `/run/containers/0/auth.json`     | Mode 0600; `$REGISTRY_AUTH_FILE` exported         |
+
+**Security model.** The credential file is treated as secret material:
+
+- The host-side file **must** be a regular file with mode `0600` or `0400`.
+  World/group-readable files are rejected outright. Symlinks are rejected.
+  Files larger than 1 MiB are rejected.
+- On the host it is copied into a per-invocation private directory under
+  `$TMPDIR/vdkr-$$/auth_share` (mode 0700; file mode 0400) and removed
+  automatically by the `EXIT`/`INT`/`TERM` trap when `vrunner.sh` exits.
+- It is exposed to the guest on a **dedicated** virtio-9p share whose
+  mount tag (`vdkr_auth` / `vpdmn_auth`) is distinct from the general
+  `*_share` share used for input/output. The guest mounts it **read-only**
+  at `/mnt/auth`, copies it into the runtime's credential location, then
+  **unmounts** `/mnt/auth` so nothing in the VM retains an open reference
+  to the host staging directory.
+- Nothing about the file appears on the kernel command line. Only a
+  boolean flag (`docker_auth=1` / `podman_auth=1`) is passed so the guest
+  init script knows to look on the auth share.
+- When both `--config` and `--registry-user`/`--registry-pass` are
+  supplied, `--config` wins and a NOTE is logged.
+- `--config` is NOT forwarded into container workloads (it only reaches
+  the container engine's credential store); containers themselves never
+  see `/mnt/auth`.
+
 ## Volume Mounts
 
 Mount host directories into containers using `-v` (requires memory resident mode):
recipes-containers/vcontainer/files/vcontainer-common.sh +18 -0
index d5637c9e..48f85c97 100755
@@ -718,6 +718,11 @@ ${BOLD}GLOBAL OPTIONS:${NC}
     --registry <url>      Default registry for unqualified images (e.g., 10.0.2.2:5000/yocto)
     --no-registry         Disable baked-in default registry (use images as-is)
     --insecure-registry <host:port>  Mark registry as insecure (HTTP). Can repeat.
+    --config <path>       Registry auth file (docker config.json / podman auth.json)
+                          Defaults to \$VDKR_CONFIG / \$VPDMN_CONFIG. The file must be
+                          mode 0600 or stricter; it is passed to the guest over a
+                          dedicated read-only virtio-9p share and never appears on
+                          the kernel cmdline.
     --verbose, -v         Enable verbose output
     --help, -h            Show this help
 
@@ -857,6 +862,7 @@ build_runner_args() {
     [ -n "$CA_CERT" ] && args+=("--ca-cert" "$CA_CERT")
     [ -n "$REGISTRY_USER" ] && args+=("--registry-user" "$REGISTRY_USER")
     [ -n "$REGISTRY_PASS" ] && args+=("--registry-pass" "$REGISTRY_PASS")
+    [ -n "$AUTH_CONFIG" ] && args+=("--config" "$AUTH_CONFIG")
 
     # Xen: pass exit grace period
     [ -n "${VXN_EXIT_GRACE_PERIOD:-}" ] && args+=("--exit-grace-period" "$VXN_EXIT_GRACE_PERIOD")
@@ -880,6 +886,11 @@ SECURE_REGISTRY="false"
 CA_CERT=""
 REGISTRY_USER=""
 REGISTRY_PASS=""
+# Registry auth config file. Env-var default depends on which CLI wrapper is
+# in use (vdkr → $VDKR_CONFIG, vpdmn → $VPDMN_CONFIG), then falls back to the
+# other for convenience when sharing a single host-side file. Overridden by
+# the --config CLI flag below.
+AUTH_CONFIG="${VDKR_CONFIG:-${VPDMN_CONFIG:-}}"
 COMMAND=""
 COMMAND_ARGS=()
 
@@ -977,6 +988,13 @@ while [ $# -gt 0 ]; do
             REGISTRY_PASS="$2"
             shift 2
             ;;
+        --config)
+            # Path to a docker/podman registry auth file (config.json / auth.json).
+            # Overrides $VDKR_CONFIG / $VPDMN_CONFIG. Forwarded to vrunner.sh --config,
+            # which validates the file and stages it on a dedicated read-only 9p share.
+            AUTH_CONFIG="$2"
+            shift 2
+            ;;
         -it|--interactive)
             INTERACTIVE="true"
             shift
recipes-containers/vcontainer/files/vcontainer-init-common.sh +54 -0

72 lines not on this page · raw message

recipes-containers/vcontainer/files/vdkr-init.sh +58 -0

76 lines not on this page · raw message

recipes-containers/vcontainer/files/vpdmn-init.sh +61 -0

79 lines not on this page · raw message

recipes-containers/vcontainer/files/vrunner.sh +147 -0

183 lines not on this page · raw message

Signature · 1 line
2.50.1 (Apple Git-155)
author
#2 lore raw

RFC PATCH 2/4 tests: add vcontainer --config / VDKR_CONFIG auth plumbing tests

In reply to Tim Orling

Add a new pytest module (tests/test_vcontainer_auth_config.py) covering the registry-auth-config feature introduced in the previous commit. Split into two tiers:

TestAuthConfigStaticPlumbing (40 static/shell-level assertions):
- vrunner.sh: AUTH_CONFIG picks up VDKR_CONFIG/VPDMN_CONFIG; --config parsing; validate_auth_config and setup_auth_share definitions; every validator reject rule (symlink / non-regular / unreadable / missing / <2B / >1MiB / mode whitelist 400|600|200 / non-owner WARN); 0700 staging dir and 0400 staged file; readonly=on on the 9p share; dedicated ${TOOL_NAME}_auth tag. Critically also asserts that AUTH_CONFIG, VDKR_CONFIG and VPDMN_CONFIG never appear in KERNEL_APPEND - only the ${CMDLINE_PREFIX}_auth=1 flag does.
- vcontainer-common.sh: env-var init, --config parsing, AUTH_CONFIG forwarding via --config to vrunner, and show_usage documentation.
- vcontainer-init-common.sh: RUNTIME_AUTH default, cmdline parsing, mount_auth_share/unmount_auth_share presence, dedicated per-runtime ${VCONTAINER_RUNTIME_NAME}_auth tag, and the ro,nosuid,nodev,noexec mount options.
- vdkr-init.sh: install_auth_config present, writes to /root/.docker/config.json with 0600 and 0700 parent, mount + unmount pairing, precedence NOTE logged, and ordering after install_registry_ca so --config wins over --registry-user/-pass.
- vpdmn-init.sh: writes to /run/containers/0/auth.json with matching modes, exports REGISTRY_AUTH_FILE, mount/unmount pairing, and ordering after verify_podman.
- README.md: --config section exists and documents both env vars and both runtime target paths.

TestAuthConfigValidator (13 functional cases):
- Extracts validate_auth_config() from vrunner.sh with a brace-matching parser, sources it in a bash subshell with a stubbed log() helper, and drives it with real files: accepts modes 0600 / 0400, accepts the 2-byte minimum "{}", rejects missing / symlink / directory / empty / 1-byte / >1 MiB / 0644 (world-readable) / 0640 / 0700 (owner-exec) / 0000 (unreadable, skipped when running as root).

Path resolution is resilient: VCONTAINER_FILES_DIR env override first, otherwise repo-relative to the test file, falling back to the /opt/bruce/poky path used elsewhere in the suite. No tests need QEMU, a registry, or network. All 53 tests complete in ~0.1s.

Add tests/__pycache__ to .gitignore.

AI-Generated: Claude Cowork Opus 4.7

---
 .gitignore                           |   1 +
 tests/test_vcontainer_auth_config.py | 642 +++++++++++++++++++++++++++
 2 files changed, 643 insertions(+)
 create mode 100644 tests/test_vcontainer_auth_config.py
.gitignore +1 -0
index daeb43d5..49b373f8 100644
@@ -7,3 +7,4 @@ pyshtables.py
 *~
 scripts/lib/wic/plugins/source/__pycache__
 lib/oeqa/runtime/cases/__pycache__
+tests/__pycache__
tests/test_vcontainer_auth_config.py new file +642 -0

642 lines not on this page · raw message

Signature · 1 line
2.50.1 (Apple Git-155)
author
#3 lore raw

RFC PATCH 3/4 vcontainer-initramfs-create.inc: depend on virtual/kernel:do_deploy

In reply to Tim Orling

vcontainer-tarball fails on sstate-accelerated builds with errors similar to:

  vdkr blob not found: .../tmp-vruntime-x86-64/deploy/images/\
  qemux86-64/vdkr/x86_64/bzImage

do_compile in vcontainer-initramfs-create.inc copies the kernel out of the multiconfig deploy dir:

    KERNEL_FILE="${MC_DEPLOY}/${KERNEL_IMAGETYPE_INITRAMFS}"

but only declares build-time deps on the two image recipes:

    do_compile[depends]  = "${VCONTAINER_RUNTIME}-tiny-initramfs-image:do_image_complete"
    do_compile[depends] += "${VCONTAINER_RUNTIME}-rootfs-image:do_image_complete"

The existing comment argued that the kernel is "built as a dependency of the rootfs image" so no explicit kernel dep was needed. That conflates building with deploying: a core-image rootfs needs the kernel via virtual/kernel:do_shared_workdir / do_packagedata, but it does not force virtual/kernel:do_deploy. The bare bzImage / Image symlink only lands in DEPLOY_DIR_IMAGE when something explicitly pulls in virtual/kernel:do_deploy (typically qemuboot.bbclass or an IMAGE_CLASSES inherit), which the vruntime-* multiconfigs do not do.

Why sstate exposes it so reliably:

- On a clean from-source build the kernel ends up deployed transitively through other mechanisms and do_compile finds it by accident.
- On an sstate-accelerated build, <runtime>-rootfs-image:do_image_complete is restored straight from cache, virtual/kernel:do_deploy is never invoked, MC_DEPLOY/bzImage doesn't exist, do_compile only emits a bbwarn, and do_deploy silently skips the kernel install because of its if [ -f ${B}/kernel ] guard. vcontainer-tarball is then the one that finally fatals with "vdkr blob not found".
- Because the kernel wasn't in do_compile's signature, the do_deploy sstate key didn't reflect it either, so a cached kernel-less deploy could be reused indefinitely.

Fix: declare an explicit intra-multiconfig dep on virtual/kernel:do_deploy. The recipe runs inside the mc (it is pulled in as mc::<mc>:vdkr-initramfs-create:do_deploy from vcontainer-tarball.bb), so a plain depends — not mcdepends — is correct. Also promote the missing-kernel bbwarn to bbfatal so a future regression fails loudly at the producing recipe instead of downstream in vcontainer-tarball.

AI-Generated: Claude Cowork Opus 4.7

---
 .../vcontainer-initramfs-create.inc           | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
recipes-containers/vcontainer/vcontainer-initramfs-create.inc +14 -5
index 1a22c3d4..29b14e20 100644
@@ -58,12 +58,18 @@ INHIBIT_DEFAULT_DEPS = "1"
 # Dependencies:
 # 1. The tiny initramfs image (produces cpio.gz)
 # 2. The multiconfig rootfs image (produces squashfs)
-# 3. The kernel from main build
-#
-# Both initramfs and rootfs images are in the same multiconfig
+# 3. The kernel's do_deploy (so ${MC_DEPLOY}/${KERNEL_IMAGETYPE_INITRAMFS}
+#    — e.g. bzImage/Image — actually exists before do_compile reads it).
+#    Being a build-time dep of the rootfs image is not enough: image
+#    recipes don't imply virtual/kernel:do_deploy, so on an sstate-
+#    accelerated build the kernel binary never lands in MC_DEPLOY and
+#    this recipe silently deploys a kernel-less blob set, which later
+#    fatals in vcontainer-tarball as "vdkr blob not found: .../bzImage".
+#    The dep is intra-multiconfig (this recipe runs inside the mc), so
+#    a plain depends — not mcdepends — is correct.
 do_compile[depends] = "${VCONTAINER_RUNTIME}-tiny-initramfs-image:do_image_complete"
 do_compile[depends] += "${VCONTAINER_RUNTIME}-rootfs-image:do_image_complete"
-# mcdepends set conditionally in anonymous python below
+do_compile[depends] += "virtual/kernel:do_deploy"
 
 S = "${UNPACKDIR}"
 B = "${WORKDIR}/build"
@@ -152,7 +158,10 @@ do_compile() {
         KERNEL_SIZE=$(stat -c%s ${B}/kernel)
         bbnote "Kernel copied: ${KERNEL_SIZE} bytes ($(expr ${KERNEL_SIZE} / 1024 / 1024)MB)"
     else
-        bbwarn "Kernel not found at ${KERNEL_FILE} — check that the vruntime multiconfig kernel is built"
+        # Fatal rather than warn: silently shipping a kernel-less blob set
+        # lets vcontainer-tarball get much further before failing with a
+        # confusing "vdkr blob not found" and produces stale sstate.
+        bbfatal "Kernel not found at ${KERNEL_FILE}. This usually means virtual/kernel:do_deploy was not pulled into the multiconfig build graph; ensure do_compile[depends] includes virtual/kernel:do_deploy."
     fi
 }
 
Signature · 1 line
2.50.1 (Apple Git-155)
#4 lore raw

Re: [meta-virtualization] [RFC PATCH 3/4] vcontainer-initramfs-create.inc: depend on virtual/kernel:do_deploy

Quoted 43 lines · Tim Orling via lists.yoctoproject.org

vcontainer-tarball fails on sstate-accelerated builds with errors similar to:

  vdkr blob not found: .../tmp-vruntime-x86-64/deploy/images/\
  qemux86-64/vdkr/x86_64/bzImage

do_compile in vcontainer-initramfs-create.inc copies the kernel out of the multiconfig deploy dir:

    KERNEL_FILE="${MC_DEPLOY}/${KERNEL_IMAGETYPE_INITRAMFS}"

but only declares build-time deps on the two image recipes:

do_compile[depends] =
"${VCONTAINER_RUNTIME}-tiny-initramfs-image:do_image_complete"

    do_compile[depends] +=

"${VCONTAINER_RUNTIME}-rootfs-image:do_image_complete"

The existing comment argued that the kernel is "built as a dependency of the rootfs image" so no explicit kernel dep was needed. That conflates building with deploying: a core-image rootfs needs the kernel via virtual/kernel:do_shared_workdir / do_packagedata, but it does not force virtual/kernel:do_deploy. The bare bzImage / Image symlink only lands in DEPLOY_DIR_IMAGE when something explicitly pulls in virtual/kernel:do_deploy (typically qemuboot.bbclass or an IMAGE_CLASSES inherit), which the vruntime-* multiconfigs do not do.

Why sstate exposes it so reliably:

- On a clean from-source build the kernel ends up deployed transitively through other mechanisms and do_compile finds it by accident.
- On an sstate-accelerated build,
<runtime>-rootfs-image:do_image_complete
is restored straight from cache, virtual/kernel:do_deploy is never invoked, MC_DEPLOY/bzImage doesn't exist, do_compile only emits a bbwarn, and do_deploy silently skips the kernel install because of its if [ -f ${B}/kernel ] guard. vcontainer-tarball is then the one that finally fatals with "vdkr blob not found".
- Because the kernel wasn't in do_compile's signature, the do_deploy sstate key didn't reflect it either, so a cached kernel-less deploy could be reused indefinitely.

Quoted 8 lines

Fix: declare an explicit intra-multiconfig dep on virtual/kernel:do_deploy. The recipe runs inside the mc (it is pulled in as mc::<mc>:vdkr-initramfs-create:do_deploy from vcontainer-tarball.bb), so a plain depends — not mcdepends — is correct. Also promote the missing-kernel bbwarn to bbfatal so a future regression fails loudly at the producing recipe instead of downstream in vcontainer-tarball.

Your diagnosis of the sstate failure looks right to me.

do_image_complete runs before do_build, so the virtual/kernel:do_deploy dependency attached to do_build in image.bbclass is never pulled into the dependency chain. The kernel ends up in MC_DEPLOY by accident on clean builds but is missing on sstate-accelerated ones.

However, I'd prefer not to add an explicit virtual/kernel:do_deploy dependency to the initramfs-create recipe. This recipe is designed as a best-effort
blob assembler — the kernel is intentionally optional (bbwarn, not bbfatal) to support use cases where the kernel is provided externally or from the main build. Adding a hard dependency on virtual/kernel:do_deploy couples
the recipe to the multiconfig kernel build and prevents those use cases.

Instead, I've fixed this by changing the dependency from do_image_complete to do_build:

do_compile[depends] =
"${VCONTAINER_RUNTIME}-tiny-initramfs-image:do_build"
do_compile[depends] += "${VCONTAINER_RUNTIME}-rootfs-image:do_build"

Both image recipes inherit core-image → image.bbclass, which has:

  KERNEL_DEPLOY_DEPEND ?= "virtual/kernel:do_deploy"
  do_build[depends] += "${KERNEL_DEPLOY_DEPEND}"

By depending on do_build instead of do_image_complete, we get virtual/kernel:do_deploy transitively through the existing image.bbclass dependency chain ... no new coupling needed. The image artifacts are already deployed after do_image_complete, so they're available when our do_compile runs after do_build.

I've also kept the bbwarn rather than promoting to bbfatal .. the blob assembler should remain permissive, while vcontainer-tarball.bb (the final packager) is the one that enforces completeness with bbfatal.

I'd also like to change the name of the initramfs recipe, since it really isn't building an initramfs, but that's for another time.

If I merge my version, can you test it in the AB environment to see if the fix holds ? If it doesn't, we'll just go with your patch.

Bruce

Quoted 68 lines

AI-Generated: Claude Cowork Opus 4.7

---
 .../vcontainer-initramfs-create.inc           | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
recipes-containers/vcontainer/vcontainer-initramfs-create.inc +9 -3
index 1a22c3d4..29b14e20 100644
@@ -58,12 +58,18 @@ INHIBIT_DEFAULT_DEPS = "1"
 # Dependencies:
 # 1. The tiny initramfs image (produces cpio.gz)
 # 2. The multiconfig rootfs image (produces squashfs)
-# 3. The kernel from main build
-#
-# Both initramfs and rootfs images are in the same multiconfig
+# 3. The kernel's do_deploy (so ${MC_DEPLOY}/${KERNEL_IMAGETYPE_INITRAMFS}
+#    — e.g. bzImage/Image — actually exists before do_compile reads it).
+#    Being a build-time dep of the rootfs image is not enough: image
+#    recipes don't imply virtual/kernel:do_deploy, so on an sstate-
+#    accelerated build the kernel binary never lands in MC_DEPLOY and
+#    this recipe silently deploys a kernel-less blob set, which later
+#    fatals in vcontainer-tarball as "vdkr blob not found: .../bzImage".
+#    The dep is intra-multiconfig (this recipe runs inside the mc), so
+#    a plain depends — not mcdepends — is correct.
 do_compile[depends] =

"${VCONTAINER_RUNTIME}-tiny-initramfs-image:do_image_complete"
do_compile[depends] +=
"${VCONTAINER_RUNTIME}-rootfs-image:do_image_complete"

recipes-containers/vcontainer/vcontainer-initramfs-create.inc +1 -1
-# mcdepends set conditionally in anonymous python below
+do_compile[depends] += "virtual/kernel:do_deploy"
 
 S = "${UNPACKDIR}"
 B = "${WORKDIR}/build"
@@ -152,7 +158,10 @@ do_compile() {
         KERNEL_SIZE=$(stat -c%s ${B}/kernel)
         bbnote "Kernel copied: ${KERNEL_SIZE} bytes ($(expr

${KERNEL_SIZE} / 1024 / 1024)MB)"
else
- bbwarn "Kernel not found at ${KERNEL_FILE} — check that the
vruntime multiconfig kernel is built"

recipes-containers/vcontainer/vcontainer-initramfs-create.inc +4 -0
+        # Fatal rather than warn: silently shipping a kernel-less blob set
+        # lets vcontainer-tarball get much further before failing with a
+        # confusing "vdkr blob not found" and produces stale sstate.
+        bbfatal "Kernel not found at ${KERNEL_FILE}. This usually means

virtual/kernel:do_deploy was not pulled into the multiconfig build graph; ensure do_compile[depends] includes virtual/kernel:do_deploy."
fi
}

--
2.50.1 (Apple Git-155)

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#9752):
https://lists.yoctoproject.org/g/meta-virtualization/message/9752
Mute This Topic: https://lists.yoctoproject.org/mt/119042095/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
author
#5 lore raw

RFC PATCH 4/4 vcontainer-tarball: fix SDK environment script for CI

In reply to Tim Orling

When running in an AutoBuilder context, the variables are stripped since the script is not actually "sourced", but rather parsed.

This resulted in VCONTAINER_DIR being empty and therefore no 'vdkr', 'vpdmn' and friends available to run in CI builder steps.

AI-Generated: Claude Cowork Opus 4.7

---
 .../vcontainer/vcontainer-tarball.bb          | 69 +++++++++++++++----
 1 file changed, 57 insertions(+), 12 deletions(-)
recipes-containers/vcontainer/vcontainer-tarball.bb +57 -12
index ed9b8e13..9564164c 100644
@@ -353,20 +353,57 @@ EOF
     script=${SDK_OUTPUT}/${SDKPATH}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
 
     # Create environment script
-    # Set OECORE_NATIVE_SYSROOT temporarily for SDK relocation, then unset it
-    # (like buildtools-tarball does to avoid confusing other Yocto tools)
+    #
+    # The script is written so that it works both when sourced by bash (the
+    # normal interactive / devshell case) AND when "installed" by
+    # yocto-autobuilder-helper's enable_tools_tarball() in CI, which does NOT
+    # source the file with bash -- it parses line by line in Python and only
+    # honours lines that start with "export " or "unset " at column 0, and
+    # only substitutes $PATH (see yocto-autobuilder-helper/scripts/utils.py).
+    #
+    # Consequences:
+    #  - The primary VCONTAINER_DIR / OECORE_NATIVE_SYSROOT / PATH values must
+    #    be emitted as plain `export FOO="<absolute-path>"` lines with the
+    #    absolute paths baked in at build time via Yocto variables
+    #    (${SDKPATH}, ${SDKPATHNATIVE}). Yocto SDK relocation rewrites these
+    #    paths at install time (via the installer's -d <dir> argument).
+    #  - PATH must not reference $VCONTAINER_DIR / $OECORE_NATIVE_SYSROOT via
+    #    shell indirection (the Python parser won't expand them); inline the
+    #    absolute paths there too.
+    #  - Any bash-only refinement (BASH_SOURCE-based relocation, final
+    #    unset of OECORE_NATIVE_SYSROOT) lives inside an `if` block so the
+    #    Python parser ignores it, while real bash still executes it.
     cat > $script <<'HEADER'
 #!/bin/bash
 # vcontainer environment setup script
 # Source this file: source environment-setup-none
 # Or use the symlink: source init-env.sh
-
-VCONTAINER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 HEADER
-    # Yocto variables (${SDK_SYS}, ${SDKPATHNATIVE}) expand at parse time
-    # Shell variables use $VAR to avoid Yocto expansion
+    # Primary env vars: emit as plain `export FOO="<abs-path>"` so the
+    # yocto-autobuilder-helper Python parser picks them up. Yocto variables
+    # expand at bitbake time; the SDK installer's relocation pass rewrites
+    # the baked-in paths at install time.
+    echo '' >> $script
+    echo '# Primary values -- literal absolute paths that survive parsing by' >> $script
+    echo '# yocto-autobuilder-helper enable_tools_tarball() (not sourced by bash).' >> $script
+    echo '# SDK relocation at install time rewrites the absolute paths below.' >> $script
+    echo 'export VCONTAINER_DIR="'"${SDKPATH}"'"' >> $script
     echo 'export OECORE_NATIVE_SYSROOT="'"${SDKPATHNATIVE}"'"' >> $script
-    echo 'export PATH="$VCONTAINER_DIR:$OECORE_NATIVE_SYSROOT/usr/bin:/usr/bin:/bin:$PATH"' >> $script
+    echo 'export PATH="'"${SDKPATH}"':'"${SDKPATHNATIVE}"'/usr/bin:/usr/bin:/bin:$PATH"' >> $script
+
+    # Bash-only refinement: if the file is actually being sourced by bash,
+    # re-derive VCONTAINER_DIR from the real on-disk location so a manually
+    # moved/copied tarball still works. Invisible to the autobuilder Python
+    # parser (doesn't start with export/unset at column 0).
+    cat >> $script <<'BASHREFINE'
+
+# When sourced by bash (interactive / devshell), prefer the real on-disk
+# location so a manually-moved tarball still works.
+if [ -n "${BASH_SOURCE[0]:-}" ]; then
+    VCONTAINER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+    export VCONTAINER_DIR
+fi
+BASHREFINE
     cat >> $script <<'FOOTER'
 
 echo "vcontainer environment configured."
@@ -395,11 +432,19 @@ echo ""
 echo "Architectures: ${VCONTAINER_ARCHITECTURES}"
 ENVEOF
 
-    # Unset OECORE_NATIVE_SYSROOT to avoid confusing other Yocto tools
-    # (same pattern as buildtools-tarball)
-    echo '' >> $script
-    echo '# Clean up - unset to avoid confusing other Yocto tools' >> $script
-    echo 'unset OECORE_NATIVE_SYSROOT' >> $script
+    # Gated unset: same pattern as buildtools-tarball (unset
+    # OECORE_NATIVE_SYSROOT after interactive sourcing so it doesn't confuse
+    # other Yocto tools), but guarded behind an `if` so the autobuilder's
+    # line-based parser (which matches "unset " only at column 0) leaves
+    # OECORE_NATIVE_SYSROOT set in the CI environment.
+    cat >> $script <<'UNSET_BLOCK'
+
+# Avoid confusing other Yocto tools post-source (matches buildtools-tarball).
+# Gated so yocto-autobuilder-helper's parser leaves OECORE_NATIVE_SYSROOT set.
+if [ -n "${BASH_SOURCE[0]:-}" ]; then
+    unset OECORE_NATIVE_SYSROOT
+fi
+UNSET_BLOCK
 
     # Replace placeholder with actual SDK_SYS
     sed -i -e "s:@SDK_SYS@:${SDK_SYS}:g" $script
Signature · 1 line
2.50.1 (Apple Git-155)
#6 lore raw

Re: [meta-virtualization] [RFC PATCH 4/4] vcontainer-tarball: fix SDK environment script for CI

Quoted 6 lines · Tim Orling via lists.yoctoproject.org

When running in an AutoBuilder context, the variables are stripped since the script is not actually "sourced", but rather parsed.

This resulted in VCONTAINER_DIR being empty and therefore no 'vdkr', 'vpdmn' and friends available to run in CI builder steps.

Tim,

I agree the autobuilder's Python parser can't handle our bash-oriented environment script, but I'd rather not add this much complexity to make one script serve both environments.

The inline if [ -n "${BASH_SOURCE[0]:-}" ] guards and dual-path logic make the script harder to reason about and maintain.

Instead, I think we should generate two scripts:

1. environment-setup-* (existing) — stays as-is, pure bash, BASH_SOURCE
based, for interactive/devshell use
2. environment-setup-ci — flat export FOO="/absolute/path" lines with
baked-in paths, no shell variable references, no unset, specifically for the autobuilder's enable_tools_tarball() parser

The CI script would be simple:

export VCONTAINER_DIR="/opt/poky/sysroots/x86_64-pokysdk-linux"
export OECORE_NATIVE_SYSROOT="/opt/poky/sysroots/x86_64-pokysdk-linux"
export
PATH="/opt/poky/sysroots/x86_64-pokysdk-linux:/opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin:/usr/bin:/bin"

SDK relocation rewrites the absolute paths at install time. The autobuilder helper would reference this file instead of the bash one. No conditional logic, no dual-purpose complexity.

Would this work with the autobuilder helper's enable_tools_tarball()?

If so I can implement it.

Bruce

Quoted 141 lines

AI-Generated: Claude Cowork Opus 4.7

---
 .../vcontainer/vcontainer-tarball.bb          | 69 +++++++++++++++----
 1 file changed, 57 insertions(+), 12 deletions(-)
recipes-containers/vcontainer/vcontainer-tarball.bb +0 -1
index ed9b8e13..9564164c 100644
@@ -353,20 +353,57 @@ EOF
 
 script=${SDK_OUTPUT}/${SDKPATH}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
 
     # Create environment script
-    # Set OECORE_NATIVE_SYSROOT temporarily for SDK relocation, then

unset it

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -1
-    # (like buildtools-tarball does to avoid confusing other Yocto tools)
+    #
+    # The script is written so that it works both when sourced by bash

(the

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -0
+    # normal interactive / devshell case) AND when "installed" by
+    # yocto-autobuilder-helper's enable_tools_tarball() in CI, which does

NOT
+ # source the file with bash -- it parses line by line in Python and
only

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -0
+    # honours lines that start with "export " or "unset " at column 0, and
+    # only substitutes $PATH (see

yocto-autobuilder-helper/scripts/utils.py).

recipes-containers/vcontainer/vcontainer-tarball.bb +3 -0
+    #
+    # Consequences:
+    #  - The primary VCONTAINER_DIR / OECORE_NATIVE_SYSROOT / PATH values

must

recipes-containers/vcontainer/vcontainer-tarball.bb +3 -0
+    #    be emitted as plain `export FOO="<absolute-path>"` lines with the
+    #    absolute paths baked in at build time via Yocto variables
+    #    (${SDKPATH}, ${SDKPATHNATIVE}). Yocto SDK relocation rewrites

these

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -0
+    #    paths at install time (via the installer's -d <dir> argument).
+    #  - PATH must not reference $VCONTAINER_DIR / $OECORE_NATIVE_SYSROOT

via
+ # shell indirection (the Python parser won't expand them); inline
the

recipes-containers/vcontainer/vcontainer-tarball.bb +6 -4
+    #    absolute paths there too.
+    #  - Any bash-only refinement (BASH_SOURCE-based relocation, final
+    #    unset of OECORE_NATIVE_SYSROOT) lives inside an `if` block so the
+    #    Python parser ignores it, while real bash still executes it.
     cat > $script <<'HEADER'
 #!/bin/bash
 # vcontainer environment setup script
 # Source this file: source environment-setup-none
 # Or use the symlink: source init-env.sh
-
-VCONTAINER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 HEADER
-    # Yocto variables (${SDK_SYS}, ${SDKPATHNATIVE}) expand at parse time
-    # Shell variables use $VAR to avoid Yocto expansion
+    # Primary env vars: emit as plain `export FOO="<abs-path>"` so the
+    # yocto-autobuilder-helper Python parser picks them up. Yocto

variables

recipes-containers/vcontainer/vcontainer-tarball.bb +4 -0
+    # expand at bitbake time; the SDK installer's relocation pass rewrites
+    # the baked-in paths at install time.
+    echo '' >> $script
+    echo '# Primary values -- literal absolute paths that survive parsing

by' >> $script
+ echo '# yocto-autobuilder-helper enable_tools_tarball() (not sourced
by bash).' >> $script
+ echo '# SDK relocation at install time rewrites the absolute paths
below.' >> $script

recipes-containers/vcontainer/vcontainer-tarball.bb +1 -1
+    echo 'export VCONTAINER_DIR="'"${SDKPATH}"'"' >> $script
     echo 'export OECORE_NATIVE_SYSROOT="'"${SDKPATHNATIVE}"'"' >> $script
-    echo 'export

PATH="$VCONTAINER_DIR:$OECORE_NATIVE_SYSROOT/usr/bin:/usr/bin:/bin:$PATH"'

Quoted 1 line
Quoted 1 line

$script

+ echo 'export
PATH="'"${SDKPATH}"':'"${SDKPATHNATIVE}"'/usr/bin:/usr/bin:/bin:$PATH"' >> $script

recipes-containers/vcontainer/vcontainer-tarball.bb +3 -0
+
+    # Bash-only refinement: if the file is actually being sourced by bash,
+    # re-derive VCONTAINER_DIR from the real on-disk location so a

manually
+ # moved/copied tarball still works. Invisible to the autobuilder
Python

recipes-containers/vcontainer/vcontainer-tarball.bb +10 -4
+    # parser (doesn't start with export/unset at column 0).
+    cat >> $script <<'BASHREFINE'
+
+# When sourced by bash (interactive / devshell), prefer the real on-disk
+# location so a manually-moved tarball still works.
+if [ -n "${BASH_SOURCE[0]:-}" ]; then
+    VCONTAINER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+    export VCONTAINER_DIR
+fi
+BASHREFINE
     cat >> $script <<'FOOTER'
 
 echo "vcontainer environment configured."
@@ -395,11 +432,19 @@ echo ""
 echo "Architectures: ${VCONTAINER_ARCHITECTURES}"
 ENVEOF
 
-    # Unset OECORE_NATIVE_SYSROOT to avoid confusing other Yocto tools
-    # (same pattern as buildtools-tarball)
-    echo '' >> $script
-    echo '# Clean up - unset to avoid confusing other Yocto tools' >>

$script

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -1
-    echo 'unset OECORE_NATIVE_SYSROOT' >> $script
+    # Gated unset: same pattern as buildtools-tarball (unset
+    # OECORE_NATIVE_SYSROOT after interactive sourcing so it doesn't

confuse

recipes-containers/vcontainer/vcontainer-tarball.bb +6 -0
+    # other Yocto tools), but guarded behind an `if` so the autobuilder's
+    # line-based parser (which matches "unset " only at column 0) leaves
+    # OECORE_NATIVE_SYSROOT set in the CI environment.
+    cat >> $script <<'UNSET_BLOCK'
+
+# Avoid confusing other Yocto tools post-source (matches

buildtools-tarball).
+# Gated so yocto-autobuilder-helper's parser leaves OECORE_NATIVE_SYSROOT set.

recipes-containers/vcontainer/vcontainer-tarball.bb +4 -1
+if [ -n "${BASH_SOURCE[0]:-}" ]; then
+    unset OECORE_NATIVE_SYSROOT
+fi
+UNSET_BLOCK
 
     # Replace placeholder with actual SDK_SYS
     sed -i -e "s:@SDK_SYS@:${SDK_SYS}:g" $script
--

2.50.1 (Apple Git-155)

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#9753):
https://lists.yoctoproject.org/g/meta-virtualization/message/9753
Mute This Topic: https://lists.yoctoproject.org/mt/119042096/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
author
#7 lore raw

Re: [meta-virtualization] [RFC PATCH 4/4] vcontainer-tarball: fix SDK environment script for CI

Quoted 12 lines · Bruce Ashfield
Quoted 6 lines · Tim Orling via lists.yoctoproject.org

When running in an AutoBuilder context, the variables are stripped since the script is not actually "sourced", but rather parsed.

This resulted in VCONTAINER_DIR being empty and therefore no 'vdkr', 'vpdmn' and friends available to run in CI builder steps.

Quoted 9 lines

Tim,

I agree the autobuilder's Python parser can't handle our bash-oriented environment script, but I'd rather not add this much complexity to make one script serve both environments.

The inline if [ -n "${BASH_SOURCE[0]:-}" ] guards and dual-path logic make the script harder to reason about and maintain.

Agreed. That was an ugly hack and I did not like it either.

Quoted 10 lines

Instead, I think we should generate two scripts:

1. environment-setup-* (existing) — stays as-is, pure bash, BASH_SOURCE
based, for interactive/devshell use
2. environment-setup-ci — flat export FOO="/absolute/path" lines with
baked-in paths, no shell variable references, no unset, specifically for the autobuilder's enable_tools_tarball() parser

The current enable_tools_tarball uses a "greedy" glob of "environment-setup-*" [1], which could be modified to be passed in as a keyword arg -- with a default.

[1]
https://git.yoctoproject.org/yocto-autobuilder-helper/tree/scripts/utils.py?id=7ba82651cae130890e2120dccca939153ec7042e#n445

The CI script would be simple:

Quoted 7 lines

export VCONTAINER_DIR="/opt/poky/sysroots/x86_64-pokysdk-linux"
export OECORE_NATIVE_SYSROOT="/opt/poky/sysroots/x86_64-pokysdk-linux"
export
PATH="/opt/poky/sysroots/x86_64-pokysdk-linux:/opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin:/usr/bin:/bin"

Currently, since the vcontainer-tarball is not yet published to downloads.yoctoproject.org, the CI path is passed in as:
VCONTAINER_SDK=/srv/autobuilder/ autobuilder.yocto.io/pub/vcontainer-tarball-latest/vcontainer-standalone.sh

When 'vcontainer' is enabled as a worker feature, a pre-build step is added which currently installs the SDK to:
/home/pokybuild/yocto-worker/vcontainer-tests/build/build/vcontainer-test-extracted

Where "vcontainer-tests" is a "builder" (job) which needs the SDK installed. This was also partially done this way so
that I can test a "just built" vcontainer-tarball with test jobs like vcontainer-tests, vdkr-tests and vpdmn-tests (before
even trying to build and push containers).

Quoted 4 lines

SDK relocation rewrites the absolute paths at install time. The autobuilder helper would reference this file instead of the bash one. No conditional logic, no dual-purpose complexity.

I agree we should avoid that brittle path of conditional logic and dual-purpose complexity.

Quoted 3 lines

Would this work with the autobuilder helper's enable_tools_tarball()?

I think it will work. Given the reality of how these things interact in the Yocto AutoBuilder context, I will play
around with it. I already know what works and doesn't and how to test it ;)

Thank you for the feedback!

--Tim

Quoted 160 lines

If so I can implement it.

Bruce

Quoted 135 lines

AI-Generated: Claude Cowork Opus 4.7

---
 .../vcontainer/vcontainer-tarball.bb          | 69 +++++++++++++++----
 1 file changed, 57 insertions(+), 12 deletions(-)
recipes-containers/vcontainer/vcontainer-tarball.bb +0 -1
index ed9b8e13..9564164c 100644
@@ -353,20 +353,57 @@ EOF
 
 script=${SDK_OUTPUT}/${SDKPATH}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
 
     # Create environment script
-    # Set OECORE_NATIVE_SYSROOT temporarily for SDK relocation, then

unset it

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -1
-    # (like buildtools-tarball does to avoid confusing other Yocto tools)
+    #
+    # The script is written so that it works both when sourced by bash

(the

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -0
+    # normal interactive / devshell case) AND when "installed" by
+    # yocto-autobuilder-helper's enable_tools_tarball() in CI, which

does NOT
+ # source the file with bash -- it parses line by line in Python and
only
+ # honours lines that start with "export " or "unset " at column 0,
and
+ # only substitutes $PATH (see
yocto-autobuilder-helper/scripts/utils.py).

recipes-containers/vcontainer/vcontainer-tarball.bb +3 -0
+    #
+    # Consequences:
+    #  - The primary VCONTAINER_DIR / OECORE_NATIVE_SYSROOT / PATH

values must
+ # be emitted as plain export FOO="<absolute-path>" lines with
the

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -0
+    #    absolute paths baked in at build time via Yocto variables
+    #    (${SDKPATH}, ${SDKPATHNATIVE}). Yocto SDK relocation rewrites

these

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -0
+    #    paths at install time (via the installer's -d <dir> argument).
+    #  - PATH must not reference $VCONTAINER_DIR /

$OECORE_NATIVE_SYSROOT via
+ # shell indirection (the Python parser won't expand them); inline
the

recipes-containers/vcontainer/vcontainer-tarball.bb +3 -0
+    #    absolute paths there too.
+    #  - Any bash-only refinement (BASH_SOURCE-based relocation, final
+    #    unset of OECORE_NATIVE_SYSROOT) lives inside an `if` block so

the

recipes-containers/vcontainer/vcontainer-tarball.bb +3 -4
+    #    Python parser ignores it, while real bash still executes it.
     cat > $script <<'HEADER'
 #!/bin/bash
 # vcontainer environment setup script
 # Source this file: source environment-setup-none
 # Or use the symlink: source init-env.sh
-
-VCONTAINER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 HEADER
-    # Yocto variables (${SDK_SYS}, ${SDKPATHNATIVE}) expand at parse time
-    # Shell variables use $VAR to avoid Yocto expansion
+    # Primary env vars: emit as plain `export FOO="<abs-path>"` so the
+    # yocto-autobuilder-helper Python parser picks them up. Yocto

variables
+ # expand at bitbake time; the SDK installer's relocation pass
rewrites

recipes-containers/vcontainer/vcontainer-tarball.bb +3 -0
+    # the baked-in paths at install time.
+    echo '' >> $script
+    echo '# Primary values -- literal absolute paths that survive

parsing by' >> $script
+ echo '# yocto-autobuilder-helper enable_tools_tarball() (not sourced
by bash).' >> $script
+ echo '# SDK relocation at install time rewrites the absolute paths
below.' >> $script

recipes-containers/vcontainer/vcontainer-tarball.bb +1 -1
+    echo 'export VCONTAINER_DIR="'"${SDKPATH}"'"' >> $script
     echo 'export OECORE_NATIVE_SYSROOT="'"${SDKPATHNATIVE}"'"' >> $script
-    echo 'export

PATH="$VCONTAINER_DIR:$OECORE_NATIVE_SYSROOT/usr/bin:/usr/bin:/bin:$PATH"'

Quoted 1 line
Quoted 1 line

$script

+ echo 'export
PATH="'"${SDKPATH}"':'"${SDKPATHNATIVE}"'/usr/bin:/usr/bin:/bin:$PATH"' >> $script

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -0
+
+    # Bash-only refinement: if the file is actually being sourced by

bash,
+ # re-derive VCONTAINER_DIR from the real on-disk location so a
manually
+ # moved/copied tarball still works. Invisible to the autobuilder
Python

recipes-containers/vcontainer/vcontainer-tarball.bb +10 -4
+    # parser (doesn't start with export/unset at column 0).
+    cat >> $script <<'BASHREFINE'
+
+# When sourced by bash (interactive / devshell), prefer the real on-disk
+# location so a manually-moved tarball still works.
+if [ -n "${BASH_SOURCE[0]:-}" ]; then
+    VCONTAINER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+    export VCONTAINER_DIR
+fi
+BASHREFINE
     cat >> $script <<'FOOTER'
 
 echo "vcontainer environment configured."
@@ -395,11 +432,19 @@ echo ""
 echo "Architectures: ${VCONTAINER_ARCHITECTURES}"
 ENVEOF
 
-    # Unset OECORE_NATIVE_SYSROOT to avoid confusing other Yocto tools
-    # (same pattern as buildtools-tarball)
-    echo '' >> $script
-    echo '# Clean up - unset to avoid confusing other Yocto tools' >>

$script

recipes-containers/vcontainer/vcontainer-tarball.bb +2 -1
-    echo 'unset OECORE_NATIVE_SYSROOT' >> $script
+    # Gated unset: same pattern as buildtools-tarball (unset
+    # OECORE_NATIVE_SYSROOT after interactive sourcing so it doesn't

confuse

recipes-containers/vcontainer/vcontainer-tarball.bb +6 -0
+    # other Yocto tools), but guarded behind an `if` so the autobuilder's
+    # line-based parser (which matches "unset " only at column 0) leaves
+    # OECORE_NATIVE_SYSROOT set in the CI environment.
+    cat >> $script <<'UNSET_BLOCK'
+
+# Avoid confusing other Yocto tools post-source (matches

buildtools-tarball).
+# Gated so yocto-autobuilder-helper's parser leaves OECORE_NATIVE_SYSROOT set.

recipes-containers/vcontainer/vcontainer-tarball.bb +4 -1
+if [ -n "${BASH_SOURCE[0]:-}" ]; then
+    unset OECORE_NATIVE_SYSROOT
+fi
+UNSET_BLOCK
 
     # Replace placeholder with actual SDK_SYS
     sed -i -e "s:@SDK_SYS@:${SDK_SYS}:g" $script
--

2.50.1 (Apple Git-155)

Quoted 11 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#9753):
https://lists.yoctoproject.org/g/meta-virtualization/message/9753
Mute This Topic: https://lists.yoctoproject.org/mt/119042096/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II