[game-data-packager] 03/03: steamcmd integration

Alexandre Detiste detiste-guest at moszumanska.debian.org
Sun Dec 27 10:43:56 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 87b1826bc20f561554eb726b307e91250f4d5962
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Sun Dec 27 11:37:26 2015 +0100

    steamcmd integration
    
    ./run doom2
    INFO:game-data-packager.build:doom2-wad can be downloaded with steamcmd
    Please provided password for Steam account psn_sir_dregan:
    Redirecting stderr to '/home/tchet/.steam/logs/stderr.txt'
    [  0%] Recherche de nouvelles mises à jour...
    [----] Vérification de l'installation...
    Steam Console Client (c) Valve Corporation
    -- type 'quit' to exit --
    Loading Steam API...OK.
    "@sSteamCmdForcePlatformType" = "windows"
    
    Logging in user 'psn_sir_dregan' to Steam Public...Logged in OK
    Waiting for license info...OK
    roaming config store loaded successfully - 3501 bytes.
    migrating temporary roaming config store
     Update state (0x5) validating, progress: 81,27 (16324690 / 20086753)
     Update state (0x61) downloading, progress: 0,00 (0 / 14604584)
     Update state (0x61) downloading, progress: 0,00 (0 / 14604584)
     ....
     Update state (0x61) downloading, progress: 85,64 (12507432 / 14604584)
     Update state (0x61) downloading, progress: 85,64 (12507432 / 14604584)
     Update state (0x61) downloading, progress: 92,82 (13556008 / 14604584)
     Update state (0x61) downloading, progress: 92,82 (13556008 / 14604584)
    Success! App '2300' fully installed.
    INFO:game-data-packager.build:generating package doom2-wad
---
 data/duke3d.yaml                     |  1 +
 data/noahs-ark.yaml                  |  1 +
 data/nomouth.yaml                    |  1 +
 data/pajama-sam-gtpoad.yaml          |  1 +
 data/strife.yaml                     |  1 +
 data/tony.yaml                       |  1 +
 debian/control                       |  2 ++
 game_data_packager/build.py          | 50 +++++++++++++++++++++++++++++++++---
 game_data_packager/games/lgeneral.py |  2 +-
 game_data_packager/steam.py          |  9 +++++++
 10 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/data/duke3d.yaml b/data/duke3d.yaml
index 72ddbd2..1d54d56 100644
--- a/data/duke3d.yaml
+++ b/data/duke3d.yaml
@@ -28,6 +28,7 @@ packages:
     steam:
       id: 225140
       path: common/Duke Nukem 3D/gameroot/classic
+      native: true
     gog:
       url: duke_nukem_3d_atomic_edition
       # banner at http://eduke32.com/
diff --git a/data/noahs-ark.yaml b/data/noahs-ark.yaml
index ce76a7b..41b04cd 100644
--- a/data/noahs-ark.yaml
+++ b/data/noahs-ark.yaml
@@ -19,6 +19,7 @@ packages:
     steam:
       id: 371180
       path: "common/Super 3-D Noah's Ark"
+      native: true
     url_misc: http://wisdomtree.itch.io/s3dna
     install:
     - audiohed.n3d
diff --git a/data/nomouth.yaml b/data/nomouth.yaml
index 345c0cc..67ad2c6 100644
--- a/data/nomouth.yaml
+++ b/data/nomouth.yaml
@@ -8,6 +8,7 @@ gameid: ihnm
 steam:
   id: 245390
   path: common/IHNMAIMS
+  native: true
 gog:
   # known suffix: " French", " (French)"; same for German, Spanish
   path: 'I Have No Mouth And I Must Scream'
diff --git a/data/pajama-sam-gtpoad.yaml b/data/pajama-sam-gtpoad.yaml
index 23d61f1..3cf59d5 100644
--- a/data/pajama-sam-gtpoad.yaml
+++ b/data/pajama-sam-gtpoad.yaml
@@ -10,6 +10,7 @@ gameid: pjgames
 steam:
   id: 317020
   path: common/Pajama Sam GTPOAD
+  native: true
 
 packages:
   pajama-sam-games-to-play-on-any-day-data:
diff --git a/data/strife.yaml b/data/strife.yaml
index 738e9f5..03d5f1b 100644
--- a/data/strife.yaml
+++ b/data/strife.yaml
@@ -26,6 +26,7 @@ packages:
     steam:
       id: 317040
       path: common/Strife
+      native: true
     fedora:
       engine: chocolate-doom
     suse:
diff --git a/data/tony.yaml b/data/tony.yaml
index a3c053d..e42a743 100644
--- a/data/tony.yaml
+++ b/data/tony.yaml
@@ -8,6 +8,7 @@ missing_langs: [de,it,pl]
 steam:
   id: 356210
   path: common/TonyTough
+  native: true
 dotemu:
   id: 4602
 
diff --git a/debian/control b/debian/control
index 88782c3..ea1ab66 100644
--- a/debian/control
+++ b/debian/control
@@ -44,6 +44,8 @@ Suggests:
 	unzip,
 # for 100+ gog.com games
 	innoextract, lgogdownloader,
+# for Quake 1/2/3, Doom, Wolf3d...
+	steam, steamcmd,
 # for Doom3
 	p7zip-full,
 # for Jedi Academy (demo), Arx Fatalis
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index a552e86..269ba50 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -1976,7 +1976,7 @@ class PackagingTask(object):
         try:
             ready = self.prepare_packages(packages,
                     build_demos=args.demo, download=args.download,
-                    log_immediately=bool(args.packages))
+                    search=args.search, log_immediately=bool(args.packages))
         except NoPackagesPossible:
             logger.error('Unable to complete any packages.')
             if self.missing_tools:
