[game-data-packager] 01/01: GOG: trusted already downloaded files if the size+md5 match cached info

Alexandre Detiste detiste-guest at moszumanska.debian.org
Tue Oct 13 08:28:16 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 1a2eb15e8f1d2fbbdf50de81772348b8896cbbc2
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Tue Oct 13 10:27:26 2015 +0200

    GOG: trusted already downloaded files if the size+md5 match cached info
---
 data/rott.yaml              | 30 +++++++++++++++---------------
 game_data_packager/build.py |  2 ++
 game_data_packager/gog.py   | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/data/rott.yaml b/data/rott.yaml
index 032999d..3023ee7 100644
--- a/data/rott.yaml
+++ b/data/rott.yaml
@@ -125,19 +125,19 @@ files:
   DEMO4_3.DMO:
     distinctive_name: false
 
-  setup_rise_of_the_triad_2.0.0.5.exe:
-    unpack:
-      format: innoextract
-    provides:
-    - DARKWAR.RTL
-    - DARKWAR.WAD
-    - EXTREME.RTL
-    - HUNTBGIN.RTC
-    - HUNTBGIN.RTL
-    - LICENSE.TXT
-    - manual.pdf?gog
-    - REMOTE1.RTS
-    - ROTTCD.RTC
+  #setup_rise_of_the_triad_2.0.0.5.exe:
+  #  unpack:
+  #    format: innoextract
+  #  provides:
+  #  - DARKWAR.RTL
+  #  - DARKWAR.WAD
+  #  - EXTREME.RTL
+  #  - HUNTBGIN.RTC
+  #  - HUNTBGIN.RTL
+  #  - LICENSE.TXT
+  #  - manual.pdf?gog
+  #  - REMOTE1.RTS
+  #  - ROTTCD.RTC
 
   # MojoSetup archive
   gog_rise_of_the_triad_dark_war_2.0.0.8.sh:
@@ -215,7 +215,7 @@ size_and_md5: |
 
   8199108  37ea1777fb3156634006c96e4be4ea17 manual.pdf?steam
 
-  31605104 92a132d4d25d6f96587e406bd9959ae8 setup_rise_of_the_triad_2.0.0.5.exe
+  #31605104 92a132d4d25d6f96587e406bd9959ae8 setup_rise_of_the_triad_2.0.0.5.exe
   22951652 bd413e46648d9dbcf10bb579c9b867fd gog_rise_of_the_triad_dark_war_2.0.0.8.sh
   21337749 5695390945993b841f1c0b72781d143c gog_rise_of_the_triad_dark_war_1.0.0.7.tar.gz
   18864246 7acfe7c8d48c4654604b90e955212793 gog_rise_of_the_triad_dark_war_1.0.0.7.deb
@@ -247,7 +247,7 @@ sha1sums: |
 
   78d12446ee71853ea71b648f4852b0f548773648  manual.pdf?steam
 
-  53d4a05c474dd13098b9d591ea2eab13310af0bc  setup_rise_of_the_triad_2.0.0.5.exe
+  #53d4a05c474dd13098b9d591ea2eab13310af0bc  setup_rise_of_the_triad_2.0.0.5.exe
   7ecd289958858af8dfc357fec2499d9bc3e7206b  manual.pdf?gog
   22189affd36bed5e0be9c9fde86e1701c840c0a8  gog_rise_of_the_triad_dark_war_2.0.0.8.sh
   017a31ee33bdb81882287b497682b12de56b0f50  gog_rise_of_the_triad_dark_war_1.0.0.7.tar.gz
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index 2fe4512..79627b5 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -556,6 +556,8 @@ class PackagingTask(object):
                     tried.add(wanted_name)
                     if self.use_file(self.game.files[wanted_name], path, hashes):
                         return
+            if not trusted:
+                trusted = GOG.verify_checksum(path, size, hashes.md5)
 
         basename = os.path.basename(path)
         extension = os.path.splitext(basename)[1]
diff --git a/game_data_packager/gog.py b/game_data_packager/gog.py
index fc2c961..50128ae 100644
--- a/game_data_packager/gog.py
+++ b/game_data_packager/gog.py
@@ -81,6 +81,39 @@ class Gog:
                 if installer['path'].endswith(archive):
                     return game['gamename']
 
+    def verify_checksum(self, archive, size, md5):
+        basename = os.path.basename(archive)
+        extension = os.path.splitext(basename)[1]
+        if not (basename.startswith('gog_') and extension == '.sh'
+             or basename.startswith('setup_') and extension == '.exe'):
+            return False
+
+        xml_root = os.path.expanduser('~/.cache/lgogdownloader/xml/')
+        if not os.path.isdir(xml_root):
+            return False
+
+        for dirpath, dirnames, filenames in os.walk(xml_root):
+            for fn in filenames:
+                if fn != basename + '.xml':
+                    continue
+                xml_file = os.path.join(dirpath, fn)
+                xml = open(xml_file, 'r', encoding='utf-8').readline()
+                xml = xml.strip('<>\n')
+                xml_md5 = None
+                xml_size = None
+                for tag in xml.split(' '):
+                    if '=' not in tag:
+                        continue
+                    k,v = tag.split('=', 2)
+                    v = v.strip('"')
+                    if k == 'md5':
+                        xml_md5 = v
+                    elif k == 'total_size':
+                        xml_size = int(v)
+                if xml_size == size and xml_md5 == md5:
+                    return True
+        return False
+
 GOG = Gog()
 
 def run_gog_meta_mode(parsed, games):

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