From 4900137dde22ca34250c4de54fb1d2ec3e569170 Mon Sep 17 00:00:00 2001 From: Vadim Misbakh-Soloviov Date: Tue, 16 Jan 2024 11:21:43 +0700 Subject: games-strategy/unknown-horizons: fix build Closes: https://bugs.gentoo.org/905123 Signed-off-by: Vadim Misbakh-Soloviov --- .../unknown-horizons/files/json_decoder.patch | 8 +++ .../unknown-horizons/files/python-3.8.patch | 19 +++++++ .../unknown-horizons/files/unitmanager.patch | 20 +++++++ .../unknown-horizons/files/util_preloader.patch | 14 +++++ games-strategy/unknown-horizons/metadata.xml | 14 ++--- .../unknown-horizons-2019.1-r1.ebuild | 66 ++++++++++++++++++++++ .../unknown-horizons-2019.1.ebuild | 53 ----------------- 7 files changed, 134 insertions(+), 60 deletions(-) create mode 100644 games-strategy/unknown-horizons/files/json_decoder.patch create mode 100644 games-strategy/unknown-horizons/files/python-3.8.patch create mode 100644 games-strategy/unknown-horizons/files/unitmanager.patch create mode 100644 games-strategy/unknown-horizons/files/util_preloader.patch create mode 100644 games-strategy/unknown-horizons/unknown-horizons-2019.1-r1.ebuild delete mode 100644 games-strategy/unknown-horizons/unknown-horizons-2019.1.ebuild diff --git a/games-strategy/unknown-horizons/files/json_decoder.patch b/games-strategy/unknown-horizons/files/json_decoder.patch new file mode 100644 index 0000000..bb355a4 --- /dev/null +++ b/games-strategy/unknown-horizons/files/json_decoder.patch @@ -0,0 +1,8 @@ +--- a/horizons/util/loaders/jsondecoder.py 2019-01-12 16:15:42.000000000 +0100 ++++ b/horizons/util/loaders/jsondecoder.py 2022-09-04 02:23:14.570074926 +0200 +@@ -37,4 +37,4 @@ + return newdict + + with open(path, "r") as f: +- return json.load(f, encoding="ascii", object_hook=_decode_dict) ++ return json.loads(f.read().encode("ascii"), object_hook=_decode_dict) diff --git a/games-strategy/unknown-horizons/files/python-3.8.patch b/games-strategy/unknown-horizons/files/python-3.8.patch new file mode 100644 index 0000000..f994250 --- /dev/null +++ b/games-strategy/unknown-horizons/files/python-3.8.patch @@ -0,0 +1,19 @@ +--- a/setup.py 2022-09-01 12:49:18.429156294 +0200 ++++ b/setup.py 2022-09-01 12:55:09.679161589 +0200 +@@ -26,6 +26,7 @@ + import json + import os + import platform ++import distro + import sys + from distutils.command.build import build + from distutils.core import setup +@@ -39,7 +40,7 @@ + # Ensure we are in the correct directory + os.chdir(os.path.realpath(os.path.dirname(__file__))) + +-if platform.dist()[0].lower() in ('debian', 'ubuntu'): ++if distro.id().lower() in ('debian', 'ubuntu'): + executable_path = 'games' + else: + executable_path = 'bin' diff --git a/games-strategy/unknown-horizons/files/unitmanager.patch b/games-strategy/unknown-horizons/files/unitmanager.patch new file mode 100644 index 0000000..901ea64 --- /dev/null +++ b/games-strategy/unknown-horizons/files/unitmanager.patch @@ -0,0 +1,20 @@ +--- a/horizons/ai/aiplayer/combat/unitmanager.py 2019-01-12 16:15:42.000000000 +0100 ++++ b/horizons/ai/aiplayer/combat/unitmanager.py 2022-09-04 03:17:12.660088944 +0200 +@@ -151,7 +151,7 @@ + """ + Rule stating that ship has to be in any of given states. + """ +- if not isinstance(ship_states, collections.Iterable): ++ if not isinstance(ship_states, collections.abc.Iterable): + ship_states = (ship_states,) + return lambda ship: (state_dict[ship] in ship_states) + +@@ -178,7 +178,7 @@ + @param rules: conditions each ship has to meet (AND) + @type rules: iterable of lambda(ship) or single lambda(ship) + """ +- if not isinstance(rules, collections.Iterable): ++ if not isinstance(rules, collections.abc.Iterable): + rules = (rules,) + return [ship for ship in ships if all((rule(ship) for rule in rules))] + diff --git a/games-strategy/unknown-horizons/files/util_preloader.patch b/games-strategy/unknown-horizons/files/util_preloader.patch new file mode 100644 index 0000000..c584f26 --- /dev/null +++ b/games-strategy/unknown-horizons/files/util_preloader.patch @@ -0,0 +1,14 @@ +--- a/horizons/util/preloader.py 2019-01-12 16:15:42.000000000 +0100 ++++ b/horizons/util/preloader.py 2022-09-04 02:18:05.000073586 +0200 +@@ -79,9 +79,9 @@ + """ + self.lock.acquire() + # wait until it finished its current action +- if self.isAlive(): ++ if self.is_alive(): + self.join() +- assert not self.isAlive() ++ assert not self.is_alive() + else: + try: + self.lock.release() diff --git a/games-strategy/unknown-horizons/metadata.xml b/games-strategy/unknown-horizons/metadata.xml index 7a6f11a..5df3482 100644 --- a/games-strategy/unknown-horizons/metadata.xml +++ b/games-strategy/unknown-horizons/metadata.xml @@ -1,11 +1,11 @@ - - totycro@unknown-horizons.org - totycro - - Anno-like real time strategy game - - + + totycro@unknown-horizons.org + totycro + + + unknown-horizons/unknown-horizons + diff --git a/games-strategy/unknown-horizons/unknown-horizons-2019.1-r1.ebuild b/games-strategy/unknown-horizons/unknown-horizons-2019.1-r1.ebuild new file mode 100644 index 0000000..6fcda6a --- /dev/null +++ b/games-strategy/unknown-horizons/unknown-horizons-2019.1-r1.ebuild @@ -0,0 +1,66 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{9..12} ) +DISTUTILS_SINGLE_IMPL=1 +PYTHON_REQ_USE="sqlite" + +inherit distutils-r1 + +DESCRIPTION="Anno-like real time strategy game" +HOMEPAGE="https://www.unknown-horizons.org/" +SRC_URI="https://github.com/${PN}/${PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="GPL-2" +KEYWORDS="~amd64 ~x86" +SLOT="0" +IUSE="test" + +RESTRICT="!test? ( test )" + +RDEPEND=" + dev-python/pyyaml + dev-python/pillow + >=games-engines/fifengine-0.4.2[python] + >=games-engines/fifechan-0.1.5 + ${PYTHON_DEPS} +" +DEPEND=" + ${RDEPEND} + test? ( + dev-python/greenlet + dev-python/polib + dev-python/isort + dev-python/pylint + dev-python/mock + dev-python/nose + dev-python/pycodestyle + ) +" + +REQUIRED_USE="${PYTHON_REQUIRED_USE}" + +PATCHES=( + "${FILESDIR}/python-3.8.patch" + "${FILESDIR}/util_preloader.patch" + "${FILESDIR}/json_decoder.patch" + "${FILESDIR}/unitmanager.patch" +) + +src_test() { + ${PYTHON} ./run_tests.py +} + +src_compile() { + distutils-r1_src_compile build_i18n + chmod +x horizons/engine/generate_atlases.py + horizons/engine/generate_atlases.py 2048 +} + +src_install() { + distutils-r1_src_install + insinto "/usr/share/unknown-horizons/content" + doins "content/atlas.sql" +} diff --git a/games-strategy/unknown-horizons/unknown-horizons-2019.1.ebuild b/games-strategy/unknown-horizons/unknown-horizons-2019.1.ebuild deleted file mode 100644 index 9bea365..0000000 --- a/games-strategy/unknown-horizons/unknown-horizons-2019.1.ebuild +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 1999-2023 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -PYTHON_COMPAT=( python3_{9..11} ) -DISTUTILS_SINGLE_IMPL=1 -PYTHON_REQ_USE="sqlite" - -inherit distutils-r1 - -DESCRIPTION="Anno-like real time strategy game" -HOMEPAGE="https://www.unknown-horizons.org/" -SRC_URI="https://github.com/${PN}/${PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz" - -LICENSE="GPL-2" -KEYWORDS="~amd64 ~x86" -SLOT="0" -IUSE="test" - -RDEPEND=" - dev-python/pyyaml - dev-python/pillow - >=games-engines/fifengine-0.4.2[python] - >=games-engines/fifechan-0.1.5 - ${PYTHON_DEPS} -" -DEPEND=" - ${RDEPEND} - test? ( - dev-python/greenlet - dev-python/polib - dev-python/isort - dev-python/pylint - dev-python/mock - dev-python/nose - dev-python/pycodestyle - ) -" - -REQUIRED_USE="${PYTHON_REQUIRED_USE}" - -src_test() { - ${PYTHON} ./run_tests.py -} - -src_compile() { - distutils-r1_src_compile build_i18n -} - -src_install() { - distutils-r1_src_install -} -- cgit v1.2.3-65-gdbad