[game-data-packager] 01/01: GOG: trust unknown InnoSetup we got from lgogdownloader
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Sun Sep 20 10:24:07 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 59902e37c636a055591f3c4c75dd33783768af2a
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Sun Sep 20 12:23:16 2015 +0200
GOG: trust unknown InnoSetup we got from lgogdownloader
---
game_data_packager/__init__.py | 37 +++++++++++++++++++++++++++++++------
game_data_packager/make_template.py | 2 +-
tools/fake_lgog.py | 3 ++-
3 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index c05f716..fa49266 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -1116,7 +1116,7 @@ class GameData(object):
return HashedFile.from_file(path, open(path, 'rb'), size=size,
progress=(size > QUITE_LARGE))
- def consider_file(self, path, really_should_match_something):
+ def consider_file(self, path, really_should_match_something, trusted=False):
if not os.path.exists(path):
# dangling symlink
return
@@ -1205,13 +1205,38 @@ class GameData(object):
if self.use_file(self.files[wanted_name], path, hashes):
return
- if really_should_match_something:
+ basename = os.path.basename(path)
+ extension = os.path.splitext(basename)[1]
+ if trusted:
+ if basename.startswith('gog_') and extension == '.sh':
+ with zipfile.ZipFile(path, 'r') as zf:
+ self.consider_zip(path, zf)
+ elif basename.startswith('setup_') and extension == '.exe':
+ version = subprocess.check_output(['innoextract', '-v', '-s'],
+ universal_newlines=True)
+ args = ['-I', '/app'] if version.split('-')[0] >= '1.5' else []
+ tmpdir = os.path.join(self.get_workdir(), 'tmp',
+ basename + '.d')
+ mkdir_p(tmpdir)
+ subprocess.check_call(['innoextract',
+ '--language', 'english',
+ '-T', 'local',
+ '-d', tmpdir,
+ path] + args)
+ self.consider_file_or_dir(tmpdir)
+ # print warning after innoextract's output,
+ # to give user a chance to read it
+ logger.warning('\n\nPlease repport this unknown archive to '
+ 'game-data-packager at packages.debian.org\n\n'
+ ' %-9s %s %s\n'
+ ' %s %s\n' % (size, hashes.md5, basename, hashes.sha1, basename))
+ elif really_should_match_something:
logger.warning('file "%s" does not match any known file', path)
# ... still G-D-P should try to process any random .zip
# file thrown at it, like the .zip provided by GamersHell
# or the MojoSetup installers provided by GOG.com
- if (os.path.splitext(path)[1].lower() in ('.zip', '.apk')
- or (os.path.basename(path).startswith('gog_') and path.endswith('.sh')) ):
+ if (extension.lower() in ('.zip', '.apk')
+ or (basename.startswith('gog_') and extension == '.sh')):
with zipfile.ZipFile(path, 'r') as zf:
self.consider_zip(path, zf)
@@ -1778,7 +1803,7 @@ class GameData(object):
cmdline.append('--silent')
version = subprocess.check_output(['innoextract', '-v', '-s'],
universal_newlines=True)
- if version[0:3] >= '1.5':
+ if version.split('-')[0] >= '1.5':
prefix = provider.unpack.get('prefix', '')
suffix = provider.unpack.get('suffix', '')
if prefix and not prefix.endswith('/'):
@@ -2876,7 +2901,7 @@ class GameData(object):
for dirpath, dirnames, filenames in os.walk(tmpdir):
for fn in filenames:
archive = os.path.join(dirpath, fn)
- self.consider_file(archive, True)
+ self.consider_file(archive, True, trusted=True)
# recheck file status
if self.fill_gaps(package, log=True, download=True,
recheck=True) is not FillResult.IMPOSSIBLE:
diff --git a/game_data_packager/make_template.py b/game_data_packager/make_template.py
index 17d4f3f..1446dca 100644
--- a/game_data_packager/make_template.py
+++ b/game_data_packager/make_template.py
@@ -213,7 +213,7 @@ class GameData(object):
command = ['innoextract', os.path.realpath(exe)]
version = subprocess.check_output(['innoextract', '-v', '-s'], universal_newlines=True)
- if version[0:3] >= '1.5':
+ if version.split('-')[0] >= '1.5':
command.append('-I')
command.append('app')
diff --git a/tools/fake_lgog.py b/tools/fake_lgog.py
index 917095b..7952cc8 100755
--- a/tools/fake_lgog.py
+++ b/tools/fake_lgog.py
@@ -44,12 +44,13 @@ archive = {
'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',
}.get(game + '#' + (args.language or 'en'))
if archive is None:
exit('FAKE LGOGDOWNLOADER: Unknown game %s' % game)
-locate = subprocess.check_output(['locate', archive], universal_newlines=True)
+locate = subprocess.check_output(['locate', '-e', archive], universal_newlines=True)
for file in locate.splitlines():
if file.endswith(archive):
break
--
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