]> code.ossystems Code Review - openembedded-core.git/commitdiff
classes/image: use oe.utils.directory_size() instead of du
authorRoss Burton <ross.burton@intel.com>
Tue, 23 Mar 2021 16:37:22 +0000 (16:37 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 28 Mar 2021 21:26:19 +0000 (22:26 +0100)
Instead of using du (which has issues as disussed in the previous commit), use
the new oe.utils.directory_size() function.

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/image.bbclass

index b558653635590964c07f5fd52fdc77ad51030f47..87a58dfae75622846f2b2d98cf98bcd6c558c7c3 100644 (file)
@@ -507,7 +507,7 @@ python () {
 # Compute the rootfs size
 #
 def get_rootfs_size(d):
-    import subprocess
+    import subprocess, oe.utils
 
     rootfs_alignment = int(d.getVar('IMAGE_ROOTFS_ALIGNMENT'))
     overhead_factor = float(d.getVar('IMAGE_OVERHEAD_FACTOR'))
@@ -518,9 +518,7 @@ def get_rootfs_size(d):
     initramfs_fstypes = d.getVar('INITRAMFS_FSTYPES') or ''
     initramfs_maxsize = d.getVar('INITRAMFS_MAXSIZE')
 
-    output = subprocess.check_output(['du', '-ks',
-                                      d.getVar('IMAGE_ROOTFS')])
-    size_kb = int(output.split()[0])
+    size_kb = oe.utils.directory_size(d.getVar("IMAGE_ROOTFS")) / 1024
 
     base_size = size_kb * overhead_factor
     bb.debug(1, '%f = %d * %f' % (base_size, size_kb, overhead_factor))