Skip to contentSkip to conversation

buildstats: support of custom disk usage command

PATCH In review Uladzimir Bely 2 participants 3 messages Jan 11, 2022 – Jan 12, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 buildstats: support of custom disk usage command

This helps to make buildstats code usage easier in third-party projects like Isar (https://github.com/ilbers/isar/). In Isar rootfs is created using 'sudo' and some subpaths like '/proc' may be mounted. So, "du -sh" on rootfs produces incorrect result with multiple 'Permission denied' warnings.

Customizable disk usage command allows to deal with these issues (e.g., "-x" option or "sudo" can be added) in such cases.

---
Changes in v2:
- Removed wrong [meta-oe] prefix from previously sent patch

 meta/classes/buildstats.bbclass | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/classes/buildstats.bbclass +4 -1
index 0de605200a..9f80cbd75c 100644
@@ -8,6 +8,8 @@ BUILDSTATS_BASE = "${TMPDIR}/buildstats/"
 #
 ################################################################################
 
+BUILDSTATS_DISK_USAGE_CMD ??= "du -sh"
+
 def get_buildprocess_cputime(pid):
     with open("/proc/%d/stat" % pid, "r") as f:
         fields = f.readline().rstrip().split()
@@ -244,7 +246,8 @@ python run_buildstats () {
                 rootfs = d.getVar('IMAGE_ROOTFS')
                 if os.path.isdir(rootfs):
                     try:
-                        rootfs_size = subprocess.check_output(["du", "-sh", rootfs],
+                        rootfs_size = subprocess.check_output(
+                                d.getVar('BUILDSTATS_DISK_USAGE_CMD').split() + [rootfs],
                                 stderr=subprocess.STDOUT).decode('utf-8')
                         f.write("Uncompressed Rootfs size: %s" % rootfs_size)
                     except subprocess.CalledProcessError as err:
Signature · 1 line
2.20.1
#1 lore raw

Thanks for this patch however it needs to be sent to openembedded-core mailing list

Quoted 60 lines · Uladzimir Bely

This helps to make buildstats code usage easier in third-party projects like Isar (https://github.com/ilbers/isar/). In Isar rootfs is created using 'sudo' and some subpaths like '/proc' may be mounted. So, "du -sh" on rootfs produces incorrect result with multiple 'Permission denied' warnings.

Customizable disk usage command allows to deal with these issues (e.g., "-x" option or "sudo" can be added) in such cases.

---
Changes in v2:
- Removed wrong [meta-oe] prefix from previously sent patch

 meta/classes/buildstats.bbclass | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/classes/buildstats.bbclass +2 -0
index 0de605200a..9f80cbd75c 100644
@@ -8,6 +8,8 @@ BUILDSTATS_BASE = "${TMPDIR}/buildstats/"
 #
 
 ################################################################################
 
+BUILDSTATS_DISK_USAGE_CMD ??= "du -sh"
+
 def get_buildprocess_cputime(pid):
     with open("/proc/%d/stat" % pid, "r") as f:
         fields = f.readline().rstrip().split()
meta/classes/buildstats.bbclass +2 -1
@@ -244,7 +246,8 @@ python run_buildstats () {
                 rootfs = d.getVar('IMAGE_ROOTFS')
                 if os.path.isdir(rootfs):
                     try:
-                        rootfs_size = subprocess.check_output(["du",
 "-sh", rootfs],
+                        rootfs_size = subprocess.check_output(
+
 d.getVar('BUILDSTATS_DISK_USAGE_CMD').split() + [rootfs],
                                 stderr=subprocess.STDOUT).decode('utf-8')

f.write("Uncompressed Rootfs size: %s" %
rootfs_size)
except subprocess.CalledProcessError as err:
--
2.20.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#94745):
https://lists.openembedded.org/g/openembedded-devel/message/94745
Mute This Topic: https://lists.openembedded.org/mt/88348508/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 2 lines · In the email from вторник, 11 января 2022 г. 19:27:32 +03 user Khem Raj wrote:

Thanks for this patch however it needs to be sent to openembedded-core mailing list

Thanks for the answer. I'll resend it there.