Fix fwupdtool firmware-convert to work with image-less formats

Converting 'simple' non-nested formats like Intel Hex into nested formats like
DfuSe needs us to create a binary child firmware to avoid missing data.

Fixes https://github.com/fwupd/fwupd/issues/5493
This commit is contained in:
Richard Hughes 2023-02-07 11:52:16 +00:00 committed by Mario Limonciello
parent 2da924d8bc
commit be33aaaf94

View File

@ -2617,6 +2617,20 @@ fu_util_firmware_convert(FuUtilPrivate *priv, gchar **values, GError **error)
fu_firmware_add_image(firmware_dst, img);
}
/* copy data as fallback, preferring a binary blob to the export */
if (images->len == 0) {
g_autoptr(GBytes) fw = NULL;
g_autoptr(FuFirmware) img = NULL;
fw = fu_firmware_get_bytes(firmware_src, NULL);
if (fw == NULL) {
fw = fu_firmware_write(firmware_src, error);
if (fw == NULL)
return FALSE;
}
img = fu_firmware_new_from_bytes(fw);
fu_firmware_add_image(firmware_dst, img);
}
/* write new file */
blob_dst = fu_firmware_write(firmware_dst, error);
if (blob_dst == NULL)