Commit 87b1826b authored by Alexandre Detiste's avatar Alexandre Detiste

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
parent 83f7afe3
......@@ -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/
......
......@@ -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
......
......@@ -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'
......
......@@ -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:
......
......@@ -26,6 +26,7 @@ packages:
steam:
id: 317040
path: common/Strife
native: true
fedora:
engine: chocolate-doom
suse:
......
......@@ -8,6 +8,7 @@ missing_langs: [de,it,pl]
steam:
id: 356210
path: common/TonyTough
native: true
dotemu:
id: 4602
......
......@@ -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
......
......@@ -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 = ['+@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 ' +
......
......@@ -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.')
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment