Currently, `do_swuimage` will fail silently if a file exceeds the 4GB limit imposed by CPIO. This patch adds a check to fail the task if any file exceeds this maximum size.
Signed-off-by: Cameron McQuinn <
cameron...@gmail.com>
---
classes-recipe/swupdate-common.bbclass | 38 ++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/classes-recipe/swupdate-common.bbclass b/classes-recipe/swupdate-common.bbclass
index 80a5d5b..2925a7c 100644
--- a/classes-recipe/swupdate-common.bbclass
+++ b/classes-recipe/swupdate-common.bbclass
@@ -316,7 +316,45 @@ def swupdate_add_artifacts(d, list_for_cpio):
bb.fatal("swupdate cannot find %s image file" % image)
+def swupdate_check_cpio_file_sizes(d, list_for_cpio):
+ """
+ Fail the task if any file exceeds the cpio CRC 4GB limit.
+ """
+ s = d.getVar('S')
+ max_size = (4 * 1024 * 1024 * 1024) - 1 # 4GB - 1 byte
+
+ oversized = []
+
+ for relpath in list_for_cpio:
+ path = os.path.join(s, relpath)
+
+ if not os.path.exists(path):
+ bb.fatal(f"SWUpdate: file listed for SWU does not exist: {relpath}")
+
+ size = os.stat(path).st_size
+ if size > max_size:
+ oversized.append((relpath, size))
+
+ if oversized:
+ msg = [
+ "SWUpdate image creation failed:",
+ "The following files exceed the 4GB cpio CRC format limit:"
+ ]
+
+ for name, size in oversized:
+ msg.append(f" - {name}: {size} bytes")
+
+ msg.append(
+ "cpio (SVR4 CRC format) cannot pack files >= 4GB.\n"
+ "Consider splitting the artifact, compressing it, or delivering it via an external handler."
+ )
+
+ bb.fatal("\n".join(msg))
+
def swupdate_create_cpio(d, swudeploydir, list_for_cpio):
+ # Check sizes
+ swupdate_check_cpio_file_sizes(d, list_for_cpio)
+
workdir = d.getVar('WORKDIR')
os.chdir(workdir)
updateimage = d.getVar('IMAGE_NAME') + '.swu'
--
2.43.0