From d18bfe48f2199be56983e1cd22d90fa4d9a94500 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Sat, 28 Sep 2024 19:58:58 +0100 Subject: games-strategy/ufoai: Patch to use MXML 4, EAPI 8 Closes: https://bugs.gentoo.org/930524 Signed-off-by: James Le Cuirot --- .../ufoai/files/ufoai-2.5.0_p20180603-mxml3.patch | 29 --- .../ufoai/files/ufoai-2.5.0_p20180603-mxml4.patch | 210 +++++++++++++++++++++ .../ufoai/ufoai-2.5.0_p20180603-r2.ebuild | 136 ------------- .../ufoai/ufoai-2.5.0_p20180603-r3.ebuild | 136 +++++++++++++ 4 files changed, 346 insertions(+), 165 deletions(-) delete mode 100644 games-strategy/ufoai/files/ufoai-2.5.0_p20180603-mxml3.patch create mode 100644 games-strategy/ufoai/files/ufoai-2.5.0_p20180603-mxml4.patch delete mode 100644 games-strategy/ufoai/ufoai-2.5.0_p20180603-r2.ebuild create mode 100644 games-strategy/ufoai/ufoai-2.5.0_p20180603-r3.ebuild (limited to 'games-strategy/ufoai') diff --git a/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-mxml3.patch b/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-mxml3.patch deleted file mode 100644 index 256b43e94b2c..000000000000 --- a/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-mxml3.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 163073ab9527cdaa33d77a713b8e46ff462a2b5c Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Tam=C3=A1s=20Feh=C3=A9rv=C3=A1ri?= - -Date: Sat, 3 Aug 2019 15:21:05 +0200 -Subject: [PATCH] * {{Bug|5739}} MiniXML (mxml) 3.x compatibility - ---- - src/common/xml.cpp | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/src/common/xml.cpp b/src/common/xml.cpp -index 7aeceb3a29..5a66ccc887 100644 ---- a/src/common/xml.cpp -+++ b/src/common/xml.cpp -@@ -509,8 +509,13 @@ static mxml_type_t mxml_ufo_type_cb (xmlNode_t* node) - /* You can lookup attributes and/or use the - * element name, hierarchy, etc... */ - const char* type = mxmlElementGetAttr(node, "type"); -- if (type == nullptr) -+ if (type == nullptr) { -+#ifdef MXML_MAJOR_VERSION -+ type = mxmlGetElement(node); -+#else - type = node->value.element.name; -+#endif -+ } - - if (Q_streq(type, "int")) - return MXML_INTEGER; diff --git a/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-mxml4.patch b/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-mxml4.patch new file mode 100644 index 000000000000..c45a3682b776 --- /dev/null +++ b/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-mxml4.patch @@ -0,0 +1,210 @@ +diff --git a/build/default.mk b/build/default.mk +index 38ecea4627..f598425394 100644 +--- a/build/default.mk ++++ b/build/default.mk +@@ -232,8 +232,8 @@ VORBIS_CFLAGS ?= $(call PKG_CFLAGS,vorbis) + VORBIS_LIBS ?= $(call PKG_LIBS,vorbis) + OGG_CFLAGS ?= $(call PKG_CFLAGS,ogg) + OGG_LIBS ?= $(call PKG_LIBS,ogg) +-MXML_CFLAGS ?= $(call PKG_CFLAGS,mxml) +-MXML_LIBS ?= $(call PKG_LIBS,mxml) ++MXML_CFLAGS ?= $(call PKG_CFLAGS,mxml4) ++MXML_LIBS ?= $(call PKG_LIBS,mxml4) + PICOMODEL_CFLAGS ?= $(call PKG_CFLAGS,picomodel) + PICOMODEL_LIBS ?= $(call PKG_LIBS,picomodel) + INTL_LIBS ?= +@@ -248,16 +248,16 @@ endif + MUMBLE_LIBS ?= + MUMBLE_SRCS = libs/mumble/libmumblelink.c + MUMBLE_CFLAGS = -Isrc/libs/mumble +-ifndef HAVE_MXML_MXML_H ++ifndef HAVE_MXML4_MXML_H + MXML_SRCS = libs/mxml/mxml-attr.c \ +- libs/mxml/mxml-entity.c \ + libs/mxml/mxml-file.c \ ++ libs/mxml/mxml-get.c \ + libs/mxml/mxml-index.c \ + libs/mxml/mxml-node.c \ ++ libs/mxml/mxml-options.c \ + libs/mxml/mxml-private.c \ + libs/mxml/mxml-search.c \ +- libs/mxml/mxml-set.c \ +- libs/mxml/mxml-string.c ++ libs/mxml/mxml-set.c + MXML_CFLAGS = -Isrc/libs/mxml + MXML_LIBS = + ifeq ($(findstring $(TARGET_OS), mingw32 mingw64),) +diff --git a/configure b/configure +index e1dc2610be..fed7a5247b 100755 +--- a/configure ++++ b/configure +@@ -205,7 +205,7 @@ check_headers() { + check_header "zlib.h" "zlib" + check_header "png.h" "libpng" + check_header "CUnit/Basic.h" +- check_header "mxml.h" "mxml" ++ check_header "mxml.h" "mxml4" + check_header "SDL.h" "sdl" + check_header "SDL_mixer.h" "SDL_mixer" + check_header "SDL_ttf.h" "SDL_ttf" +diff --git a/src/client/cgame/campaign/cp_save.cpp b/src/client/cgame/campaign/cp_save.cpp +index 70b3887e45..2824977891 100644 +--- a/src/client/cgame/campaign/cp_save.cpp ++++ b/src/client/cgame/campaign/cp_save.cpp +@@ -249,11 +249,11 @@ static bool SAV_GameSave (const char* filename, const char* comment, char** erro + { + xmlNode_t* topNode, *node; + char savegame[MAX_OSPATH]; ++ char* buf; + int res; + int requiredBufferLength; + uLongf bufLen; + saveFileHeader_t header; +- char dummy[2]; + int i; + dateLong_t date; + char message[30]; +@@ -308,19 +308,16 @@ static bool SAV_GameSave (const char* filename, const char* comment, char** erro + date.year, Date_GetMonthName(date.month - 1), date.day); + Q_strncpyz(header.realDate, timeStampBuffer, sizeof(header.realDate)); + +- requiredBufferLength = mxmlSaveString(topNode, dummy, 2, MXML_NO_CALLBACK); +- +- header.xmlSize = LittleLong(requiredBufferLength); +- byte* const buf = Mem_PoolAllocTypeN(byte, requiredBufferLength + 1, cp_campaignPool); ++ buf = mxmlSaveAllocString(topNode, nullptr); ++ mxmlDelete(topNode); + if (!buf) { +- mxmlDelete(topNode); + *error = _("Could not allocate enough memory to save this game"); + Com_Printf("Error: Could not allocate enough memory to save this game\n"); + return false; + } +- res = mxmlSaveString(topNode, (char*)buf, requiredBufferLength + 1, MXML_NO_CALLBACK); +- mxmlDelete(topNode); +- Com_Printf("XML Written to buffer (%d Bytes)\n", res); ++ requiredBufferLength = strlen(buf) + 1; ++ header.xmlSize = LittleLong(requiredBufferLength); ++ Com_Printf("XML Written to buffer (%d Bytes)\n", requiredBufferLength); + + if (header.compressed) + bufLen = compressBound(requiredBufferLength); +@@ -331,8 +328,8 @@ static bool SAV_GameSave (const char* filename, const char* comment, char** erro + memcpy(fbuf, &header, sizeof(header)); + + if (header.compressed) { +- res = compress(fbuf + sizeof(header), &bufLen, buf, requiredBufferLength); +- Mem_Free(buf); ++ res = compress(fbuf + sizeof(header), &bufLen, (byte*) buf, requiredBufferLength); ++ free(buf); + + if (res != Z_OK) { + Mem_Free(fbuf); +@@ -342,7 +339,7 @@ static bool SAV_GameSave (const char* filename, const char* comment, char** erro + } + } else { + memcpy(fbuf + sizeof(header), buf, requiredBufferLength); +- Mem_Free(buf); ++ free(buf); + } + + /* last step - write data */ +diff --git a/src/client/cgame/cl_game_team.cpp b/src/client/cgame/cl_game_team.cpp +index 94274e74b4..f37c9ad93e 100644 +--- a/src/client/cgame/cl_game_team.cpp ++++ b/src/client/cgame/cl_game_team.cpp +@@ -223,7 +223,7 @@ static bool GAME_SaveTeam (const char* filename, const char* name) + { + int requiredBufferLength; + teamSaveFileHeader_t header; +- char dummy[2]; ++ char* buf; + int i; + xmlNode_t* topNode, *node, *snode; + equipDef_t* ed = GAME_GetEquipmentDefinition(); +@@ -248,26 +248,22 @@ static bool GAME_SaveTeam (const char* filename, const char* name) + XML_AddIntValue(ssnode, SAVE_TEAM_NUMLOOSE, ed->numItemsLoose[od->idx]); + } + } +- requiredBufferLength = mxmlSaveString(topNode, dummy, 2, MXML_NO_CALLBACK); +- /* required for storing compressed */ +- header.xmlSize = LittleLong(requiredBufferLength); +- +- byte* const buf = Mem_PoolAllocTypeN(byte, requiredBufferLength + 1, cl_genericPool); ++ buf = mxmlSaveAllocString(topNode, nullptr); ++ mxmlDelete(topNode); + if (!buf) { +- mxmlDelete(topNode); + Com_Printf("Error: Could not allocate enough memory to save this game\n"); + return false; + } +- mxmlSaveString(topNode, (char*)buf, requiredBufferLength + 1, MXML_NO_CALLBACK); +- mxmlDelete(topNode); ++ requiredBufferLength = strlen(buf) + 1; ++ header.xmlSize = LittleLong(requiredBufferLength); + +- byte* const fbuf = Mem_PoolAllocTypeN(byte, requiredBufferLength + 1 + sizeof(header), cl_genericPool); ++ byte* const fbuf = Mem_PoolAllocTypeN(byte, requiredBufferLength + sizeof(header), cl_genericPool); + memcpy(fbuf, &header, sizeof(header)); +- memcpy(fbuf + sizeof(header), buf, requiredBufferLength + 1); +- Mem_Free(buf); ++ memcpy(fbuf + sizeof(header), buf, requiredBufferLength); ++ free(buf); + + /* last step - write data */ +- FS_WriteFile(fbuf, requiredBufferLength + 1 + sizeof(header), filename); ++ FS_WriteFile(fbuf, requiredBufferLength + sizeof(header), filename); + Mem_Free(fbuf); + + return true; +diff --git a/src/common/xml.cpp b/src/common/xml.cpp +index 1629c90a6a..176846c421 100644 +--- a/src/common/xml.cpp ++++ b/src/common/xml.cpp +@@ -508,33 +508,37 @@ xmlNode_t* XML_GetNode (xmlNode_t* parent, const char* name) + */ + xmlNode_t* XML_GetNextNode (xmlNode_t* current, xmlNode_t* parent, const char* name) + { +- return mxmlFindElement(current, parent, name, nullptr, nullptr, MXML_NO_DESCEND); ++ return mxmlFindElement(current, parent, name, nullptr, nullptr, MXML_DESCEND_NONE); + } + + /** + * @brief callback function for parsing the node tree + */ +-static mxml_type_t mxml_ufo_type_cb (xmlNode_t* node) ++static mxml_type_t mxml_ufo_type_cb (void *cbdata, xmlNode_t* node) + { + /* You can lookup attributes and/or use the + * element name, hierarchy, etc... */ + const char* type = mxmlElementGetAttr(node, "type"); + if (type == nullptr) +- type = node->value.element.name; ++ type = mxmlGetElement(node); + + if (!strcmp(type, "int")) +- return MXML_INTEGER; ++ return MXML_TYPE_INTEGER; + else if (!strcmp(type, "opaque")) +- return MXML_OPAQUE; ++ return MXML_TYPE_OPAQUE; + else if (!strcmp(type, "string")) +- return MXML_OPAQUE; ++ return MXML_TYPE_OPAQUE; + else if (!strcmp(type, "double")) +- return MXML_REAL; ++ return MXML_TYPE_REAL; + else +- return MXML_TEXT; ++ return MXML_TYPE_TEXT; + } + + xmlNode_t* XML_Parse (const char* buffer) + { +- return mxmlLoadString(nullptr, buffer, mxml_ufo_type_cb); ++ mxml_options_t *options = mxmlOptionsNew(); ++ mxmlOptionsSetTypeCallback(options, &mxml_ufo_type_cb, nullptr); ++ xmlNode_t *ret = mxmlLoadString(nullptr, nullptr, buffer); ++ mxmlOptionsDelete(options); ++ return ret; + } diff --git a/games-strategy/ufoai/ufoai-2.5.0_p20180603-r2.ebuild b/games-strategy/ufoai/ufoai-2.5.0_p20180603-r2.ebuild deleted file mode 100644 index b87029251055..000000000000 --- a/games-strategy/ufoai/ufoai-2.5.0_p20180603-r2.ebuild +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -inherit desktop flag-o-matic toolchain-funcs xdg - -# 2.5.0 requires several patches -COMMIT="8b4533e85fdc0665889ff285e1521432084ee784" - -# UFO:AI v2.5.0 was uploaded to SourceForge as 2.5 -DIST_VERSION=$(ver_cut 1-2) - -# Install game data here -DATADIR="/usr/share/${PN}" - -DESCRIPTION="UFO: Alien Invasion - X-COM inspired strategy game" -HOMEPAGE="https://ufoai.org/" -SRC_URI=" - https://dev.gentoo.org/~chewi/distfiles/${PN}-code-${COMMIT}.zip - https://downloads.sourceforge.net/${PN}/${PN}-${DIST_VERSION}-data.tar -" -S="${WORKDIR}/${PN}-code-${COMMIT}" - -# https://ufoai.org/licenses/ -LICENSE="GPL-2 GPL-3 public-domain CC-BY-3.0 CC-BY-SA-3.0 MIT" -SLOT="0" -KEYWORDS="~amd64 ~x86" -IUSE="+client cpu_flags_x86_sse debug server" -REQUIRED_USE="|| ( client server )" - -RDEPEND=" - dev-libs/mxml:0 - net-misc/curl - sys-libs/zlib - - client? ( - media-libs/libogg - media-libs/libpng:0= - media-libs/libsdl2[joystick,opengl,sound,threads,video] - media-libs/libtheora - media-libs/libvorbis - media-libs/sdl2-mixer - media-libs/sdl2-ttf - media-libs/xvid - virtual/jpeg:0 - virtual/opengl - ) - - server? ( - media-libs/libsdl2[threads] - ) -" - -DEPEND=" - ${RDEPEND} - app-arch/unzip - sys-devel/gettext - virtual/pkgconfig -" - -PATCHES=( - "${FILESDIR}"/${P}-install.patch - "${FILESDIR}"/${P}-mxml3.patch -) - -src_unpack() { - unpack ${PN}-code-${COMMIT}.zip - cd "${S}" || die - unpack ${PN}-${DIST_VERSION}-data.tar -} - -src_prepare() { - default - - # Make the build system a bit happier, will be fixed upstream - mkdir -p base/{maps,models} contrib/installer/mojosetup/scripts || die - - # Remove bundled mxml - rm -r src/libs/mxml/ || die -} - -src_configure() { - # Avoid noise, will be present in 2.6 - append-cxxflags -Wno-expansion-to-defined - - # The configure script of UFO:AI is hand crafted and a bit special - # econf does not work: "invalid option --build=x86_64-pc-linux-gnu" - local config=( - --prefix="${EPREFIX}"/usr - --datadir="${EPREFIX}${DATADIR}" - --libdir="${EPREFIX}"/usr/$(get_libdir)/${PN} - --localedir="${EPREFIX}"/usr/share/locale - --disable-paranoid - --disable-memory - --disable-testall - --disable-ufomodel - --disable-ufoslicer - $(use_enable cpu_flags_x86_sse sse) - $(use_enable !debug release) - $(use_enable server ufoded) - $(use_enable client ufo) - --disable-uforadiant - --disable-ufo2map - ) - - if use client || use server; then - config+=( --enable-game ) - else - config+=( --disable-game ) - fi - - echo ./configure "${config[@]}" - - CC="$(tc-getCC)" CXX="$(tc-getCXX)" \ - ./configure "${config[@]}" || die "configure failed" -} - -src_compile() { - emake all lang Q= -} - -src_install() { - newicon -s 32 src/ports/linux/ufo.png ${PN}.png - emake install Q= DESTDIR="${D}" - - if use client; then - doman debian/ufo.6 - make_desktop_entry ufo "UFO: Alien Invasion" ${PN} - fi - - if use server; then - doman debian/ufoded.6 - make_desktop_entry ufoded "UFO: Alien Invasion Server" ${PN} "Game;StrategyGame" "Terminal=true" - fi -} diff --git a/games-strategy/ufoai/ufoai-2.5.0_p20180603-r3.ebuild b/games-strategy/ufoai/ufoai-2.5.0_p20180603-r3.ebuild new file mode 100644 index 000000000000..4a608e33a4d1 --- /dev/null +++ b/games-strategy/ufoai/ufoai-2.5.0_p20180603-r3.ebuild @@ -0,0 +1,136 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit desktop flag-o-matic toolchain-funcs xdg + +# 2.5.0 requires several patches +COMMIT="8b4533e85fdc0665889ff285e1521432084ee784" + +# UFO:AI v2.5.0 was uploaded to SourceForge as 2.5 +DIST_VERSION=$(ver_cut 1-2) + +# Install game data here +DATADIR="/usr/share/${PN}" + +DESCRIPTION="UFO: Alien Invasion - X-COM inspired strategy game" +HOMEPAGE="https://ufoai.org/" +SRC_URI=" + https://dev.gentoo.org/~chewi/distfiles/${PN}-code-${COMMIT}.zip + https://downloads.sourceforge.net/${PN}/${PN}-${DIST_VERSION}-data.tar +" +S="${WORKDIR}/${PN}-code-${COMMIT}" + +# https://ufoai.org/licenses/ +LICENSE="GPL-2 GPL-3 public-domain CC-BY-3.0 CC-BY-SA-3.0 MIT" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="+client cpu_flags_x86_sse debug server" +REQUIRED_USE="|| ( client server )" + +RDEPEND=" + dev-libs/mxml:4 + net-misc/curl + sys-libs/zlib + + client? ( + media-libs/libogg + media-libs/libpng:0= + media-libs/libsdl2[joystick,opengl,sound,threads,video] + media-libs/libtheora + media-libs/libvorbis + media-libs/sdl2-mixer + media-libs/sdl2-ttf + media-libs/xvid + virtual/jpeg:0 + virtual/opengl + ) + + server? ( + media-libs/libsdl2[threads] + ) +" + +DEPEND=" + ${RDEPEND} + app-arch/unzip + sys-devel/gettext + virtual/pkgconfig +" + +PATCHES=( + "${FILESDIR}"/${P}-install.patch + "${FILESDIR}"/${P}-mxml4.patch +) + +src_unpack() { + unpack ${PN}-code-${COMMIT}.zip + cd "${S}" || die + unpack ${PN}-${DIST_VERSION}-data.tar +} + +src_prepare() { + default + + # Make the build system a bit happier, will be fixed upstream + mkdir -p base/{maps,models} contrib/installer/mojosetup/scripts || die + + # Remove bundled mxml + rm -r src/libs/mxml/ || die +} + +src_configure() { + # Avoid noise, will be present in 2.6 + append-cxxflags -Wno-expansion-to-defined + + # The configure script of UFO:AI is hand crafted and a bit special + # econf does not work: "invalid option --build=x86_64-pc-linux-gnu" + local config=( + --prefix="${EPREFIX}"/usr + --datadir="${EPREFIX}${DATADIR}" + --libdir="${EPREFIX}"/usr/$(get_libdir)/${PN} + --localedir="${EPREFIX}"/usr/share/locale + --disable-paranoid + --disable-memory + --disable-testall + --disable-ufomodel + --disable-ufoslicer + $(use_enable cpu_flags_x86_sse sse) + $(use_enable !debug release) + $(use_enable server ufoded) + $(use_enable client ufo) + --disable-uforadiant + --disable-ufo2map + ) + + if use client || use server; then + config+=( --enable-game ) + else + config+=( --disable-game ) + fi + + echo ./configure "${config[@]}" + + CC="$(tc-getCC)" CXX="$(tc-getCXX)" \ + ./configure "${config[@]}" || die "configure failed" +} + +src_compile() { + emake all lang Q= +} + +src_install() { + newicon -s 32 src/ports/linux/ufo.png ${PN}.png + emake install Q= DESTDIR="${D}" + + if use client; then + doman debian/ufo.6 + make_desktop_entry ufo "UFO: Alien Invasion" ${PN} + fi + + if use server; then + doman debian/ufoded.6 + make_desktop_entry ufoded "UFO: Alien Invasion Server" ${PN} "Game;StrategyGame" "Terminal=true" + fi +} -- cgit v1.2.3-65-gdbad