src_prepare-overlay/eclass/gog.eclass

80 lines
2.4 KiB
Bash
Raw Normal View History

2020-04-18 19:35:09 +02:00
# Copyright 2020-2020 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: gog.eclass
# @MAINTAINER:
# moog621@gmail.com
# @AUTHOR:
# moog621@gmail.com
# @SUPPORTED_EAPIS: 7
# @BLURB: Functions for interacting with GOG API.
# @DESCRIPTION:
# Sets GOG_GAME_* variables for use with games that can be obtained from GOG.
# Additionally, some games are not available on all platforms. ebuilds are
# allowed to prefer a platform that works best with the host platform.
# However, GOG probably supplies only x86 binaries for Linux, Mac and Windows.
# It is up to the ebuild to enable and offer other alternate avenues to support
# a particular game.
2020-04-21 04:46:29 +02:00
# In order to disable network-sandbox:
PROPERTIES+="live"
2020-04-18 19:35:09 +02:00
# @ECLASS-VARIABLE: GOG_GAME_NAME
# @DESCRIPTION:
# Name of the game as it appears in lgogdownloader list.
: ${GOG_GAME_NAME:=}
# @ECLASS-VARIABLE: GOG_GAME_L10N
# @DESCRIPTION:
# Languages available for the game.
: ${GOG_GAME_L10N:=()}
# @ECLASS-VARIABLE: GOG_GAME_PLATFORM
# @DESCRIPTION:
# This choice specifies which binaries, for which platform, will be downloaded from GOG.
# Sometimes, this can be irrelevant, as unofficial platform binaries may come from 3rd
# party sources.
: ${GOG_GAME_PLATFORM:=}
# @ECLASS-VARIABLE: GOG_GAME_INSTALLER
# @DESCRIPTION:
# Filename of the installer. There can be many, as some games support each language
# through separate installers.
: ${GOG_GAME_INSTALLER:=()}
2020-04-21 04:46:29 +02:00
LICENSE+="GOG_EULA"
2020-04-18 19:35:09 +02:00
BDEPEND+="
games-util/lgogdownloader[portage]
2020-04-21 04:46:29 +02:00
app-arch/innoextract
"
2020-04-18 19:35:09 +02:00
gog_sanity_check() {
portageq envvar GOG_CONFIG >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
die "Please define GOG_CONFIG in /etc/portage/make.conf as the output of export_gog_to_portage."
fi
}
gog_initialize() {
gog_sanity_check
mkdir -p ~/.config
echo ${GOG_CONFIG} | base64 -d | tar -Jxf - -C ~
}
# @FUNCTION: gog_download_installer
# @DESCRIPTION:
# Downloads the offline installer of a specified game, with specified language, for the specified platform.
gog_download_installer() {
lgogdownloader --no-platform-detection --download --game ${GOG_GAME_NAME} --exclude extras --language ${GOG_GAME_L10N} --platform ${GOG_GAME_PLATFORM} >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
die "lgogdownloader failed. Please make sure it works."
fi
}
# @FUNCTION: gog_extract_installer
# @DESCRIPTION:
# Extracts the installer of specified filename.
gog_extract_installer() {
innoextract -e ${GOG_GAME_INSTALLER}
}