summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorFrank Hunleth <fhunleth@troodon-software.com>2016-10-24 10:36:39 -0400
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-02-06 19:38:53 +0100
commit2ec0a7d11ca6c5a6fa1fe142e291a8f308f9c91f (patch)
tree718755deef98b7689c24520ecd7d7623356e29fb /support
parentee5bbc8cf087943cb1e8575327d44727139c4e65 (diff)
size-stats: don't count hard links
This change adds inode tracking to the size-stats script so that hard links don't cause files to be double counted. This has a significant effect on the size computation for some packages. For example, git has around a dozen hard links to a large file. Before this change, git would weigh in at about 170 MB with the total filesystem size reported as 175 MB. The actual rootfs.ext2 size was around 16 MB. With the change, the git package registers at 10.5 MB with a total filesystem size of 15.8 MB. Signed-off-by: Frank Hunleth <fhunleth@troodon-software.com> Acked-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'support')
-rwxr-xr-xsupport/scripts/size-stats11
1 files changed, 10 insertions, 1 deletions
diff --git a/support/scripts/size-stats b/support/scripts/size-stats
index 0ddcc0790..af4500035 100755
--- a/support/scripts/size-stats
+++ b/support/scripts/size-stats
@@ -88,11 +88,20 @@ def build_package_dict(builddir):
def build_package_size(filesdict, builddir):
pkgsize = collections.defaultdict(int)
+ seeninodes = set()
for root, _, files in os.walk(os.path.join(builddir, "target")):
for f in files:
fpath = os.path.join(root, f)
if os.path.islink(fpath):
continue
+
+ st = os.stat(fpath)
+ if st.st_ino in seeninodes:
+ # hard link
+ continue
+ else:
+ seeninodes.add(st.st_ino)
+
frelpath = os.path.relpath(fpath, os.path.join(builddir, "target"))
if not frelpath in filesdict:
print("WARNING: %s is not part of any package" % frelpath)
@@ -100,7 +109,7 @@ def build_package_size(filesdict, builddir):
else:
pkg = filesdict[frelpath][0]
- pkgsize[pkg] += os.path.getsize(fpath)
+ pkgsize[pkg] += st.st_size
return pkgsize