[game-data-packager] 03/03: add support for multipart InnoExtract archives

Alexandre Detiste detiste-guest at moszumanska.debian.org
Wed Sep 30 07:50:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

detiste-guest pushed a commit to branch master
in repository game-data-packager.

commit 1728d4c3c8eeb7ff77cb1802dde761bc363b9057
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Wed Sep 30 09:49:29 2015 +0200

    add support for multipart InnoExtract archives
---
 game_data_packager/__init__.py | 94 ++++++++++++++++++++++++------------------
 tools/fake_lgog.py             | 37 +++++++++--------
 2 files changed, 75 insertions(+), 56 deletions(-)

diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index b306b07..6dcbba8 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -1794,41 +1794,47 @@ class GameData(object):
                              list(to_unpack), cwd=tmpdir)
                     self.consider_file_or_dir(tmpdir)
                 elif fmt == 'innoextract':
-                    to_unpack = provider.unpack.get('unpack', provider.provides)
-                    logger.debug('Extracting %r from %s',
-                            to_unpack, found_name)
-                    package.used_sources.add(provider.name)
-                    tmpdir = os.path.join(self.get_workdir(), 'tmp',
-                            provider_name + '.d')
-                    mkdir_p(tmpdir)
-                    cmdline = ['innoextract',
-                               '--language', 'english',
-                               '-T', 'local',
-                               '-d', tmpdir,
-                               os.path.abspath(found_name)]
-                    if not self.verbose:
-                        cmdline.append('--silent')
-                    version = subprocess.check_output(['innoextract', '-v', '-s'],
-                                                      universal_newlines=True)
-                    if version.split('-')[0] >= '1.5':
-                        prefix = provider.unpack.get('prefix', '')
-                        suffix = provider.unpack.get('suffix', '')
-                        if prefix and not prefix.endswith('/'):
-                            prefix += '/'
-                        if '$provides' in to_unpack:
-                            to_unpack.remove('$provides')
-                            to_unpack += provider.provides
-                        for i in to_unpack:
-                            cmdline.append('-I')
-                            if prefix and i[0] != '/':
-                                i = prefix + i
-                            if suffix and i.endswith(suffix):
-                                i = i[:len(i)-len(suffix)]
-                            cmdline.append(i)
-                    subprocess.check_call(cmdline)
-                    # for at least Theme Hospital the files we want are
-                    # actually in subdirectories, so we search recursively
-                    self.consider_file_or_dir(tmpdir)
+                    other_parts = provider.unpack.get('other_parts',[])
+                    for p in other_parts:
+                        self.fill_gap(package, self.files[p], download=False, log=True)
+                        if p not in self.found:
+                            # can't concatenate: one of the bits is missing
+                            break
+                    else:
+                        to_unpack = provider.unpack.get('unpack', provider.provides)
+                        logger.debug('Extracting %r from %s', to_unpack, found_name)
+                        package.used_sources.add(provider.name)
+                        tmpdir = os.path.join(self.get_workdir(), 'tmp',
+                                provider_name + '.d')
+                        mkdir_p(tmpdir)
+                        cmdline = ['innoextract',
+                                   '--language', 'english',
+                                   '-T', 'local',
+                                   '-d', tmpdir,
+                                   os.path.abspath(found_name)]
+                        if not self.verbose:
+                            cmdline.append('--silent')
+                        version = subprocess.check_output(['innoextract', '-v', '-s'],
+                                                          universal_newlines=True)
+                        if version.split('-')[0] >= '1.5':
+                            prefix = provider.unpack.get('prefix', '')
+                            suffix = provider.unpack.get('suffix', '')
+                            if prefix and not prefix.endswith('/'):
+                                prefix += '/'
+                            if '$provides' in to_unpack:
+                                to_unpack.remove('$provides')
+                                to_unpack += provider.provides
+                            for i in to_unpack:
+                                cmdline.append('-I')
+                                if prefix and i[0] != '/':
+                                    i = prefix + i
+                                if suffix and i.endswith(suffix):
+                                    i = i[:len(i)-len(suffix)]
+                                cmdline.append(i)
+                        subprocess.check_call(cmdline)
+                        # for at least Theme Hospital the files we want are
+                        # actually in subdirectories, so we search recursively
+                        self.consider_file_or_dir(tmpdir)
                 elif fmt == 'unzip' and which('unzip'):
                     to_unpack = provider.unpack.get('unpack', provider.provides)
                     logger.debug('Extracting %r from %s',
@@ -2903,17 +2909,27 @@ class GameData(object):
                                        '--platform-priority', 'linux,windows',
                                        '--language', package.lang,
                                        '--game', '^' + gog_id + '$'])
