[game-data-packager] 11/11: Estimate Installed-Size with the algorithm planned for dpkg 1.18, rather than using du which is filesystem-dependent
Simon McVittie
smcv at debian.org
Sun Jan 25 19:29:36 UTC 2015
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit fbf914a8fabe4d1fd9c48510d05eaf9a8575bab6
Author: Simon McVittie <smcv at debian.org>
Date: Sun Jan 25 19:26:58 2015 +0000
Estimate Installed-Size with the algorithm planned for dpkg 1.18, rather than using du which is filesystem-dependent
---
debian/changelog | 2 ++
game_data_packager/__init__.py | 22 +++++++++++++++++++---
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index d321f8a..3191378 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -25,6 +25,8 @@ game-data-packager (40) UNRELEASED; urgency=medium
which we have never actually shipped. In versions < 39 it was silently
ignored, in versions >= 39 it prints an error message.
/etc/game-data-packager/idstuff-mirrors is sufficient.
+ * Estimate Installed-Size with the algorithm planned for dpkg 1.18,
+ rather than using du which is filesystem-dependent
-- Simon McVittie <smcv at debian.org> Thu, 22 Jan 2015 23:54:12 +0000
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index c5a0b16..4c9e2ed 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -1653,9 +1653,25 @@ class GameData(object):
assert control['Package'] in ('PACKAGE', package.name)
control['Package'] = package.name
- size = subprocess.check_output(['du', '-sk', '--exclude=./DEBIAN',
- '.'], cwd=destdir).decode('utf-8').split(None, 1)[0]
- control['Installed-Size'] = size
+ installed_size = 0
+ # algorithm from https://bugs.debian.org/650077 designed to be
+ # filesystem-independent
+ for dirpath, dirnames, filenames in os.walk(destdir):
+ if dirpath == destdir and 'DEBIAN' in dirnames:
+ dirnames.remove('DEBIAN')
+ # estimate 1 KiB per directory
+ installed_size += len(dirnames)
+ for f in filenames:
+ stat_res = os.lstat(os.path.join(dirpath, f))
+ if (stat.S_ISLNK(stat_res.st_mode) or
+ stat.S_ISREG(stat_res.st_mode)):
+ # take the real size and round up to next 1 KiB
+ installed_size += ((stat_res.st_size + 1023) // 1024)
+ else:
+ # this will probably never happen in gdp, but assume
+ # 1 KiB per non-regular, non-directory, non-symlink file
+ installed_size += 1
+ control['Installed-Size'] = str(installed_size)
default_values = {
'Section' : 'non-free/games',
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list