Hello;
I am currently in the process of converting the mender package in Buildroot from 3.x to 4.x, which is quite an extensive overhaul. As I near the end and prepare to submit a patch, I have ran into a rather nasty bug.
If the XZ package is selected, the following logic happens in the mender.mk file:
ifeq ($(BR2_PACKAGE_XZ),y)
MENDER_DEPENDENCIES += xz
MENDER_CONF_OPTS += -DMENDER_ARTIFACT_LZMA_COMPRESSION=ON
else
MENDER_CONF_OPTS += -DMENDER_ARTIFACT_LZMA_COMPRESSION=OFF
endif
However, this seems to break mender completely, as any run of mender-update provides the following output:
record_id=1 severity=info time="2024-Oct-04 15:22:29.911871" name="Global" msg="Installing the bootstrap Artifact"
record_id=2 severity=error time="2024-Oct-04 15:22:29.912730" name="Global" msg="Failed to initialize the Archive handle: xz compression is not supported on this platform"
record_id=3 severity=error time="2024-Oct-04 15:22:29.912822" name="Global" msg="Error reading the next tar entry: Error reading the tar stream: archive_read_next failed in LibArchive. Error code: -30 Error message: INTERNAL ERROR: Function 'archive_read_next_header' invoked with archive structure in state 'new', should be in state 'header/data'"
Could not fulfill request: Parse error: Failed to install the bootstrap Artifact: Got unexpected token : 'Unrecognized' expected 'version'
Even when the bootstrap.mender
and mender update files are not compressed using lzma.
"${HOST_DIR}"/bin/mender-artifact write bootstrap-artifact \
--compression zstd_best \
--artifact-name "${ARTIFACT_NAME}" \
--device-type "${DEVICE_TYPE}" \
--provides "rootfs-image.version:${ARTIFACT_NAME}" \
--provides "rootfs-image.checksum:${img_checksum}" \
--clears-provides "rootfs-image.*" \
--output-path "${BINARIES_DIR}"/"${bootstrap_artifact}" \
--version 3
echo "Creating ${BINARIES_DIR}/${DEVICE_TYPE}-${ARTIFACT_NAME}.mender"
"${HOST_DIR}/bin/mender-artifact" \
write rootfs-image \
--compression zstd_best \
-t "${DEVICE_TYPE}" \
-n "${BR2_VERSION}" \
-f "${BINARIES_DIR}/rootfs.ext2" \
-o "${BINARIES_DIR}/${DEVICE_TYPE}-${ARTIFACT_NAME}.mender"
NOTE: This above error also happens when --compression is set to lzma for both the bootstrap artifact and mender artifact!
Other items of note: libarchive is built with lzma support
To replicate:
NOTE: The following commands require docker and qemu-system-x86_64 installed on the host.
Clone the buildroot-mender repository with the compression-testing branch:
git clone https://github.com/mendersoftware/buildroot-mender.git -b compression-testing
Build a buildroot mender 4.x build suitable to run in a qemu environment:
cd buildroot-mender && EXIT_AFTER_BUILD=true make up
Run the qemu environment:
sh buildroot-external-mender/board/x86_64/qemu-run.sh
switch to serial0 view -> serial0
login as root (no password)
run mender-update show-provides
All the logic to create the bootstrap and update artifacts are in buildroot-external-mender/board/common/post-image-include
Edit: To view the mender package logic, run the following commands in the buildroot-mender directory:
make shell
nano package/mender/mender.mk
If you wish to build manually, after running make shell
:
cd ~/buildroot/buildroot-external-mender/output/x86_64_mender/
make -j$(nproc)
- Patches to buildroot are in the
buildroot-external-mender/patches/buildroot
directory. - The exact buildroot git hash is found in the
docker-compose.yaml
file
Thanks for the help!