[game-data-packager] 02/09: Reduce duplication by making GOG path search behave more like Steam

Simon McVittie smcv at debian.org
Sun Oct 25 22:13:36 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 f5e18bdea146fc250a8993a8c43a5d5f24039ba4
Author: Simon McVittie <smcv at debian.org>
Date:   Sat Oct 24 18:28:45 2015 +0100

    Reduce duplication by making GOG path search behave more like Steam
    
    Because GOG games' paths tend to have a variable suffix by language,
    I've made the code search anything that starts with the right prefix.
---
 data/atlantis.yaml                  | 15 ++++-----------
 data/baldurs-gate-1.yaml            |  4 +++-
 data/baldurs-gate-2.yaml            |  4 +++-
 data/dig.yaml                       | 15 ++++-----------
 data/eye-of-the-beholder1.yaml      | 11 ++++-------
 data/eye-of-the-beholder2.yaml      | 11 +++++------
 data/hugo.yaml                      | 10 +++-------
 data/inherit.yaml                   | 11 ++++-------
 data/loom.yaml                      |  8 +++-----
 data/nomouth.yaml                   | 22 ++++------------------
 data/rott.yaml                      |  4 +---
 data/sam-and-max.yaml               | 16 +++++-----------
 data/toonstruck.yaml                | 17 ++++-------------
 data/zak.yaml                       |  5 +----
 game_data_packager/build.py         | 34 ++++++++++++++++++++++++++++++++++
 game_data_packager/make_template.py |  6 +++---
 16 files changed, 85 insertions(+), 108 deletions(-)

diff --git a/data/atlantis.yaml b/data/atlantis.yaml
index 010f720..ad90306 100644
--- a/data/atlantis.yaml
+++ b/data/atlantis.yaml
@@ -4,17 +4,10 @@ franchise: Indiana Jones
 copyright: © 1992 LucasArts
 plugin: scummvm_common
 wiki: Indiana_Jones_and_the_Fate_of_Atlantis
-try_repack_from:
-- "/opt/GOG Games/Indiana Jones and the Fate of Atlantis"
-- "/opt/GOG Games/Indiana Jones and the Fate of Atlantis (French)"
-- "/opt/GOG Games/Indiana Jones and the Fate of Atlantis (German)"
-- "/opt/GOG Games/Indiana Jones and the Fate of Atlantis (Italian)"
-- "/opt/GOG Games/Indiana Jones and the Fate of Atlantis (Spanish)"
-- "~/GOG Games/Indiana Jones and the Fate of Atlantis"
-- "~/GOG Games/Indiana Jones and the Fate of Atlantis French"
-- "~/GOG Games/Indiana Jones and the Fate of Atlantis German"
-- "~/GOG Games/Indiana Jones and the Fate of Atlantis Italian"
-- "~/GOG Games/Indiana Jones and the Fate of Atlantis Spanish"
+gog:
+  # also seen with language suffix: "... (French)" or "... French",
+  # and the same for German, Italian, Spanish
+  path: "Indiana Jones and the Fate of Atlantis"
 
 help_text: |
   The non-english versions available on GOG.com are not always the best ones.
diff --git a/data/baldurs-gate-1.yaml b/data/baldurs-gate-1.yaml
index f686eac..bd952cb 100644
--- a/data/baldurs-gate-1.yaml
+++ b/data/baldurs-gate-1.yaml
@@ -6,7 +6,9 @@ genre: Role Playing
 engine: gemrb
 compress_deb: [-Zgzip, -z1]
 missing_langs: [fr,de,pl,ru]
-try_repack_from: ['~/GOG Games/Baldurs Gate The Original Saga']
+gog:
+  path:
+    'Baldurs Gate The Original Saga'
 help_text: |
   Data for Baldur's Gate - The Original Saga can be downloaded from gog.com
   automatically. You can skip the download by providing the English Linux
diff --git a/data/baldurs-gate-2.yaml b/data/baldurs-gate-2.yaml
index ab4213a..d7c8914 100644
--- a/data/baldurs-gate-2.yaml
+++ b/data/baldurs-gate-2.yaml
@@ -6,7 +6,9 @@ genre: Role Playing
 engine: gemrb
 compress_deb: [-Zgzip, -z1]
 missing_langs: [fr,de,pl,ru]
