diff mbox series

[v2,1/3] wic: add runtime dependencies on the tools it invokes

Message ID 20260707144009.708407-2-twoerner@gmail.com
State New
Headers show
Series wic: give installed wic the tools it needs | expand

Commit Message

Trevor Woerner July 7, 2026, 2:40 p.m. UTC
wic shells out to a number of host-side tools to do its work: parted,
mkdosfs, mcopy, the mkfs.* family, sfdisk, e2fsck, resize2fs, debugfs,
blkid and more, depending on the operation and on the partition types
in the image.

None of these are declared as dependencies of wic. For the bitbake
do_image_wic task this is handled by the wic-tools recipe, which builds
the tools into a native sysroot. Wherever else wic is installed as a
package it gets none of them, and its offline lookup (wic ls/cp/write)
resolves each tool over a search path that falls back to the host PATH,
so on a machine that happens to have the tool installed system-wide wic
succeeds while on a machine without it wic fails:

  wic.WicError: Can't find executable 'mcopy'

Falling back to the host is unreliable even when the tool is found: wic
depends on specific minimum versions of some of these tools, and an
arbitrary host copy may be too old, so wic can pick up a tool that does
not behave as it needs. Providing the tools as proper dependencies pins
known-good versions rather than leaving it to whatever the host has.

Add the tools as RDEPENDS so they are installed alongside wic and found
regardless of the host. They are added to the nativesdk variant only,
which is where wic is packaged for use outside a bitbake build; the
native and target variants are unaffected (and wic is not expected on a
target).

resize2fs is named explicitly: e2fsprogs splits it into its own
e2fsprogs-resize2fs package, so nativesdk-e2fsprogs alone does not
provide it, and it is needed by the wic cp/write resize path.

syslinux (with its isohybrid helper) is gated to x86 hosts; cdrtools
(mkisofs) is native-only with no nativesdk variant and is only needed
for ISO images, so it cannot be included here.

AI-Generated: codex/claude-opus 4.8 (xhigh)
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
 meta/recipes-support/wic/wic_0.3.0.bb | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-support/wic/wic_0.3.0.bb b/meta/recipes-support/wic/wic_0.3.0.bb
index 7dbf84b039a6..2d4d32a6b15d 100644
--- a/meta/recipes-support/wic/wic_0.3.0.bb
+++ b/meta/recipes-support/wic/wic_0.3.0.bb
@@ -17,4 +17,27 @@  RDEPENDS:${PN} += " \
     python3-misc \
     "
 
+# Pull in the tools wic invokes for the nativesdk variant, where wic is
+# packaged for use outside a bitbake build; native and target are
+# unaffected. resize2fs is named explicitly as e2fsprogs splits it into
+# its own package.
+RDEPENDS:${PN}:append:class-nativesdk = " \
+    nativesdk-parted \
+    nativesdk-gptfdisk \
+    nativesdk-dosfstools \
+    nativesdk-mtools \
+    nativesdk-bmaptool \
+    nativesdk-grub \
+    nativesdk-btrfs-tools \
+    nativesdk-squashfs-tools \
+    nativesdk-e2fsprogs \
+    nativesdk-e2fsprogs-resize2fs \
+    nativesdk-util-linux \
+    nativesdk-tar \
+    nativesdk-erofs-utils \
+"
+
+# syslinux (with its isohybrid helper) only builds for x86 hosts.
+RDEPENDS:${PN}:append:class-nativesdk = "${@' nativesdk-syslinux nativesdk-syslinux-misc' if d.getVar('SDK_ARCH') in ['x86_64', 'i686'] else ''}"
+
 BBCLASSEXTEND = "native nativesdk"