| Message ID | de38f3ac-4287-45e2-b258-3df00330c2d2n@googlegroups.com |
|---|---|
| State | Changes Requested |
| Delegated to: | Stefano Babic |
| Headers | show |
| Series | [meta-swupdate] Add check for cpio file size limits in swupdate_create_cpio | expand |
Hi Cameron, On 2/10/26 18:26, Cameron McQuinn wrote: > 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.mcquinn@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 Patch is ok, but I cannot apply because it results malformed, see : https://patchwork.ozlabs.org/project/swupdate/patch/de38f3ac-4287-45e2-b258-3df00330c2d2n@googlegroups.com/ Best regards, Stefano Babic
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')
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.mcquinn@gmail.com> --- classes-recipe/swupdate-common.bbclass | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) os.chdir(workdir) updateimage = d.getVar('IMAGE_NAME') + '.swu'