[game-data-packager] 02/03: GOG: call lgogdownloader automatically

Alexandre Detiste detiste-guest at moszumanska.debian.org
Tue Sep 15 10:00:51 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 4f4d4b94553282ff51524bcdfd642745b712dbc4
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Tue Sep 15 11:59:10 2015 +0200

    GOG: call lgogdownloader automatically
---
 debian/changelog               |  1 +
 debian/control                 |  5 +++--
 game_data_packager/__init__.py | 32 +++++++++++++++++++++++++++++---
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index ec22339..14ac238 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -24,6 +24,7 @@ game-data-packager (43) UNRELEASED; urgency=medium
   * add "game-data-packager steam" mode
   * make-template mode: check innoextract version (#797550)
   * add support for the new Doom packages at GOG.com (#796995)
+  * call 'lgogdownloader' automatically
 
   [ Stephen Kitt ]
   * Add Steam path for The 7th Guest.
diff --git a/debian/control b/debian/control
index a3220ec..e1ca1d6 100644
--- a/debian/control
+++ b/debian/control
@@ -25,6 +25,7 @@ Depends: fakeroot, ${misc:Depends},
 	python3-debian,
 	python3-yaml,
 	${python3:Depends},
+Breaks: lgogdownloader (<< 2.25-2~)
 Suggests:
 # for quake music and quake2 music
 	cdparanoia, vorbis-tools,
@@ -38,8 +39,8 @@ Suggests:
 	dynamite (>= 0.1.1-2),
 # for wolf3d v1.2
 	unzip,
-# gog.com games: Descent 1/2, Theme Hospital
-	innoextract,
+# for 100+ gog.com games
+	innoextract, lgogdownloader,
 # for Doom3
 	p7zip-full,
 # for Jedi Academy (demo), Arx Fatalis
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 8419c25..01e2a38 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -43,6 +43,7 @@ from debian.deb822 import Deb822
 import yaml
 
 from .config import read_config
+from .gog import GOG
 from .paths import DATADIR, ETCDIR
 from .util import (MEBIBYTE,
         TemporaryUmask,
@@ -1257,7 +1258,7 @@ class GameData(object):
             logger.warning('file "%s" does not exist or is not a file, ' +
                     'directory or CD block device', path)
 
-    def fill_gaps(self, package, download=False, log=True):
+    def fill_gaps(self, package, download=False, log=True, recheck=False):
         """Return a FillResult.
         """
         assert package is not None
@@ -1293,6 +1294,7 @@ class GameData(object):
                 wanted = self.files[filename]
                 # updates file_status as a side-effect
                 self.fill_gap(package, wanted, download=download,
+                        recheck=recheck,
                         log=(log and filename in package.install))
 
             logger.debug('%s: %s', filename, self.file_status[filename])
@@ -1301,6 +1303,30 @@ class GameData(object):
                 # it is mandatory
                 result &= self.file_status[filename]
 
+        # download game if it is already owned by user's GOG.com account
+        # user must have used 'lgogdownloader' at least once to make this work
+        if (result is FillResult.IMPOSSIBLE and package.gog
+            and which('innoextract') and which('lgogdownloader') ):
+             game = package.gog.get('game', package.gog['url'])
+             if game in GOG.owned_games():
+                 if recheck:
+                     logger.error('Something went bad,avoiding infinite loop')
+                 elif not download:
+                     result = FillResult.DOWNLOAD_NEEDED
+                 else:
+                     tmpdir = os.path.join(self.get_workdir(), game)
+                     mkdir_p(tmpdir)
+                     subprocess.check_call(['lgogdownloader',
+                                            '--download', '--no-extra',
+                                            '--directory', tmpdir,
+                                            '--platform', '1',
+                                            '--language', '1',
+                                            '--game', game])
+                     self.consider_file_or_dir(tmpdir)
+                     # recursively call again
+                     result = self.fill_gaps(package, log=True,
+                                             download=True, recheck=True)
+
         self.package_status[package.name] = result
         logger.debug('%s: %s', package.name, result)
         return result
@@ -1497,7 +1523,7 @@ class GameData(object):
             os.utime(path, (orig_time, orig_time))
             self.use_file(wanted, path, hasher)
 
-    def fill_gap(self, package, wanted, download=False, log=True):
+    def fill_gap(self, package, wanted, download=False, log=True, recheck=False):
         """Try to unpack, download or otherwise obtain wanted.
 
         If download is true, we may attempt to download wanted or a
@@ -1509,7 +1535,7 @@ class GameData(object):
             assert self.file_status[wanted.name] is FillResult.COMPLETE
             return FillResult.COMPLETE
 
-        if self.file_status[wanted.name] is FillResult.IMPOSSIBLE:
+        if self.file_status[wanted.name] is FillResult.IMPOSSIBLE and not recheck:
             return FillResult.IMPOSSIBLE
 
         if (self.file_status[wanted.name] is FillResult.DOWNLOAD_NEEDED and

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