@@ -2107,12 +2107,13 @@ class PackagingTask(object):
         return self._architecture
 
     def prepare_packages(self, packages=None, build_demos=False, download=True,
-            log_immediately=True):
+            search=True, log_immediately=True):
         if packages is None:
             packages = self.game.packages.values()
 
         possible = set()
         possible_with_lgogdownloader = set()
+        possible_with_steamcmd = set()
 
         if self.cd_device is not None:
             rip_cd_packages = self.rip_cd_packages & packages
@@ -2128,6 +2129,7 @@ class PackagingTask(object):
 
         for package in packages:
             gog_id = self.game.gog_download_name(package)
+            steam_id = package.steam.get('id') or self.game.steam.get('id')
             if package.rip_cd and not self.cd_tracks.get(package.name):
                 logger.debug('no CD tracks found for %s', package.name)
             elif self.fill_gaps(package,
@@ -2146,6 +2148,17 @@ class PackagingTask(object):
                     possible_with_lgogdownloader.add(package.name)
                 else:
                     self.missing_tools.add('innoextract')
+            # don't download "http://steamcommunity.com/profiles/<steam_id>/games?xml=1"
+            # if downloads are disabled
+            elif steam_id and download and search and which('steamcmd'):
+                # avoid import loop
+                from .steam import (owned_steam_games,get_steam_account)
+                for g in owned_steam_games():
+                    if steam_id == g[0]:
+                        logger.info('%s can be downloaded with steamcmd', package.name)
+                        possible.add(package)
+                        possible_with_steamcmd.add(package.name)
+                        break
             else:
                 logger.debug('%s is impossible', package.name)
 
@@ -2281,12 +2294,14 @@ class PackagingTask(object):
 
         ready = set()
         lgogdownloaded = set()
+        steam_password = None
 
+        external_download = possible_with_lgogdownloader | possible_with_steamcmd
         for package in possible:
             logger.debug('will produce %s', package.name)
             result = self.fill_gaps(package=package, download=download,
-              log=package.name not in possible_with_lgogdownloader,
-              recheck=package.name in possible_with_lgogdownloader)
+              log=package.name not in external_download,
+              recheck=package.name in external_download)
             if result is FillResult.COMPLETE:
                 ready.add(package)
             elif download and package.name in possible_with_lgogdownloader:
@@ -2333,6 +2348,33 @@ class PackagingTask(object):
                                 pass
                 except subprocess.CalledProcessError:
                     pass
+            elif package.name in possible_with_steamcmd:
+                steam_id = package.steam.get('id') or self.game.steam.get('id')
+                steam_account = get_steam_account()
+                if not steam_password:
+                    import getpass
+                    steam_password = getpass.getpass("Please provided password"
+                                                     " for Steam account %s:" %
+                                                      steam_account)
+                # this should be guessed automatically like for GOG
+                # and not needed to be encoded in individual YAML files
+                if package.steam.get('native') or self.game.steam.get('native'):
+                    platform = []
+                else:
+                    platform = ['+ at sSteamCmdForcePlatformType', 'windows']
+
+                try:
+                    check_call(['steamcmd'] + platform + [
+                                '+login', steam_account, steam_password,
+                                '+app_update', '%s' % steam_id, 'validate',
+                                '+quit'])
+                except subprocess.CalledProcessError:
+                    pass
+                for path in set(self.iter_steam_paths(packages=(package,))):
+                    self.consider_file_or_dir(path)
+                if self.fill_gaps(package, log=True, download=True,
+                    recheck=True) is not FillResult.IMPOSSIBLE:
+                    ready.add(package)
             elif (result is FillResult.DOWNLOAD_NEEDED or
                   package.name in possible_with_lgogdownloader) and not download:
                 logger.warning('As requested, not downloading necessary ' +
diff --git a/game_data_packager/games/lgeneral.py b/game_data_packager/games/lgeneral.py
index d99ad84..fdda483 100644
--- a/game_data_packager/games/lgeneral.py
+++ b/game_data_packager/games/lgeneral.py
@@ -40,7 +40,7 @@ class LGeneralGameData(GameData):
 
 class LGeneralTask(PackagingTask):
     def prepare_packages(self, packages, build_demos=False, download=True,
-                    log_immediately=True):
+                    search=True, log_immediately=True):
         # don't bother even trying if it isn't going to work
         if which('lgc-pg') is None:
             logger.error('The "lgc-pg" tool is required for this package.')
diff --git a/game_data_packager/steam.py b/game_data_packager/steam.py
index 7c04ef3..4b36d8a 100644
--- a/game_data_packager/steam.py
+++ b/game_data_packager/steam.py
@@ -87,6 +87,15 @@ def get_steam_id():
             if line not in ('users', '{'):
                 return line
 
+def get_steam_account():
+    path = os.path.expanduser('~/.steam/config/loginusers.vdf')
+    if not os.path.isfile(path):
+        return None
+    with open(path, 'r', ) as data:
+        for line in data.readlines():
+            if 'AccountName' in line:
+                return line.split('"')[-2]
+
 def run_steam_meta_mode(args, games):
     logger.info('Visit our community page: https://steamcommunity.com/groups/debian_gdp#curation')
     owned = set()

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