package/dracut: disable dracut-cpio if host-rustc is not available

Since upstream commit 89a86dcb0a3248606824de50f5c63f61cfe0369c (first
release: 106) if cargo exists on PATH the Dracut configure script
enables building dracut-cpio by default, and calls "cargo --version"
to check if cargo works. This fails on the autobuilders:

error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.
dracut couldn't find cargo for dracut-cpio build

The affected configs either don't have BR2_PACKAGE_HOST_RUSTC enabled,
or build-time.log.gz shows host-rustc was not installed before the
host-dracut build, so presumably the "cargo" that produces the rustup
error is an external one already installed on the autobuilders.

To fix this, enable dracut-cpio only if BR2_PACKAGE_HOST_RUSTC=y, and
add a dependency on host-rustc in that case. According to the
documentation [1, see "enhanced_cpio"] dracut-cpio is supposed to
optimize archive creation for copy-on-write filesystems, so it should
not matter much for Buildroot. The --disable-dracut-cpio option was
added in upstream commit 4a4ab928a49e81e02104ec5466160664e59c3965
(same release).

Fixes: https://autobuild.buildroot.org/results/5f557d708cce997e7f039f17e30640b02ba9180a/
Fixes: https://autobuild.buildroot.org/results/f04ca3c4598f62a7e87d84bc111eb8b161b34a70/
(and more)

[1] https://dracut-ng.github.io/dracut/man/dracut.conf.5.html#_configuration_options

Signed-off-by: Fiona Klute (Othermo GmbH) <fiona.klute@gmx.de>
Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
Fiona Klute (Othermo GmbH)
2026-08-18 13:00:25 +02:00
committed by Julien Olivain
parent e991fa0716
commit ff7f973a16

View File

@@ -13,6 +13,13 @@ DRACUT_CPE_ID_VALID = YES
HOST_DRACUT_DEPENDENCIES = host-pkgconf host-kmod host-cross-ldd
HOST_DRACUT_INSTALL_OPTS = systemdsystemunitdir="" install
ifeq ($(BR2_PACKAGE_HOST_RUSTC),y)
HOST_DRACUT_CONF_OPTS += --enable-dracut-cpio
HOST_DRACUT_DEPENDENCIES += host-rustc
else
HOST_DRACUT_CONF_OPTS += --disable-dracut-cpio
endif
define HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT
mv $(HOST_DIR)/bin/dracut $(HOST_DIR)/bin/dracut.real
sed -e "s%@@TARGET_CROSS@@%$(TARGET_CROSS)%" \