[game-data-packager] 09/25: build: get facts about packaging from PackagingSystem

Simon McVittie smcv at debian.org
Sun Oct 9 21:26:05 UTC 2016


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 6d0035fe672ae6ec4bc719d6f7952f98a54e8e02
Author: Simon McVittie <smcv at debian.org>
Date:   Sun Oct 9 14:05:54 2016 +0100

    build: get facts about packaging from PackagingSystem
    
    This will be necessary when we support "cross-compiling" packages.
---
 game_data_packager/build.py              | 20 ++++++++------------
 game_data_packager/packaging/__init__.py |  3 +++
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index 3d80f6a..8d83aa0 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -53,10 +53,6 @@ from .util import (AGENT,
         rm_rf,
         recursive_utime,
         which)
-from .version import (FORMAT, DISTRO)
-
-if FORMAT == 'deb':
-    from debian.deb822 import Deb822
 
 logging.basicConfig()
 logger = logging.getLogger(__name__)
@@ -1373,7 +1369,7 @@ class PackagingTask(object):
             spec.write('Url: %s\n' % url)
             spec.write('Release: %s\n' % release)
             spec.write('License: Commercial\n')
-            if DISTRO == 'mageia':
+            if self.packaging.derives_from('mageia'):
                 spec.write('Packager: game-data-packager\n')
                 spec.write('Group: Games/%s\n' % self.game.genre)
             else:
@@ -1603,6 +1599,9 @@ class PackagingTask(object):
                     os.chmod(full, 0o644)
 
     def generate_control(self, package, destdir):
+        # import lazily, it's only needed for Debian packages
+        from debian.deb822 import Deb822
+
         try:
             control_in = open(os.path.join(DATADIR,
                               package.name + '.control.in'), encoding='utf-8')
@@ -2410,11 +2409,11 @@ class PackagingTask(object):
                 arch = self.packaging.get_architecture(arch)
             arch = self.packaging.ARCH_DECODE.get(arch, arch)
 
-            if FORMAT == 'deb':
+            if self.packaging.derives_from('deb'):
                 pkg = self.build_deb(package, arch, destination, compress=compress)
-            elif FORMAT == 'rpm':
+            elif self.packaging.derives_from('rpm'):
                 pkg = self.build_rpm(package, arch, compress=compress)
-            elif FORMAT == 'arch':
+            elif self.packaging.derives_from('arch'):
                 pkg = self.build_arch(package, arch, destination, compress=compress)
 
             if pkg is None:
@@ -2687,10 +2686,7 @@ class PackagingTask(object):
             return True
 
         if fmt == 'deb':
-            if FORMAT == 'deb':
-                return True
-            else:
-                fmt = 'dpkg-deb'
+            fmt = 'dpkg-deb'
 
         if which(fmt) is not None:
             return True
diff --git a/game_data_packager/packaging/__init__.py b/game_data_packager/packaging/__init__.py
index edcb5ad..61eb7e0 100644
--- a/game_data_packager/packaging/__init__.py
+++ b/game_data_packager/packaging/__init__.py
@@ -59,6 +59,9 @@ class PackagingSystem(metaclass=ABCMeta):
         # dependencies, in order by preference
         self._contexts = ('generic',)
 
+    def derives_from(self, context):
+        return context in self._contexts
+
     def read_architecture(self):
         arch = os.uname()[4]
         self._architecture = { 'armv7l': 'armhf',

-- 
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