-try_repack_from: ['~/GOG Games/Baldurs Gate 2 Complete']
+gog:
+  path:
+    'Baldurs Gate 2 Complete'
 help_text: |
   Data for Baldur's Gate 2 can be downloaded from gog.com. Please download the
   English Linux installer and run it manually. Copy all files into a directory
diff --git a/data/dig.yaml b/data/dig.yaml
index 0687038..baa84a5 100644
--- a/data/dig.yaml
+++ b/data/dig.yaml
@@ -3,17 +3,10 @@ longname: The Dig
 copyright: © 1995 LucasArts
 plugin: scummvm_common
 wiki: Dig
-try_repack_from:
-- "/opt/GOG Games/The Dig"
-- "/opt/GOG Games/The Dig (French)"
-- "/opt/GOG Games/The Dig (German)"
-- "/opt/GOG Games/The Dig (Italian)"
-- "/opt/GOG Games/The Dig (Spanish)"
-- "~/GOG Games/The Dig"
-- "~/GOG Games/The Dig French"
-- "~/GOG Games/The Dig German"
-- "~/GOG Games/The Dig Italian"
-- "~/GOG Games/The Dig Spanish"
+gog:
+  # also seen with language suffix: "... (French)" or "... French",
+  # and the same for German, Italian, Spanish
+  path: "The Dig"
 
 packages:
   the-dig-en-data:
diff --git a/data/eye-of-the-beholder1.yaml b/data/eye-of-the-beholder1.yaml
index 9714c7d..372ac07 100644
--- a/data/eye-of-the-beholder1.yaml
+++ b/data/eye-of-the-beholder1.yaml
@@ -6,7 +6,10 @@ genre: Role Playing
 plugin: scummvm_common
 wiki: Eye_of_the_Beholder
 gameid: eob
-try_repack_from: ['~/GOG Games/Eye of the Beholder']
+gog:
+  url: forgotten_realms_the_archives_collection_one
+  game: eye_of_the_beholder
+  path: 'Eye of the Beholder'
 
 missing_langs: [es]
 
@@ -23,9 +26,6 @@ packages:
   eye-of-the-beholder1-en-data:
     debian:
       provides: eye-of-the-beholder1-data
-    gog:
-      url: forgotten_realms_the_archives_collection_one
-      game: eye_of_the_beholder
     install:
     - eobdata1.pak
     - eobdata2.pak
@@ -46,9 +46,6 @@ packages:
     lang: de
     debian:
       provides: eye-of-the-beholder1-data
-    gog:
-      url: forgotten_realms_the_archives_collection_one
-      game: eye_of_the_beholder
     doc:
     - cluebook.pdf
     - manual.pdf
diff --git a/data/eye-of-the-beholder2.yaml b/data/eye-of-the-beholder2.yaml
index 19418f0..4415b12 100644
--- a/data/eye-of-the-beholder2.yaml
+++ b/data/eye-of-the-beholder2.yaml
@@ -6,9 +6,11 @@ genre: Role Playing
 plugin: scummvm_common
 wiki: "Eye_of_the_Beholder_II:_The_Legend_of_Darkmoon"
 gameid: eob2
-try_repack_from:
-- '~/GOG Games/Eye of the Beholder II The Legend of Darkmoon'
-- '~/GOG Games/Eye of the Beholder II The Legend of Darkmoon German'
+gog:
+  # also seen with " German" suffix
+  path: 'Eye of the Beholder II The Legend of Darkmoon'
+  url: forgotten_realms_the_archives_collection_one
+  game: eye_of_the_beholder_ii_the_legend_of_darkmoon
 
 missing_langs: [es]
 
@@ -21,9 +23,6 @@ packages:
   eye-of-the-beholder2-en-data:
     debian:
       provides: eye-of-the-beholder2-data
-    gog:
-      url: forgotten_realms_the_archives_collection_one
-      game: eye_of_the_beholder_ii_the_legend_of_darkmoon
     doc:
     - cluebook.pdf
     - manual.pdf
diff --git a/data/hugo.yaml b/data/hugo.yaml
index cbe0cb5..1098795 100644
--- a/data/hugo.yaml
+++ b/data/hugo.yaml
@@ -3,15 +3,15 @@ longname: The Hugo Trilogy
 copyright: © 1990-1992 Gray Design Associates
 plugin: scummvm_common
 wiki: Hugo
