|
@@ -35,6 +35,7 @@ except ImportError:
|
|
colors = ['#e60004', '#009836', '#2e1d86', '#ffed00',
|
|
colors = ['#e60004', '#009836', '#2e1d86', '#ffed00',
|
|
'#0068b5', '#f28e00', '#940084', '#97c000']
|
|
'#0068b5', '#f28e00', '#940084', '#97c000']
|
|
|
|
|
|
|
|
+
|
|
#
|
|
#
|
|
# This function adds a new file to 'filesdict', after checking its
|
|
# This function adds a new file to 'filesdict', after checking its
|
|
# size. The 'filesdict' contain the relative path of the file as the
|
|
# size. The 'filesdict' contain the relative path of the file as the
|
|
@@ -54,6 +55,7 @@ def add_file(filesdict, relpath, abspath, pkg):
|
|
sz = os.stat(abspath).st_size
|
|
sz = os.stat(abspath).st_size
|
|
filesdict[relpath] = (pkg, sz)
|
|
filesdict[relpath] = (pkg, sz)
|
|
|
|
|
|
|
|
+
|
|
#
|
|
#
|
|
# This function returns a dict where each key is the path of a file in
|
|
# This function returns a dict where each key is the path of a file in
|
|
# the root filesystem, and the value is a tuple containing two
|
|
# the root filesystem, and the value is a tuple containing two
|
|
@@ -73,6 +75,7 @@ def build_package_dict(builddir):
|
|
add_file(filesdict, fpath, fullpath, pkg)
|
|
add_file(filesdict, fpath, fullpath, pkg)
|
|
return filesdict
|
|
return filesdict
|
|
|
|
|
|
|
|
+
|
|
#
|
|
#
|
|
# This function builds a dictionary that contains the name of a
|
|
# This function builds a dictionary that contains the name of a
|
|
# package as key, and the size of the files installed by this package
|
|
# package as key, and the size of the files installed by this package
|
|
@@ -103,7 +106,7 @@ def build_package_size(filesdict, builddir):
|
|
seeninodes.add(st.st_ino)
|
|
seeninodes.add(st.st_ino)
|
|
|
|
|
|
frelpath = os.path.relpath(fpath, os.path.join(builddir, "target"))
|
|
frelpath = os.path.relpath(fpath, os.path.join(builddir, "target"))
|
|
- if not frelpath in filesdict:
|
|
|
|
|
|
+ if frelpath not in filesdict:
|
|
print("WARNING: %s is not part of any package" % frelpath)
|
|
print("WARNING: %s is not part of any package" % frelpath)
|
|
pkg = "unknown"
|
|
pkg = "unknown"
|
|
else:
|
|
else:
|
|
@@ -113,6 +116,7 @@ def build_package_size(filesdict, builddir):
|
|
|
|
|
|
return pkgsize
|
|
return pkgsize
|
|
|
|
|
|
|
|
+
|
|
#
|
|
#
|
|
# Given a dict returned by build_package_size(), this function
|
|
# Given a dict returned by build_package_size(), this function
|
|
# generates a pie chart of the size installed by each package.
|
|
# generates a pie chart of the size installed by each package.
|
|
@@ -150,6 +154,7 @@ def draw_graph(pkgsize, outputf):
|
|
plt.title("Total filesystem size: %d kB" % (total / 1000.), fontsize=10, y=.96)
|
|
plt.title("Total filesystem size: %d kB" % (total / 1000.), fontsize=10, y=.96)
|
|
plt.savefig(outputf)
|
|
plt.savefig(outputf)
|
|
|
|
|
|
|
|
+
|
|
#
|
|
#
|
|
# Generate a CSV file with statistics about the size of each file, its
|
|
# Generate a CSV file with statistics about the size of each file, its
|
|
# size contribution to the package and to the overall system.
|
|
# size contribution to the package and to the overall system.
|
|
@@ -208,6 +213,7 @@ def gen_packages_csv(pkgsizes, outputf):
|
|
for (pkg, size) in pkgsizes.items():
|
|
for (pkg, size) in pkgsizes.items():
|
|
wr.writerow([pkg, size, "%.1f" % (float(size) / total * 100)])
|
|
wr.writerow([pkg, size, "%.1f" % (float(size) / total * 100)])
|
|
|
|
|
|
|
|
+
|
|
parser = argparse.ArgumentParser(description='Draw size statistics graphs')
|
|
parser = argparse.ArgumentParser(description='Draw size statistics graphs')
|
|
|
|
|
|
parser.add_argument("--builddir", '-i', metavar="BUILDDIR", required=True,
|
|
parser.add_argument("--builddir", '-i', metavar="BUILDDIR", required=True,
|