aboutsummaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorGravatar Andrey Yurovsky <yurovsky@gmail.com>2017-11-27 19:37:07 -0800
committerGravatar Thomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-11-29 21:36:34 +0100
commit88af7d330dec7b6386a9994d8e53900033d85903 (patch)
treef812cfe2341bde79062e090084736304b72c16e0 /support
parent86ad37b948b5dd1845ef7e0a3620a0e9c5820559 (diff)
downloadbuildroot-88af7d330dec7b6386a9994d8e53900033d85903.tar.gz
buildroot-88af7d330dec7b6386a9994d8e53900033d85903.tar.bz2
support/scripts/size-stats: avoid divide-by-zero
Some packages (ex: skeleton-init-systemd) have a zero size so we cannot divide by the package size. In that case make their percent zero explicitly and avoid a ZeroDivisionError exception. Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com> Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'support')
-rwxr-xr-xsupport/scripts/size-stats12
1 files changed, 10 insertions, 2 deletions
diff --git a/support/scripts/size-stats b/support/scripts/size-stats
index af45000359..3ff2a1ce18 100755
--- a/support/scripts/size-stats
+++ b/support/scripts/size-stats
@@ -178,9 +178,17 @@ def gen_files_csv(filesdict, pkgsizes, outputf):
"File size in system (%)"])
for f, (pkgname, filesize) in filesdict.items():
pkgsize = pkgsizes[pkgname]
+
+ if pkgsize == 0:
+ percent_pkg = 0
+ else:
+ percent_pkg = float(filesize) / pkgsize * 100
+
+ percent_total = float(filesize) / total * 100
+
wr.writerow([f, pkgname, filesize, pkgsize,
- "%.1f" % (float(filesize) / pkgsize * 100),
- "%.1f" % (float(filesize) / total * 100)])
+ "%.1f" % percent_pkg,
+ "%.1f" % percent_total])
#