[game-data-packager] 25/39: Remove --repack option, and just always try it

Simon McVittie smcv at debian.org
Sun Jan 11 01:52:23 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 1dd67dfabc2cf4419a25b9cebca593b6fbfbc633
Author: Simon McVittie <smcv at debian.org>
Date:   Sat Jan 10 21:03:56 2015 +0000

    Remove --repack option, and just always try it
---
 data/quake3.yaml                   |  2 ++
 lib/game_data_packager/__init__.py | 41 ++++++++++++++++++--------------------
 2 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/data/quake3.yaml b/data/quake3.yaml
index 57af15b..d567b0f 100644
--- a/data/quake3.yaml
+++ b/data/quake3.yaml
@@ -3,6 +3,8 @@
 shortname: quake3
 longname: Quake III Arena (including Team Arena)
 compress_deb: false
+# Older versions of g-d-p used this directory
+try_repack_from: /usr/share/games/quake3
 
 help_text: |
   For quake3-data, you must provide baseq3/pak0.pk3 or a directory
diff --git a/lib/game_data_packager/__init__.py b/lib/game_data_packager/__init__.py
index dfdd9fc..4bc3e2e 100644
--- a/lib/game_data_packager/__init__.py
+++ b/lib/game_data_packager/__init__.py
@@ -292,12 +292,24 @@ class GameData(object):
 
         self.help_text = ''
 
+        # Extra directories where we might find game files
+        self.try_repack_from = []
+
         self.yaml = yaml.load(open(os.path.join(self.datadir,
             shortname + '.yaml')))
 
         if 'longname' in self.yaml:
             self.longname = self.yaml['longname']
 
+        if 'try_repack_from' in self.yaml:
+            paths = self.yaml['try_repack_from']
+            if isinstance(paths, list):
+                self.try_repack_from = paths
+            elif isinstance(paths, str):
+                self.try_repack_from = [paths]
+            else:
+                raise AssertionError('try_repack_from should be str or list')
+
         if 'package' in self.yaml:
             package = GameDataPackage(self.yaml['package'])
             self.packages[self.yaml['package']] = package
@@ -1074,8 +1086,6 @@ class GameData(object):
                 help=self.longname, aliases=self.packages.keys(),
                 description=self.help_text,
                 formatter_class=argparse.RawDescriptionHelpFormatter)
-        parser.add_argument('--repack', action='store_true',
-                help='Locate installed game files automatically')
         parser.add_argument('paths', nargs='*',
                 metavar='DIRECTORY|FILE',
                 help='Files to use in constructing the .deb')
@@ -1090,27 +1100,14 @@ class GameData(object):
         self.compress_deb = (self.compress_deb and
                 getattr(args, 'compress', True))
 
-        if getattr(args, 'repack', False):
-            can_repack = False
-            absent = set()
+        for path in self.try_repack_from:
+            if os.path.isdir(path):
+                args.paths.append(path)
 
-            for package in self.packages.values():
-                path = '/' + package.install_to
-                if os.path.isdir(path):
-                    args.paths.insert(0, path)
-                    can_repack = True
-                elif (package.name == 'quake3-data' and
-                        os.path.isdir('/usr/share/games/quake3')):
-                    # FIXME: this is a hack, it would be better to
-                    # have alternative locations defined in the YAML
-                    args.paths.insert(0, '/usr/share/games/quake3')
-                    can_repack = True
-                else:
-                    absent.add(path)
-
-            if not can_repack:
-                raise SystemExit('cannot repack %s: could not open %r' %
-                        (package, sorted(absent)))
+        for package in self.packages.values():
+            path = '/' + package.install_to
+            if os.path.isdir(path):
+                args.paths.append(path)
 
         for arg in args.paths:
             self.consider_file_or_dir(arg)

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