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 1bbbb2a83bf8c1e7e234b60be39063fd19b855c7 Author: Simon McVittie <[email protected]> Date: Tue Nov 1 12:51:26 2016 +0000 Move md5sums from GameDataPackage to PackagingTask This removes another instance of storing mutable state in the GameDataPackage. My goal is that the GameDataPackage will never be modified after it has been loaded. --- game_data_packager/__init__.py | 4 ---- game_data_packager/build.py | 11 +++++++++-- game_data_packager/packaging/__init__.py | 5 ++++- game_data_packager/packaging/arch.py | 2 +- game_data_packager/packaging/deb.py | 22 ++++++++++++---------- game_data_packager/packaging/rpm.py | 2 +- 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py index 5b31b0d..347ca6d 100644 --- a/game_data_packager/__init__.py +++ b/game_data_packager/__init__.py @@ -172,10 +172,6 @@ class GameDataPackage(object): # archives actually used to built a package self.used_sources = set() - # Remember the md5 of installed files - # that will end up in DEBIAN/md5sums - self.md5sums = dict() - @property def aliases(self): return self._aliases diff --git a/game_data_packager/build.py b/game_data_packager/build.py index 2f07b8c..efa1b6a 100644 --- a/game_data_packager/build.py +++ b/game_data_packager/build.py @@ -225,6 +225,12 @@ class PackagingTask(object): # Block device from which to rip audio self.cd_device = None + # Remember the md5 of installed files that will end up in + # DEBIAN/md5sums + # e.g. { 'quake3-data': { + # 'usr/share/games/quake3-data/baseq3/pak0.pk3': '1197ca...' } + self.package_md5sums = {} + # Found CD tracks # e.g. { 'quake-music': { 2: '/usr/.../id1/music/track02.ogg' } } self.cd_tracks = {} @@ -1328,7 +1334,7 @@ class PackagingTask(object): os.chmod(copy_to, 0o644) fullname = os.path.join(install_to, install_as).strip('/') - package.md5sums[fullname] = md5 + self.package_md5sums.setdefault(package.name, {})[fullname] = md5 install_to = self.packaging.substitute(package.install_to, package.name) @@ -2009,7 +2015,8 @@ class PackagingTask(object): self.__check_component(package) pkg = self.packaging.build_package(per_package_dir, self.game, - package, destination, compress=compress) + package, destination, compress=compress, + md5sums=self.package_md5sums.get(package.name)) assert pkg is not None packages.add(pkg) diff --git a/game_data_packager/packaging/__init__.py b/game_data_packager/packaging/__init__.py index 207561c..4fd8325 100644 --- a/game_data_packager/packaging/__init__.py +++ b/game_data_packager/packaging/__init__.py @@ -304,7 +304,7 @@ class PackagingSystem(metaclass=ABCMeta): @abstractmethod def build_package(self, per_package_dir, game, package, - destination, compress=True): + destination, compress=True, md5sums=None): """Build the .deb or equivalent in destination, and return its filename. @@ -313,6 +313,9 @@ class PackagingSystem(metaclass=ABCMeta): to be packaged (so it contains DESTDIR/usr, etc.) game and package are a GameData and a GameDataPackage respectively. + + md5sums is either None, or a map like + { 'usr/share/games/quake3-data/baseq3/pak0.pk3': '1197ca...' } """ raise NotImplementedError diff --git a/game_data_packager/packaging/arch.py b/game_data_packager/packaging/arch.py index 8c5576c..c8d92a1 100644 --- a/game_data_packager/packaging/arch.py +++ b/game_data_packager/packaging/arch.py @@ -155,7 +155,7 @@ class ArchPackaging(PackagingSystem): + sorted(files), env={'LANG':'C'}, cwd=destdir) def build_package(self, per_package_dir, game, package, destination, - compress=True): + compress=True, md5sums=None): destdir = os.path.join(per_package_dir, 'DESTDIR') arch = self.get_effective_architecture(package) diff --git a/game_data_packager/packaging/deb.py b/game_data_packager/packaging/deb.py index 036449e..b2e5673 100644 --- a/game_data_packager/packaging/deb.py +++ b/game_data_packager/packaging/deb.py @@ -347,12 +347,14 @@ class DebPackaging(PackagingSystem): return control - def __fill_dest_dir_deb(self, game, package, destdir): + def __fill_dest_dir_deb(self, game, package, destdir, md5sums=None): if package.component == 'local': self.override_lintian(destdir, package.name, 'unknown-section', 'local/%s' % package.section) # same output as in dh_md5sums + if md5sums is None: + md5sums = {} # we only compute here the md5 we don't have yet, # for the (small) GDP-generated files @@ -364,18 +366,18 @@ class DebPackaging(PackagingSystem): if os.path.islink(full): continue file = full[len(destdir)+1:] - if file not in package.md5sums: + if file not in md5sums: with open(full, 'rb') as opened: hf = HashedFile.from_file(full, opened) - package.md5sums[file] = hf.md5 + md5sums[file] = hf.md5 debdir = os.path.join(destdir, 'DEBIAN') mkdir_p(debdir) - md5sums = os.path.join(destdir, 'DEBIAN/md5sums') - with open(md5sums, 'w', encoding='utf8') as outfile: - for file in sorted(package.md5sums.keys()): - outfile.write('%s %s\n' % (package.md5sums[file], file)) - os.chmod(md5sums, 0o644) + md5sums_path = os.path.join(destdir, 'DEBIAN/md5sums') + with open(md5sums_path, 'w', encoding='utf8') as outfile: + for file in sorted(md5sums.keys()): + outfile.write('%s %s\n' % (md5sums[file], file)) + os.chmod(md5sums_path, 0o644) control = os.path.join(destdir, 'DEBIAN/control') self.__generate_control(game, package, destdir).dump( @@ -383,10 +385,10 @@ class DebPackaging(PackagingSystem): os.chmod(control, 0o644) def build_package(self, per_package_dir, game, package, destination, - compress=True): + compress=True, md5sums=None): destdir = os.path.join(per_package_dir, 'DESTDIR') arch = self.get_effective_architecture(package) - self.__fill_dest_dir_deb(game, package, destdir) + self.__fill_dest_dir_deb(game, package, destdir, md5sums) normalize_permissions(destdir) # it had better have a /usr and a DEBIAN directory or diff --git a/game_data_packager/packaging/rpm.py b/game_data_packager/packaging/rpm.py index 4012a42..f7d84a4 100644 --- a/game_data_packager/packaging/rpm.py +++ b/game_data_packager/packaging/rpm.py @@ -231,7 +231,7 @@ class RpmPackaging(PackagingSystem): return specfile def build_package(self, per_package_dir, game, package, destination, - compress=True): + compress=True, md5sums=None): destdir = os.path.join(per_package_dir, 'DESTDIR') arch = self.get_effective_architecture(package) -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

