diff mbox series

[kirkstone] 3/3] image_types_sparse: backport optionally remove RAW image

Message ID 20250925172931.64046-3-emailaddress.ashish@gmail.com
State New
Headers show
Series [kirkstone] 3/3] image_types_sparse: backport optionally remove RAW image | expand

Commit Message

Ashish Mishra Sept. 25, 2025, 5:29 p.m. UTC
From: AshishKumar Mishra <emailaddress.ashish@gmail.com>

When creating sparse images, the RAW image is no longer needed in
some workflows such as Android and CI pipelines. These RAW images
can be multi-GB artifacts and consume significant disk space.

This change introduces a configuration option
`DELETE_RAWIMAGE_AFTER_SPARSE_CMD` which, when set to "1",
removes the RAW image after sparse image generation.

This reduces disk usage in builds where sparse images are the
final deliverables and RAW images are not required.

Default behavior is unchanged: RAW images are kept unless the
variable is explicitly enabled:

This change corresponds to upstream  f5246b7df447ac76ec04c6e5add398862d1c9ccd

    DELETE_RAWIMAGE_AFTER_SPARSE_CMD = "1"   # Delete RAW image
    DELETE_RAWIMAGE_AFTER_SPARSE_CMD = "0"   # Default behavior

Signed-off-by: AshishKumar Mishra <emailaddress.ashish@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: AshishKumar Mishra <emailaddress.ashish@gmail.com>
---
 meta-oe/classes/image_types_sparse.bbclass | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Ashish Mishra Sept. 29, 2025, 4:47 a.m. UTC | #1
@ Gyorgy Sarvari  :

Good Morning .
Please do consider this patch for merge in Kirkstone
If any suggestion / feedback on this , feel free to share .
Will work on it accordingly
Have shared the 3 patch changes for same

Thanks ,
Ashish
Gyorgy Sarvari Sept. 29, 2025, 6:12 a.m. UTC | #2
Your patches are not forgotten, but stable branches are not
rolling-branches.

As a non-official reference, you can check this repository:
https://git.openembedded.org/meta-openembedded-contrib/log/?h=stable/kirkstone-nut
This is where I stage the patches for testing for the next kirkstone
pull request - though it is a fluid branch and changes relatively often,
it is the best indicator I can offer you at this moment about what can
be expected. Most probably this will be merged into the final branch.

This repo/branch is not canonical. I use it now, but might change in the
future.

On 9/29/25 06:47, Ashish Mishra via lists.openembedded.org wrote:
> @ Gyorgy Sarvari  :
>
> Good Morning .
> Please do consider this patch for merge in Kirkstone 
> If any suggestion / feedback on this , feel free to share .
> Will work on it accordingly
> Have shared the 3 patch changes for same 
>  
> Thanks ,
> Ashish 
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#120007): https://lists.openembedded.org/g/openembedded-devel/message/120007
> Mute This Topic: https://lists.openembedded.org/mt/115434756/6084445
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta-oe/classes/image_types_sparse.bbclass b/meta-oe/classes/image_types_sparse.bbclass
index 8668739fd9..81dba96305 100644
--- a/meta-oe/classes/image_types_sparse.bbclass
+++ b/meta-oe/classes/image_types_sparse.bbclass
@@ -8,9 +8,17 @@  inherit image_types
 SPARSE_BLOCK_SIZE ??= "4096"
 
 CONVERSIONTYPES += "sparse"
+
+DELETE_RAWIMAGE_AFTER_SPARSE_CMD ??= "0"
+
 CONVERSION_CMD:sparse = " \
-    INPUT="${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}" && \
-    truncate --no-create --size=%${SPARSE_BLOCK_SIZE} "$INPUT" && \
-    img2simg -s "$INPUT" "$INPUT.sparse" ${SPARSE_BLOCK_SIZE} \
+    INPUT=${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} && \
+    truncate --no-create --size=%${SPARSE_BLOCK_SIZE} $INPUT && \
+    img2simg $INPUT $INPUT.sparse && \
+    if [ ${DELETE_RAWIMAGE_AFTER_SPARSE_CMD} = 1 ]; then \
+        rm -f $INPUT; \
+        bbwarn 'Raw file $INPUT removed'; \
+    fi \
 "
+
 CONVERSION_DEPENDS_sparse = "android-tools-native"