-try_repack_from: ['~/GOG Games/The Hugo Trilogy']
+gog:
+  path: 'The Hugo Trilogy'
+  url: the_hugo_trilogy
 
 packages:
   hugo1-data:
     longname: "Hugo's House of Horrors"
     copyright: © 1990 Gray Design Associates
     gameid: hugo1
-    gog:
-      url: the_hugo_trilogy
     install:
     - hugo.bsf
     - objects.dat?hugo1
@@ -26,8 +26,6 @@ packages:
     longname: "Hugo II, Whodunit?"
     copyright: © 1991 Gray Design Associates
     gameid: hugo2
-    gog:
-      url: the_hugo_trilogy
     install:
     - hugo.bsf
     - objects.dat?hugo2
@@ -42,8 +40,6 @@ packages:
     longname: "Hugo III, Jungle of Doom!"
     copyright: © 1992 Gray Design Associates
     gameid: hugo3
-    gog:
-      url: the_hugo_trilogy
     install:
     - hugo.bsf
     - objects.dat?hugo3
diff --git a/data/inherit.yaml b/data/inherit.yaml
index 3158bd2..621a317 100644
--- a/data/inherit.yaml
+++ b/data/inherit.yaml
@@ -4,9 +4,10 @@ copyright: © 1994 The Dreamers Guild
 plugin: scummvm_common
 wiki: Inherit_the_Earth
 gameid: ite
-try_repack_from:
-- "~/GOG Games/Inherit The Earth"
-- "~/GOG Games/Inherit The Earth German"
+gog:
+  url: inherit_the_earth
+  # German version has "... German" suffix
+  path: 'Inherit The Earth'
 
 help_text: |
   The German version requires ScummVM 1.8.0
@@ -29,8 +30,6 @@ packages:
     steam:
       id: 257260
       path: common/Inherit the Earth/itedata
-    gog:
-      url: inherit_the_earth
     install:
     - ite.rsc
     - scripts.rsc
@@ -48,8 +47,6 @@ packages:
     steam:
       id: 257260
       path: common/Inherit the Earth/itedata
-    gog:
-      url: inherit_the_earth
     install:
     - ite.rsc?de
     - scripts.rsc?de
diff --git a/data/loom.yaml b/data/loom.yaml
index ba828b8..06785af 100644
--- a/data/loom.yaml
+++ b/data/loom.yaml
@@ -1,15 +1,13 @@
 copyright: © 1990 Lucasfilm Games
 plugin: scummvm_common
 wiki: Loom
-try_repack_from:
-- "/opt/GOG Games/Loom"
-- "~/GOG Games/Loom"
+gog:
+  url: loom
+  path: Loom
 
 packages:
   loom-data:
     copyright: © 1992 Lucasfilm Games
-    gog:
-      url: loom
     steam:
       id: 32340
       path: common/LOOM
diff --git a/data/nomouth.yaml b/data/nomouth.yaml
index 23484eb..3bda866 100644
--- a/data/nomouth.yaml
+++ b/data/nomouth.yaml
@@ -8,18 +8,12 @@ gameid: ihnm
 steam:
   id: 245390
   path: common/IHNMAIMS
+gog:
+  # known suffix: " French", " (French)"; same for German, Spanish
+  path: 'I Have No Mouth And I Must Scream'
+  url: i_have_no_mouth_and_i_must_scream
 missing_langs: [ru]
 
-try_repack_from:
-- "/opt/GOG Games/I Have No Mouth And I Must Scream"
-- "/opt/GOG Games/I Have No Mouth And I Must Scream (French)"
-- "/opt/GOG Games/I Have No Mouth And I Must Scream (German)"
-- "/opt/GOG Games/I Have No Mouth And I Must Scream (Spanish)"
-- "~/GOG Games/I Have No Mouth And I Must Scream"
-- "~/GOG Games/I Have No Mouth And I Must Scream French"
-- "~/GOG Games/I Have No Mouth And I Must Scream German"
-- "~/GOG Games/I Have No Mouth And I Must Scream Spanish"
-
 help_text: |
   In the French & German versions,
   Nimdok character has been censored-out;
