Update buildroot 2020.02.01 (#622)
* Update buildroot 2020.02.01 Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch> * Fix LN * Fix wpa Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch> * Fix lint Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch> * fix-network Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch> * Fix script Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
@@ -22,6 +22,7 @@ import os.path
|
||||
import argparse
|
||||
import csv
|
||||
import collections
|
||||
import math
|
||||
|
||||
try:
|
||||
import matplotlib
|
||||
@@ -32,8 +33,13 @@ except ImportError:
|
||||
sys.stderr.write("You need python-matplotlib to generate the size graph\n")
|
||||
exit(1)
|
||||
|
||||
colors = ['#e60004', '#009836', '#2e1d86', '#ffed00',
|
||||
'#0068b5', '#f28e00', '#940084', '#97c000']
|
||||
|
||||
class Config:
|
||||
biggest_first = False
|
||||
iec = False
|
||||
size_limit = 0.01
|
||||
colors = ['#e60004', '#f28e00', '#ffed00', '#940084',
|
||||
'#2e1d86', '#0068b5', '#009836', '#97c000']
|
||||
|
||||
|
||||
#
|
||||
@@ -66,8 +72,8 @@ def add_file(filesdict, relpath, abspath, pkg):
|
||||
#
|
||||
def build_package_dict(builddir):
|
||||
filesdict = {}
|
||||
with open(os.path.join(builddir, "build", "packages-file-list.txt")) as filelistf:
|
||||
for l in filelistf.readlines():
|
||||
with open(os.path.join(builddir, "build", "packages-file-list.txt")) as f:
|
||||
for l in f.readlines():
|
||||
pkg, fpath = l.split(",", 1)
|
||||
# remove the initial './' in each file path
|
||||
fpath = fpath.strip()[2:]
|
||||
@@ -127,23 +133,46 @@ def build_package_size(filesdict, builddir):
|
||||
# outputf: output file for the graph
|
||||
#
|
||||
def draw_graph(pkgsize, outputf):
|
||||
def size2string(sz):
|
||||
if Config.iec:
|
||||
divider = 1024.0
|
||||
prefixes = ['', 'Ki', 'Mi', 'Gi', 'Ti']
|
||||
else:
|
||||
divider = 1000.0
|
||||
prefixes = ['', 'k', 'M', 'G', 'T']
|
||||
while sz > divider and len(prefixes) > 1:
|
||||
prefixes = prefixes[1:]
|
||||
sz = sz/divider
|
||||
# precision is made so that there are always at least three meaningful
|
||||
# digits displayed (e.g. '3.14' and '10.4', not just '3' and '10')
|
||||
precision = int(2-math.floor(math.log10(sz))) if sz < 1000 else 0
|
||||
return '{:.{prec}f} {}B'.format(sz, prefixes[0], prec=precision)
|
||||
|
||||
total = sum(pkgsize.values())
|
||||
labels = []
|
||||
values = []
|
||||
other_value = 0
|
||||
for (p, sz) in sorted(pkgsize.items(), key=lambda x: x[1]):
|
||||
if sz < (total * 0.01):
|
||||
unknown_value = 0
|
||||
for (p, sz) in sorted(pkgsize.items(), key=lambda x: x[1],
|
||||
reverse=Config.biggest_first):
|
||||
if sz < (total * Config.size_limit):
|
||||
other_value += sz
|
||||
elif p == "unknown":
|
||||
unknown_value = sz
|
||||
else:
|
||||
labels.append("%s (%d kB)" % (p, sz / 1000.))
|
||||
labels.append("%s (%s)" % (p, size2string(sz)))
|
||||
values.append(sz)
|
||||
labels.append("Other (%d kB)" % (other_value / 1000.))
|
||||
values.append(other_value)
|
||||
if unknown_value != 0:
|
||||
labels.append("Unknown (%s)" % (size2string(unknown_value)))
|
||||
values.append(unknown_value)
|
||||
if other_value != 0:
|
||||
labels.append("Other (%s)" % (size2string(other_value)))
|
||||
values.append(other_value)
|
||||
|
||||
plt.figure()
|
||||
patches, texts, autotexts = plt.pie(values, labels=labels,
|
||||
autopct='%1.1f%%', shadow=True,
|
||||
colors=colors)
|
||||
colors=Config.colors)
|
||||
# Reduce text size
|
||||
proptease = fm.FontProperties()
|
||||
proptease.set_size('xx-small')
|
||||
@@ -151,7 +180,8 @@ def draw_graph(pkgsize, outputf):
|
||||
plt.setp(texts, fontproperties=proptease)
|
||||
|
||||
plt.suptitle("Filesystem size per package", fontsize=18, y=.97)
|
||||
plt.title("Total filesystem size: %d kB" % (total / 1000.), fontsize=10, y=.96)
|
||||
plt.title("Total filesystem size: %s" % (size2string(total)), fontsize=10,
|
||||
y=.96)
|
||||
plt.savefig(outputf)
|
||||
|
||||
|
||||
@@ -209,32 +239,70 @@ def gen_packages_csv(pkgsizes, outputf):
|
||||
total = sum(pkgsizes.values())
|
||||
with open(outputf, 'w') as csvfile:
|
||||
wr = csv.writer(csvfile, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
wr.writerow(["Package name", "Package size", "Package size in system (%)"])
|
||||
wr.writerow(["Package name", "Package size",
|
||||
"Package size in system (%)"])
|
||||
for (pkg, size) in pkgsizes.items():
|
||||
wr.writerow([pkg, size, "%.1f" % (float(size) / total * 100)])
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='Draw size statistics graphs')
|
||||
#
|
||||
# Our special action for --iec, --binary, --si, --decimal
|
||||
#
|
||||
class PrefixAction(argparse.Action):
|
||||
def __init__(self, option_strings, dest, **kwargs):
|
||||
for key in ["type", "nargs"]:
|
||||
if key in kwargs:
|
||||
raise ValueError('"{}" not allowed'.format(key))
|
||||
super(PrefixAction, self).__init__(option_strings, dest, nargs=0,
|
||||
type=bool, **kwargs)
|
||||
|
||||
parser.add_argument("--builddir", '-i', metavar="BUILDDIR", required=True,
|
||||
help="Buildroot output directory")
|
||||
parser.add_argument("--graph", '-g', metavar="GRAPH",
|
||||
help="Graph output file (.pdf or .png extension)")
|
||||
parser.add_argument("--file-size-csv", '-f', metavar="FILE_SIZE_CSV",
|
||||
help="CSV output file with file size statistics")
|
||||
parser.add_argument("--package-size-csv", '-p', metavar="PKG_SIZE_CSV",
|
||||
help="CSV output file with package size statistics")
|
||||
args = parser.parse_args()
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
setattr(namespace, self.dest, option_string in ["--iec", "--binary"])
|
||||
|
||||
# Find out which package installed what files
|
||||
pkgdict = build_package_dict(args.builddir)
|
||||
|
||||
# Collect the size installed by each package
|
||||
pkgsize = build_package_size(pkgdict, args.builddir)
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Draw size statistics graphs')
|
||||
|
||||
if args.graph:
|
||||
draw_graph(pkgsize, args.graph)
|
||||
if args.file_size_csv:
|
||||
gen_files_csv(pkgdict, pkgsize, args.file_size_csv)
|
||||
if args.package_size_csv:
|
||||
gen_packages_csv(pkgsize, args.package_size_csv)
|
||||
parser.add_argument("--builddir", '-i', metavar="BUILDDIR", required=True,
|
||||
help="Buildroot output directory")
|
||||
parser.add_argument("--graph", '-g', metavar="GRAPH",
|
||||
help="Graph output file (.pdf or .png extension)")
|
||||
parser.add_argument("--file-size-csv", '-f', metavar="FILE_SIZE_CSV",
|
||||
help="CSV output file with file size statistics")
|
||||
parser.add_argument("--package-size-csv", '-p', metavar="PKG_SIZE_CSV",
|
||||
help="CSV output file with package size statistics")
|
||||
parser.add_argument("--biggest-first", action='store_true',
|
||||
help="Sort packages in decreasing size order, " +
|
||||
"rather than in increasing size order")
|
||||
parser.add_argument("--iec", "--binary", "--si", "--decimal",
|
||||
action=PrefixAction,
|
||||
help="Use IEC (binary, powers of 1024) or SI (decimal, "
|
||||
"powers of 1000, the default) prefixes")
|
||||
parser.add_argument("--size-limit", "-l", type=float,
|
||||
help='Under this size ratio, files are accounted to ' +
|
||||
'the generic "Other" package. Default: 0.01 (1%%)')
|
||||
args = parser.parse_args()
|
||||
|
||||
Config.biggest_first = args.biggest_first
|
||||
Config.iec = args.iec
|
||||
if args.size_limit is not None:
|
||||
if args.size_limit < 0.0 or args.size_limit > 1.0:
|
||||
parser.error("--size-limit must be in [0.0..1.0]")
|
||||
Config.size_limit = args.size_limit
|
||||
|
||||
# Find out which package installed what files
|
||||
pkgdict = build_package_dict(args.builddir)
|
||||
|
||||
# Collect the size installed by each package
|
||||
pkgsize = build_package_size(pkgdict, args.builddir)
|
||||
|
||||
if args.graph:
|
||||
draw_graph(pkgsize, args.graph)
|
||||
if args.file_size_csv:
|
||||
gen_files_csv(pkgdict, pkgsize, args.file_size_csv)
|
||||
if args.package_size_csv:
|
||||
gen_packages_csv(pkgsize, args.package_size_csv)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user