-                    archive = None
+                    # consider *.bin before the .exe file
+                    main_archive = None
+                    archives = []
                     for dirpath, dirnames, filenames in os.walk(tmpdir):
                         for fn in filenames:
                             archive = os.path.join(dirpath, fn)
-                            self.consider_file(archive, True, trusted=True)
+                            archives.append(archive)
+                            if os.path.splitext(fn)[1] in ('.exe', '.sh'):
+                                main_archive = archive
+                            else:
+                                self.consider_file(archive, True, trusted=True)
+                    if main_archive:
+                        self.consider_file(main_archive, True, trusted=True)
+
                     # recheck file status
                     if self.fill_gaps(package, log=True, download=True,
                        recheck=True) is not FillResult.IMPOSSIBLE:
                        ready.add(package)
-                    if archive and self.save_downloads:
-                        shutil.move(archive, self.save_downloads)
+                    if self.save_downloads:
+                        for archive in archives:
+                            shutil.move(archive, self.save_downloads)
                 except subprocess.CalledProcessError:
                     pass
             elif result is FillResult.DOWNLOAD_NEEDED and not download:
diff --git a/tools/fake_lgog.py b/tools/fake_lgog.py
index 1d7d47d..8beaf6c 100755
--- a/tools/fake_lgog.py
+++ b/tools/fake_lgog.py
@@ -37,24 +37,27 @@ assert args.game, 'Must specifiy --game'
 
 game = args.game.lstrip('^').rstrip('$')
 
-archive = {
-          'descent#en': 'setup_descent_2.1.0.8.exe',
-          'legend_of_kyrandia#en': 'setup_legend_of_kyrandia_2.1.0.14.exe',
-          'legend_of_kyrandia#de': 'setup_legend_of_kyrandia_german_2.1.0.14.exe',
-          'legend_of_kyrandia#fr': 'setup_legend_of_kyrandia_french_2.1.0.14.exe',
-          'loom#en': 'setup_loom_2.0.0.4.exe',
-          'rise_of_the_triad__dark_war#en': 'setup_rise_of_the_triad_2.0.0.5.exe',
-          #'rise_of_the_triad__dark_war#en': 'gog_rise_of_the_triad_dark_war_2.0.0.8.sh',
+archives = {
+          'descent#en': ['setup_descent_2.1.0.8.exe'],
+          'legend_of_kyrandia#en': ['setup_legend_of_kyrandia_2.1.0.14.exe'],
+          'legend_of_kyrandia#de': ['setup_legend_of_kyrandia_german_2.1.0.14.exe'],
+          'legend_of_kyrandia#fr': ['setup_legend_of_kyrandia_french_2.1.0.14.exe'],
+          'loom#en': ['setup_loom_2.0.0.4.exe'],
+          'rise_of_the_triad__dark_war#en': ['setup_rise_of_the_triad_2.0.0.5.exe'],
+          #'rise_of_the_triad__dark_war#en': ['gog_rise_of_the_triad_dark_war_2.0.0.8.sh'],
+          'the_feeble_files#en': ['setup_the_feeble_files_2.0.0.5.exe',
+                                  'setup_the_feeble_files_2.0.0.5-1.bin',
+                                  'setup_the_feeble_files_2.0.0.5-2.bin']
           }.get(game + '#' + (args.language or 'en'))
 
-if archive is None:
+if archives is None:
     exit('FAKE LGOGDOWNLOADER: Unknown game %s' % game)
 
-locate = subprocess.check_output(['locate', '-e', archive], universal_newlines=True)
-for file in locate.splitlines():
-    if file.endswith(archive):
-       break
-else:
-    exit('FAKE LGOGDOWNLOADER: archive %s not found in "locate" database' % archive)
-
-subprocess.check_call(['ln', '-s', '-v', file, args.directory])
+for archive in archives:
+    locate = subprocess.check_output(['locate', '-e', archive], universal_newlines=True)
+    for file in locate.splitlines():
+        if file.endswith(archive):
+           break
+    else:
+        exit('FAKE LGOGDOWNLOADER: archive %s not found in "locate" database' % archive)
+    subprocess.check_call(['ln', '-s', '-v', file, args.directory])

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