@@ -41,8 +35,6 @@ packages:
   i-have-no-mouth-and-i-must-scream-en-data:
     debian:
       provides: i-have-no-mouth-and-i-must-scream-data
-    gog:
-      url: i_have_no_mouth_and_i_must_scream
     install:
     - musicfm.res
     - musicgm.res
@@ -66,8 +58,6 @@ packages:
     lang: de
     debian:
       provides: i-have-no-mouth-and-i-must-scream-data
-    gog:
-      url: i_have_no_mouth_and_i_must_scream
     install:
     - musicfm.res
     - musicgm.res
@@ -91,8 +81,6 @@ packages:
     lang: fr
     debian:
       provides: i-have-no-mouth-and-i-must-scream-data
-    gog:
-      url: i_have_no_mouth_and_i_must_scream
     install:
     - musicfm.res
     - musicgm.res
@@ -116,8 +104,6 @@ packages:
     lang: es
     debian:
       provides: i-have-no-mouth-and-i-must-scream-data
-    gog:
-      url: i_have_no_mouth_and_i_must_scream
     install:
     - musicfm.res
     - musicgm.res
diff --git a/data/rott.yaml b/data/rott.yaml
index 70ed69c..8acbbc6 100644
--- a/data/rott.yaml
+++ b/data/rott.yaml
@@ -3,9 +3,6 @@ longname: Rise of the Triad
 copyright: © 1995 Apogee Software
 engine: rott
 genre: First-person shooter
-try_repack_from:
-- "/opt/GOG Games/Rise of the Triad Dark War"
-- "~/GOG Games/Rise of the Triad Dark War"
 
 help_text: |
   The GOG.com & Steam packages don't include
@@ -18,6 +15,7 @@ steam:
   path: "common/The Apogee Throwback Pack/Rise of the Triad"
 gog:
   url: rise_of_the_triad__dark_war
+  path: "Rise of the Triad Dark War"
 
 packages:
   rott-data:
diff --git a/data/sam-and-max.yaml b/data/sam-and-max.yaml
index d802a46..71e3b3e 100644
--- a/data/sam-and-max.yaml
+++ b/data/sam-and-max.yaml
@@ -4,17 +4,6 @@ copyright: © 1993 LucasArts
 plugin: scummvm_common
 wiki: Sam_%26_Max_Hit_the_Road
 gameid: samnmax
-try_repack_from:
-- "/opt/GOG Games/Sam And Max Hit The Road"
-- "/opt/GOG Games/Sam And Max Hit The Road (French)"
-- "/opt/GOG Games/Sam And Max Hit The Road (German)"
-- "/opt/GOG Games/Sam And Max Hit The Road (Italian)"
-- "/opt/GOG Games/Sam And Max Hit The Road (Spanish)"
-- "~/GOG Games/Sam Max Hit the Road"
-- "~/GOG Games/Sam Max Hit the Road French"
-- "~/GOG Games/Sam Max Hit the Road German"
-- "~/GOG Games/Sam Max Hit the Road Italian"
-- "~/GOG Games/Sam Max Hit the Road Spanish"
 
 help_text: |
   Here are the versions available in GOG package:
@@ -24,6 +13,11 @@ help_text: |
 
 gog:
   url: sam_max_hit_the_road
+  path:
+    # also with " (French)" suffix, and same for German, Italian, Spanish
+    - "Sam And Max Hit The Road"
+    # also with " French" suffix, and same for German, Italian, Spanish
+    - "Sam Max Hit the Road"
 
 packages:
   sam-and-max-en-data:
diff --git a/data/toonstruck.yaml b/data/toonstruck.yaml
index c5b0a3e..ac4972b 100644
--- a/data/toonstruck.yaml
+++ b/data/toonstruck.yaml
@@ -5,18 +5,15 @@ wiki: Toonstruck
 gameid: toon
 disks: 2
 missing_langs: [ru]
-try_repack_from:
-- '~/GOG Games/Toonstruck'
-- '~/GOG Games/Toonstruck German'
-- '~/GOG Games/Toonstruck Spanish'
-- '~/GOG Games/Toonstruck French'
+gog:
+  url: toonstruck
+  # also seen as "Toonstruck {German,Spanish,French}"
+  path: Toonstruck
 
 packages:
   toonstruck-en-data:
     debian:
       provides: toonstruck-data
-    gog:
-      url: toonstruck
     install:
     - act1/arcaddbl/422m.smk
     - act1/arcaddbl/423m.smk
@@ -586,8 +583,6 @@ packages:
     lang: de
     debian:
       provides: toonstruck-data
-    gog:
-      url: toonstruck
     install:
     - act1/arcaddbl/422m.smk?de
     - act1/arcaddbl/423m.smk?de
@@ -873,8 +868,6 @@ packages:
     lang: es
     debian:
       provides: toonstruck-data
-    gog:
-      url: toonstruck
     doc:
     - manual.pdf?es
     install:
@@ -1160,8 +1153,6 @@ packages:
     lang: fr
     debian:
       provides: toonstruck-data
-    gog:
-      url: toonstruck
     doc:
     - manual.pdf?fr
     install:
diff --git a/data/zak.yaml b/data/zak.yaml
index 9ffce66..525250e 100644
--- a/data/zak.yaml
+++ b/data/zak.yaml
@@ -4,10 +4,6 @@ copyright: © 1988 Lucasfilm Games
 plugin: scummvm_common
 wiki: Zak_McKracken_and_the_Alien_Mindbenders
 
-try_repack_from:
-- "/opt/GOG Games/Zak McKracken and the Alien Mindbenders"
-- "~/GOG Games/Zak McKracken and the Alien Mindbenders"
-
 help_text: |
   GOG.com only sells the English version.
 
@@ -15,6 +11,7 @@ packages:
   zak-en-data:
     gog:
       url: zak_mckracken_and_the_alien_mindbenders
+      path: 'Zak McKracken and the Alien Mindbenders'
     debian:
       provides: zak-data
     install:
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index 8fe4075..0873fc1 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -2246,6 +2246,40 @@ class PackagingTask(object):
                 return icon
         return
 
+    def iter_gog_paths(self, packages=None):
+        if packages is None:
+            packages = self.game.packages.values()
+
+        dirnames = set()
+        for p in list(packages) + [self.game]:
+            # some games seem to list more than one installation path :-(
+            path = p.gog.get('path')
+            if isinstance(path, list):
+                dirnames |= set(path)
+            else:
+                dirnames.add(path)
+        dirnames.discard(None)
+        if not dirnames:
+            return
+
+        for prefix in ('/opt/GOG Games', os.path.expanduser('~/GOG Games')):
+            try:
+                # We look for anything starting with an element of dirnames,
+                # so that we'll pick up names like "Inherit The Earth German".
+                for name in os.listdir(prefix):
+                    for target in dirnames:
+                        try:
+                            if name.startswith(target):
+                                path = os.path.join(prefix, name)
+                                if os.path.isdir(path):
+                                    logger.debug('possible %r found at %r',
+                                            self.game.shortname, path)
+                                    yield os.path.realpath(path)
+                        except OSError:
+                            continue
+            except OSError:
+                continue
+
     def iter_steam_paths(self, packages=None):
         if packages is None:
             packages = self.game.packages.values()
diff --git a/game_data_packager/make_template.py b/game_data_packager/make_template.py
index 86ace2d..c8c52d5 100644
--- a/game_data_packager/make_template.py
+++ b/game_data_packager/make_template.py
@@ -121,6 +121,7 @@ class GameData(object):
         self.plugin = None
         self.gog_url = None
         self.gog_game = None
+        self.gog_path = None
 
         self.data = dict()
         # global list of files accross packages
@@ -313,8 +314,7 @@ class GameData(object):
                     for line in metadata.read().decode().splitlines():
                         line = line.strip()
                         if line.startswith('id = '):
-                            dir = '~/GOG Games/' + line.split('"')[1]
-                            self.try_repack_from.append(dir)
+                            self.gog_path = line.split('"')[1]
 
     def add_one_innoextract(self,exe):
         game = self.gog_game = GOG.get_id_from_archive(exe)
@@ -427,7 +427,7 @@ class GameData(object):
                             there = name[len('opt/GOG Games/'):]
                             there = there.split('/', 1)[0]
                             install_to = ('opt/GOG Games/' + there)
-                            self.try_repack_from.append('/' + install_to)
+                            self.gog_path = there
 
                     if entry.isfile():
                         hf = HashedFile.from_file(deb + '//data.tar.*//' + name,

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