From c70133193be8b443aee840718355e5da1a103d39 Mon Sep 17 00:00:00 2001 From: eroen Date: Wed, 31 Aug 2016 15:58:30 +0200 Subject: steam.eclass - new eclass Steam fetching logic moved from morrowind-data ebuild --- games-rpg/morrowind-data/files/steam-mail.py | 47 --------- .../morrowind-data/morrowind-data-9999.ebuild | 112 +-------------------- 2 files changed, 5 insertions(+), 154 deletions(-) delete mode 100644 games-rpg/morrowind-data/files/steam-mail.py (limited to 'games-rpg') diff --git a/games-rpg/morrowind-data/files/steam-mail.py b/games-rpg/morrowind-data/files/steam-mail.py deleted file mode 100644 index 51bebab0..00000000 --- a/games-rpg/morrowind-data/files/steam-mail.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python - -# By eroen , 2016 -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. - -from __future__ import print_function - -from imaplib import IMAP4_SSL -import re -import sys - - -SERVER = sys.stdin.readline().strip() -USER = sys.stdin.readline().strip() -PASS = sys.stdin.readline().strip() - -if len(SERVER) * len(USER) * len(PASS) <= 0: - print('server, username, and password separated by newlines must be ' - 'supplied on stdin', file=sys.stderr) - sys.exit(1) - -print('conncting to "{}"'.format(SERVER), file=sys.stderr) -M = IMAP4_SSL(SERVER) -# M.enable('UTF8=ACCEPT') -# print(M.capabilities) -print('authenticating', file=sys.stderr) -M.authenticate('PLAIN', lambda response: b'\0' + USER.encode() + b'\0' + - PASS.encode()) -M.select('INBOX') -typ, data = M.search(None, '(FROM "Steam Support")') -index = data[0].split()[-1] -print('found message "{}"'.format(index.decode()), file=sys.stderr) -typ, data = M.fetch(index, '(RFC822)') -message = data[0][1].splitlines() -# print(message) - -r = re.compile(b'Date: ') -date = [l.decode('utf8') for l in message if r.match(l)] -print('message date: "{}"'.format(date[0][6:]), file=sys.stderr) - -r = re.compile(b'[A-Z1-9]{5}$') -keys = [l.decode('utf8') for l in message if r.match(l)] -print(keys[0]) - -M.logout() diff --git a/games-rpg/morrowind-data/morrowind-data-9999.ebuild b/games-rpg/morrowind-data/morrowind-data-9999.ebuild index f2fe9a68..19cbf34d 100644 --- a/games-rpg/morrowind-data/morrowind-data-9999.ebuild +++ b/games-rpg/morrowind-data/morrowind-data-9999.ebuild @@ -6,15 +6,12 @@ EAPI=6 -PYTHON_COMPAT=(python2_7 python3_3 python3_4 python3_5) -PYTHON_REQ_USE="ssl" #CHECKREQS_DISK_BUILD="1140M" - -inherit eutils linux-info python-any-r1 +inherit steam DESCRIPTION="Data files for Morrowind" HOMEPAGE="http://www.elderscrolls.com" -SRC_URI="https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" +SRC_URI="" LICENSE="all-rights-reserved Morrowind-EULA" RESTRICT="bindist mirror" @@ -22,110 +19,11 @@ SLOT="0" KEYWORDS="" # -* ~amd64 ~x86 IUSE="" -DEPEND="${PYTHON_DEPS} - sys-devel/gcc[cxx] - amd64? ( sys-devel/gcc[cxx,multilib] )" +DEPEND="" RDEPEND="" -STEAM_app_id=22320 # See https://steamdb.info -STEAM_platform=windows # linux, macos, or windows - -steam_pkg_setup() { - # CONFIG_PAX_ELFRELOCS must not be disabled (if present). - # Textrels are all over the place :( - if linux_config_exists; then - if [[ -n $(linux_chkconfig_string PAX_ELFRELOCS) ]] && \ - ! linux_chkconfig_present PAX_ELFRELOCS; then - die "Need support for x86 TEXTRELs" - fi - else - ewarn "Could not find kernel config. The install will fail later if" - ewarn "x86 TEXTRELs are not supported on the system." - fi - - : ${STEAM_CREDS:=/etc/portage/creds_steam} - if [[ $MERGE_TYPE != binary && ! -r $STEAM_CREDS ]]; then - die "\$STEAM_CREDS=$STEAM_CREDS is not readable" - fi - - if [[ -z $STEAM_app_id ]]; then - die "\$STEAM_app_id is not set" - fi - - python-any-r1_pkg_setup -} - -pkg_setup() { steam_pkg_setup; } - -steam_get_cred() { - [[ -n $1 ]] || die "$FUNCNAME - no argument passed" - awk "/^${1^^}: /{print \$2}" "$STEAM_CREDS" || die -} - -steam_get_mail() { - printf "%s\n%s\n%s\n" \ - "$(steam_get_cred MAIL_SERVER)" \ - "$(steam_get_cred MAIL_USER)" \ - "$(steam_get_cred MAIL_PASS)" \ - | ${EPYTHON} "$FILESDIR"/steam-mail.py -} - -esteamcmd() { - # Supply password on stdin to avoid leaking it in /proc/$pid/cmdline - printf "%s\n" "$(steam_get_cred STEAM_PASS)" \ - | ./steamcmd.sh \ - "+@ShutdownOnFailedCommand 1" \ - "+@NoPromptForPassword 0" \ - "+login $(steam_get_cred STEAM_USER)" \ - "$@" \ - "+quit" || die -n "Error $? in $FUNCNAME $*" -} - -steam_firstlogin() { - # make steam up to date - einfo "Update steam" - ./steamcmd.sh "+quit" || die "unable to run steamcmd.sh" - - # generate 'special access code' - einfo "Attempt to log in, generate special access code email" - printf "%s\n" "$(steam_get_cred STEAM_PASS)" \ - | ./steamcmd.sh "+login $(steam_get_cred STEAM_USER)" "+quit" - if [[ $? == 5 ]]; then - local i imax=5 - for (( i=1; i<=imax; i++ )); do - # supply 'special access code' - einfo "Supply special access code, attempt $i of $imax" - printf "%s\n" "$(steam_get_cred STEAM_PASS)" \ - | ./steamcmd.sh "+set_steam_guard_code $(steam_get_mail)" \ - "+login $(steam_get_cred STEAM_USER)" \ - "+quit" && break - - (( i < 5 )) || die "Unable to log in" - sleep 10 - done - fi - - # verify we can log in - einfo "Verify we can log in" - esteamcmd -} - -steam_src_unpack() { - default - steam_firstlogin - - local cmd_platform= - [[ -n $STEAM_platform ]] && cmd_platform="+@sSteamCmdForcePlatformType ${STEAM_platform}" - - # fetch our thing to $S - einfo "Install app_id ${STEAM_app_id}" - esteamcmd \ - "$cmd_platform" \ - "+force_install_dir ${S}" \ - "+app_update ${STEAM_app_id}" -} - -src_unpack() { steam_src_unpack; } +STEAM_app_id=22320 +STEAM_platform=windows src_install() { insinto /usr/share/morrowind-data -- cgit v1.2.1