From 08c610afa286a33ec9edee44838938ed877a049b Mon Sep 17 00:00:00 2001 From: breakgimme Date: Sat, 21 Sep 2024 04:11:31 +0200 Subject: [PATCH] user/openttd: new package --- user/openttd-locale | 1 + user/openttd/patches/musl-random.patch | 20 ++++++++++++++ user/openttd/patches/no-sse4.patch | 14 ++++++++++ user/openttd/patches/redefs-fix.patch | 10 +++++++ user/openttd/template.py | 38 ++++++++++++++++++++++++++ user/openttd/update.py | 2 ++ 6 files changed, 85 insertions(+) create mode 120000 user/openttd-locale create mode 100644 user/openttd/patches/musl-random.patch create mode 100644 user/openttd/patches/no-sse4.patch create mode 100644 user/openttd/patches/redefs-fix.patch create mode 100644 user/openttd/template.py create mode 100644 user/openttd/update.py diff --git a/user/openttd-locale b/user/openttd-locale new file mode 120000 index 0000000000..550b7b6222 --- /dev/null +++ b/user/openttd-locale @@ -0,0 +1 @@ +openttd \ No newline at end of file diff --git a/user/openttd/patches/musl-random.patch b/user/openttd/patches/musl-random.patch new file mode 100644 index 0000000000..bdec49e1ba --- /dev/null +++ b/user/openttd/patches/musl-random.patch @@ -0,0 +1,20 @@ +--- a/src/core/random_func.cpp ++++ b/src/core/random_func.cpp +@@ -26,7 +26,7 @@ + # include + #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) + // No includes required. +-#elif defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 25))) ++#elif defined(__linux__) + # include + #elif defined(__EMSCRIPTEN__) + # include +@@ -100,7 +100,7 @@ + #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) + arc4random_buf(buf.data(), buf.size()); + return; +-#elif defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 25))) ++#elif defined(__linux__) + auto res = getrandom(buf.data(), buf.size(), 0); + if (res > 0 && static_cast(res) == buf.size()) return; + #elif defined(__EMSCRIPTEN__) diff --git a/user/openttd/patches/no-sse4.patch b/user/openttd/patches/no-sse4.patch new file mode 100644 index 0000000000..d373e1416e --- /dev/null +++ b/user/openttd/patches/no-sse4.patch @@ -0,0 +1,14 @@ +Patch-Source: https://git.alpinelinux.org/aports/tree/testing/openttd/no-sse4.patch?id=631059433ebe8b46a288746a64d4ab1699be1558 +this sets the sources to use sse4 instructions, which is above our baseline. +it also enables sse4 on pure-x86 with our builds, so best to disable +--- a/cmake/FindSSE.cmake ++++ b/cmake/FindSSE.cmake +@@ -12,6 +12,7 @@ + #include + #include + #include +- int main() { return 0; }" ++ # die! ++ int main() { *(int *)0 = 0; }" + SSE_FOUND + ) diff --git a/user/openttd/patches/redefs-fix.patch b/user/openttd/patches/redefs-fix.patch new file mode 100644 index 0000000000..a36b27c6e4 --- /dev/null +++ b/user/openttd/patches/redefs-fix.patch @@ -0,0 +1,10 @@ +--- a/cmake/CompileFlags.cmake ++++ b/cmake/CompileFlags.cmake +@@ -30,7 +30,6 @@ + # it does not appear to support the $<> tags. + add_compile_options( + "$<$:-D_DEBUG>" +- "$<$>:-D_FORTIFY_SOURCE=2>" # FORTIFY_SOURCE should only be used in non-debug builds (requires -O1+) + ) + if(MINGW) + add_link_options( diff --git a/user/openttd/template.py b/user/openttd/template.py new file mode 100644 index 0000000000..aa9d4692e2 --- /dev/null +++ b/user/openttd/template.py @@ -0,0 +1,38 @@ +pkgname = "openttd" +pkgver = "14.1" +pkgrel = 0 +build_style = "cmake" +hostmakedepends = ["cmake", "ninja", "pkgconf"] +makedepends = [ + "fluidsynth-devel", + "fontconfig-devel", + "freetype-devel", + "harfbuzz-devel", + "libcurl-devel", + "libpng-devel", + "lzo-devel", + "icu-devel", + "sdl-devel", + "xz-devel", + "zlib-ng-devel", +] +pkgdesc = "Simulation game based upon Transport Tycoon Deluxe" +maintainer = "breakgimme " +license = "GPL-2.0-or-later" +url = "https://openttd.org" +source = f"https://cdn.openttd.org/openttd-releases/{pkgver}/openttd-{pkgver}-source.tar.xz" +sha256 = "2c14c8f01f44148c4f2c88c169a30abcdb002eb128a92b9adb76baa76b013494" +# SetBitIterator tests (src/tests/bitmath_func.cpp) fail with int enabled (and the game crashes when the tests are skipped) +hardening = ["!int"] +# can't cross compile due to https://github.com/OpenTTD/OpenTTD/issues/8249 +options = ["!cross"] + + +def check(self): + self.do("./build/openttd_test") + + +@subpackage("openttd-locale") +def _(self): + self.install_if = [self.parent, "base-locale"] + return ["usr/share/games/openttd/lang/*[!english]*.lng"] diff --git a/user/openttd/update.py b/user/openttd/update.py new file mode 100644 index 0000000000..8854855688 --- /dev/null +++ b/user/openttd/update.py @@ -0,0 +1,2 @@ +url = "https://cdn.openttd.org/openttd-releases/latest.yaml" +pattern = r"version:\s*([\d.]+)"