@@ -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:
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. Signed-off-by: Uladzimir Bely <ubely@ilbers.de> --- meta/classes/buildstats.bbclass | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)