public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "'MOESSBAUER, Felix' via isar-users" <isar-users@googlegroups.com>
To: Adithya Balakumar <Adithya.Balakumar@toshiba-tsip.com>,
	"isar-users@googlegroups.com" <isar-users@googlegroups.com>,
	"Cetin, Gokhan" <gokhan.cetin@siemens.com>
Cc: "Kiszka, Jan" <jan.kiszka@siemens.com>,
	"kazuhiro3.hayashi@toshiba.co.jp"
	<kazuhiro3.hayashi@toshiba.co.jp>,
	"dinesh.kumar@toshiba-tsip.com" <dinesh.kumar@toshiba-tsip.com>,
	"shivanand.kunijadar@toshiba-tsip.com"
	<shivanand.kunijadar@toshiba-tsip.com>,
	"sai.sathujoda@toshiba-tsip.com" <sai.sathujoda@toshiba-tsip.com>
Subject: Re: [PATCH v1 1/1] image.bbclass: use oe.utils.directory_size() instead of du
Date: Thu, 10 Sep 2026 07:03:50 +0000	[thread overview]
Message-ID: <3143f6a15bee948c4759c8566b155e8ac82a5f50.camel@siemens.com> (raw)
In-Reply-To: <20241129062827.527177-2-Adithya.Balakumar@toshiba-tsip.com>

On Fri, 2024-11-29 at 11:58 +0530, Adithya Balakumar wrote:
> Currently the "du" command is used to calculate the rootfs size, and
> sometimes the reported size of the rootfs by "du" varies across multiple
> builds (usually by a few kb). But the rootfs contents are reproducible.
> 
> Although this does not affect any functionality, but it does affect
> reproducibility of artifacts that rely on the calculated rootfs size.
> 
> Some of the files/directories in the rootfs has different number of
> blocks allocated and "du" estimates the directory size based on the
> allocated blocks. The files/directories affected are not always the
> same across builds.
> 
> OE-Core uses a custom function to calculate directory size (See [1])
> and this patch introduces the use of that function from oe.utils to
> calculate the directory size.
> 
> [1] https://github.com/openembedded/openembedded-core/commit/d8f1f3a6b024a2ae6631d1ce25421e8d94b69a12
> 
> Signed-off-by: Adithya Balakumar <Adithya.Balakumar@toshiba-tsip.com>
> ---
>  meta/classes/image.bbclass | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 982523b0..3e70fe83 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -85,13 +85,10 @@ inherit image-account-extension
>  ROOTFS_EXTRA ?= "64"
>  
>  def get_rootfs_size(d):
> -    import subprocess
> +    import subprocess, oe.utils

Hi, the subprocess import is not needed anymore.

>      rootfs_extra = int(d.getVar("ROOTFS_EXTRA"))
>  
> -    output = subprocess.check_output(
> -        ["sudo", "du", "-xs", "--block-size=1k", d.getVar("IMAGE_ROOTFS")]
> -    )
> -    base_size = int(output.split()[0])
> +    base_size = int(oe.utils.directory_size(d.getVar("IMAGE_ROOTFS")) / 1024)

This unfortunately breaks if the calling user is not able to read all
files in this rootfs. Actually a single file with perms 600 and owner
root breaks this and by that the imaging.

I don't have a better solution yet, though.
I'm also wondering why this only came up now. It seems like it only
breaks under rootless.

Felix

>  
>      return base_size + rootfs_extra * 1024
>  
> -- 
> 2.39.5
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups "isar-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/isar-users/20241129062827.527177-2-Adithya.Balakumar%40toshiba-tsip.com.

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/3143f6a15bee948c4759c8566b155e8ac82a5f50.camel%40siemens.com.

  reply	other threads:[~2026-09-10  7:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-29  6:28 [PATCH v1 0/1] Use oe.utils.directory_size() instead of du for calculating rootfs size Adithya Balakumar
2024-11-29  6:28 ` [PATCH v1 1/1] image.bbclass: use oe.utils.directory_size() instead of du Adithya Balakumar
2026-09-10  7:03   ` 'MOESSBAUER, Felix' via isar-users [this message]
2024-12-06  7:29 ` [PATCH v1 0/1] Use oe.utils.directory_size() instead of du for calculating rootfs size Uladzimir Bely

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=3143f6a15bee948c4759c8566b155e8ac82a5f50.camel@siemens.com \
    --to=isar-users@googlegroups.com \
    --cc=Adithya.Balakumar@toshiba-tsip.com \
    --cc=dinesh.kumar@toshiba-tsip.com \
    --cc=felix.moessbauer@siemens.com \
    --cc=gokhan.cetin@siemens.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kazuhiro3.hayashi@toshiba.co.jp \
    --cc=sai.sathujoda@toshiba-tsip.com \
    --cc=shivanand.kunijadar@toshiba-tsip.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox