All of lore.kernel.org
 help / color / mirror / Atom feed
From: AshishKumar Mishra <emailaddress.ashish@gmail.com>
To: openembedded-devel@lists.openembedded.org
Cc: skandigraun@gmail.com,
	AshishKumar Mishra <emailaddress.ashish@gmail.com>,
	Khem Raj <raj.khem@gmail.com>
Subject: [kirkstone][PATCH] 3/3] image_types_sparse: backport optionally remove RAW image
Date: Thu, 25 Sep 2025 22:59:31 +0530	[thread overview]
Message-ID: <20250925172931.64046-3-emailaddress.ashish@gmail.com> (raw)
In-Reply-To: <20250925172931.64046-1-emailaddress.ashish@gmail.com>

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(-)

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"
-- 
2.43.0



  parent reply	other threads:[~2025-09-25 17:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25 17:29 [kirkstone][PATCH] 1/3] image_types_sparse: backport fix pad source image to block size AshishKumar Mishra
2025-09-25 17:29 ` [kirkstone][PATCH] 2/3] image_types_sparse: backport generate "don't care" chunks AshishKumar Mishra
2025-09-25 17:29 ` AshishKumar Mishra [this message]
2025-09-29  4:47   ` [kirkstone][PATCH] 3/3] image_types_sparse: backport optionally remove RAW image Ashish Mishra
2025-09-29  6:12     ` [oe] " Gyorgy Sarvari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250925172931.64046-3-emailaddress.ashish@gmail.com \
    --to=emailaddress.ashish@gmail.com \
    --cc=openembedded-devel@lists.openembedded.org \
    --cc=raj.khem@gmail.com \
    --cc=skandigraun@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.