From 17d9e66641cfdec7bf1a2f97f8d50fd4d93d8435 Mon Sep 17 00:00:00 2001 From: Conrad Kostecki Date: Tue, 12 Apr 2022 22:57:20 +0200 Subject: games-simulation/openttd: add custom attach command Adding a custom attach command, so you can attach yourself with 'dtach' in the interactive console open OpenTTD, when running in server mode. Signed-off-by: Conrad Kostecki --- games-simulation/openttd/files/openttd.confd | 5 - games-simulation/openttd/files/openttd.confd-r1 | 10 ++ games-simulation/openttd/files/openttd.initd-r2 | 16 ---- games-simulation/openttd/files/openttd.initd-r3 | 34 +++++++ games-simulation/openttd/openttd-12.2-r1.ebuild | 121 ++++++++++++++++++++++++ games-simulation/openttd/openttd-12.2.ebuild | 120 ----------------------- 6 files changed, 165 insertions(+), 141 deletions(-) delete mode 100644 games-simulation/openttd/files/openttd.confd create mode 100644 games-simulation/openttd/files/openttd.confd-r1 delete mode 100644 games-simulation/openttd/files/openttd.initd-r2 create mode 100644 games-simulation/openttd/files/openttd.initd-r3 create mode 100644 games-simulation/openttd/openttd-12.2-r1.ebuild delete mode 100644 games-simulation/openttd/openttd-12.2.ebuild (limited to 'games-simulation/openttd') diff --git a/games-simulation/openttd/files/openttd.confd b/games-simulation/openttd/files/openttd.confd deleted file mode 100644 index 399ab5d984c6..000000000000 --- a/games-simulation/openttd/files/openttd.confd +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# Options for your started OpenTTD server -openttd_opts="" diff --git a/games-simulation/openttd/files/openttd.confd-r1 b/games-simulation/openttd/files/openttd.confd-r1 new file mode 100644 index 000000000000..47cae2fda01a --- /dev/null +++ b/games-simulation/openttd/files/openttd.confd-r1 @@ -0,0 +1,10 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# Dtach options, which will used, when the `attach` extra command is called. +# By default, CTRL+D is used, and no signal is send, +# when you want to detach from the attached console. +dtach_opts="-e '^D' -r none" + +# Options for your started OpenTTD server +openttd_opts="" diff --git a/games-simulation/openttd/files/openttd.initd-r2 b/games-simulation/openttd/files/openttd.initd-r2 deleted file mode 100644 index 6a24bbc25072..000000000000 --- a/games-simulation/openttd/files/openttd.initd-r2 +++ /dev/null @@ -1,16 +0,0 @@ -#!/sbin/openrc-run -# Copyright 1999-2022 Gentoo Foundation -# Distributed under the terms of the GNU General Public License, v2 or later - -description="OpenTTD dedicated game server" -pidfile="/run/${SVCNAME}.pid" - -command="/usr/bin/openttd" -command_args="-D ${openttd_opts}" -command_background="true" -command_group="openttd" -command_user="openttd" - -depend() { - need net -} diff --git a/games-simulation/openttd/files/openttd.initd-r3 b/games-simulation/openttd/files/openttd.initd-r3 new file mode 100644 index 000000000000..89680f91d267 --- /dev/null +++ b/games-simulation/openttd/files/openttd.initd-r3 @@ -0,0 +1,34 @@ +#!/sbin/openrc-run +# Copyright 1999-2022 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later + +description="OpenTTD dedicated game server" +dtach_tmpfile="$(mktemp -u)" +name="OpenTTD dedicated game server" +openttd_command="/usr/bin/openttd" +pidfile="/run/${SVCNAME}.pid" + +description_attach="Attaches to the session (interactive console) of the OpenTTD game server" +extra_started_commands="attach" + +command="/usr/bin/dtach" +command_args="-N ${dtach_tmpfile} ${openttd_command} -D ${openttd_opts}" +command_background="true" +command_group="openttd" +command_user="openttd" + +depend() { + need net +} + +attach() { + pidnumber="$(cat ${pidfile})" + dtach_tmpfile="$(cat /proc/${pidnumber}/cmdline | tr '\0' ' ' | awk '{print $3}')" + + if [ -S "${dtach_tmpfile}" ]; then + eval "${command}" -a "${dtach_tmpfile}" "${dtach_opts}" + else + eerror "The determined socket file for dtach could not be found!" + eerror "Did the process crash?" + fi +} diff --git a/games-simulation/openttd/openttd-12.2-r1.ebuild b/games-simulation/openttd/openttd-12.2-r1.ebuild new file mode 100644 index 000000000000..2c6d18c4b2c4 --- /dev/null +++ b/games-simulation/openttd/openttd-12.2-r1.ebuild @@ -0,0 +1,121 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit cmake xdg-utils + +DESCRIPTION="A clone of Transport Tycoon Deluxe" +HOMEPAGE="https://www.openttd.org/" +SRC_URI="https://cdn.openttd.org/openttd-releases/${PV}/${P}-source.tar.xz" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86" + +IUSE="allegro cpu_flags_x86_sse dedicated +fluidsynth icu +lzma lzo +openmedia +png +sdl timidity +truetype +zlib" +REQUIRED_USE="!dedicated? ( || ( allegro sdl ) )" + +RESTRICT="test" # needs a graphics set in order to test + +RDEPEND=" + dedicated? ( + acct-group/openttd + acct-user/openttd + app-misc/dtach + ) + !dedicated? ( + allegro? ( media-libs/allegro:5 ) + fluidsynth? ( media-sound/fluidsynth ) + icu? ( + dev-libs/icu-layoutex:= + dev-libs/icu-le-hb + >=dev-libs/icu-58.1:= + ) + sdl? ( media-libs/libsdl2[sound,video] ) + truetype? ( + media-libs/fontconfig + media-libs/freetype:2 + sys-libs/zlib:= + ) + ) + lzma? ( app-arch/xz-utils ) + lzo? ( dev-libs/lzo:2 ) + png? ( media-libs/libpng:0= ) + zlib? ( sys-libs/zlib:= ) +" +DEPEND="${RDEPEND}" +BDEPEND=" + >=games-util/grfcodec-6.0.6_p20210310 + virtual/pkgconfig +" +PDEPEND=" + !dedicated? ( + openmedia? ( + >=games-misc/openmsx-0.4.0 + >=games-misc/opensfx-1.0.1 + ) + ) + openmedia? ( >=games-misc/opengfx-0.6.1 ) + timidity? ( media-sound/timidity++ ) +" + +DOCS=( docs/directory_structure.md ) +PATCHES=( "${FILESDIR}/${PN}-1.11.2_dont_compress_man.patch" ) + +src_configure() { + local mycmakeargs=( + -DCMAKE_INSTALL_BINDIR=bin + -DCMAKE_INSTALL_DATADIR=share + -DOPTION_DEDICATED=$(usex dedicated) + -DCMAKE_DISABLE_FIND_PACKAGE_Allegro=$(usex !allegro) + -DCMAKE_DISABLE_FIND_PACKAGE_Freetype=$(usex !truetype) + -DCMAKE_DISABLE_FIND_PACKAGE_Fontconfig=$(usex !truetype) + -DCMAKE_DISABLE_FIND_PACKAGE_Fluidsynth=$(usex !fluidsynth) + -DCMAKE_DISABLE_FIND_PACKAGE_ICU=$(usex !icu) + -DCMAKE_DISABLE_FIND_PACKAGE_LibLZMA=$(usex !lzma) + -DCMAKE_DISABLE_FIND_PACKAGE_LZO=$(usex !lzo) + -DCMAKE_DISABLE_FIND_PACKAGE_PNG=$(usex !png) + # N.B. regarding #807364 and #828984: CMAKE_DISABLE_FIND_PACKAGE_SDL is used only + # with USE="allegro -sdl" combination flags. There no other way to + # completely disable SDL1 support. + -DCMAKE_DISABLE_FIND_PACKAGE_SDL=ON + -DCMAKE_DISABLE_FIND_PACKAGE_SDL2=$(usex !sdl) + -DCMAKE_DISABLE_FIND_PACKAGE_SSE=$(usex !cpu_flags_x86_sse) + -DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=$(usex !zlib) + ) + + cmake_src_configure +} + +src_install() { + cmake_src_install + if use dedicated ; then + newconfd "${FILESDIR}"/openttd.confd-r1 openttd + newinitd "${FILESDIR}"/openttd.initd-r3 openttd + fi +} + +pkg_postinst() { + xdg_icon_cache_update + + if ! use openmedia ; then + elog + elog "OpenTTD was compiled without the 'openmedia' USE flag." + elog + elog "In order to play, you must at least install" + elog "games-misc/opengfx, and games-misc/opensfx, or copy the " + elog "following 6 files from a version of Transport Tycoon Deluxe" + elog "(Windows or DOS) to shared or personal location." + elog "See /usr/share/doc/${PF}/directory_structure.md for more info." + elog + elog "From the Windows version you need: " + elog "sample.cat trg1r.grf trgcr.grf trghr.grf trgir.grf trgtr.grf" + elog "OR from the DOS version you need: " + elog "SAMPLE.CAT TRG1.GRF TRGC.GRF TRGH.GRF TRGI.GRF TRGT.GRF" + fi +} + +pkg_postrm() { + xdg_icon_cache_update +} diff --git a/games-simulation/openttd/openttd-12.2.ebuild b/games-simulation/openttd/openttd-12.2.ebuild deleted file mode 100644 index aaeac2d9a8f2..000000000000 --- a/games-simulation/openttd/openttd-12.2.ebuild +++ /dev/null @@ -1,120 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -inherit cmake xdg-utils - -DESCRIPTION="A clone of Transport Tycoon Deluxe" -HOMEPAGE="https://www.openttd.org/" -SRC_URI="https://cdn.openttd.org/openttd-releases/${PV}/${P}-source.tar.xz" - -LICENSE="GPL-2" -SLOT="0" -KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86" - -IUSE="allegro cpu_flags_x86_sse dedicated +fluidsynth icu +lzma lzo +openmedia +png +sdl timidity +truetype +zlib" -REQUIRED_USE="!dedicated? ( || ( allegro sdl ) )" - -RESTRICT="test" # needs a graphics set in order to test - -RDEPEND=" - dedicated? ( - acct-group/openttd - acct-user/openttd - ) - !dedicated? ( - allegro? ( media-libs/allegro:5 ) - fluidsynth? ( media-sound/fluidsynth ) - icu? ( - dev-libs/icu-layoutex:= - dev-libs/icu-le-hb - >=dev-libs/icu-58.1:= - ) - sdl? ( media-libs/libsdl2[sound,video] ) - truetype? ( - media-libs/fontconfig - media-libs/freetype:2 - sys-libs/zlib:= - ) - ) - lzma? ( app-arch/xz-utils ) - lzo? ( dev-libs/lzo:2 ) - png? ( media-libs/libpng:0= ) - zlib? ( sys-libs/zlib:= ) -" -DEPEND="${RDEPEND}" -BDEPEND=" - >=games-util/grfcodec-6.0.6_p20210310 - virtual/pkgconfig -" -PDEPEND=" - !dedicated? ( - openmedia? ( - >=games-misc/openmsx-0.4.0 - >=games-misc/opensfx-1.0.1 - ) - ) - openmedia? ( >=games-misc/opengfx-0.6.1 ) - timidity? ( media-sound/timidity++ ) -" - -DOCS=( docs/directory_structure.md ) -PATCHES=( "${FILESDIR}/${PN}-1.11.2_dont_compress_man.patch" ) - -src_configure() { - local mycmakeargs=( - -DCMAKE_INSTALL_BINDIR=bin - -DCMAKE_INSTALL_DATADIR=share - -DOPTION_DEDICATED=$(usex dedicated) - -DCMAKE_DISABLE_FIND_PACKAGE_Allegro=$(usex !allegro) - -DCMAKE_DISABLE_FIND_PACKAGE_Freetype=$(usex !truetype) - -DCMAKE_DISABLE_FIND_PACKAGE_Fontconfig=$(usex !truetype) - -DCMAKE_DISABLE_FIND_PACKAGE_Fluidsynth=$(usex !fluidsynth) - -DCMAKE_DISABLE_FIND_PACKAGE_ICU=$(usex !icu) - -DCMAKE_DISABLE_FIND_PACKAGE_LibLZMA=$(usex !lzma) - -DCMAKE_DISABLE_FIND_PACKAGE_LZO=$(usex !lzo) - -DCMAKE_DISABLE_FIND_PACKAGE_PNG=$(usex !png) - # N.B. regarding #807364 and #828984: CMAKE_DISABLE_FIND_PACKAGE_SDL is used only - # with USE="allegro -sdl" combination flags. There no other way to - # completely disable SDL1 support. - -DCMAKE_DISABLE_FIND_PACKAGE_SDL=ON - -DCMAKE_DISABLE_FIND_PACKAGE_SDL2=$(usex !sdl) - -DCMAKE_DISABLE_FIND_PACKAGE_SSE=$(usex !cpu_flags_x86_sse) - -DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=$(usex !zlib) - ) - - cmake_src_configure -} - -src_install() { - cmake_src_install - if use dedicated ; then - newconfd "${FILESDIR}"/openttd.confd openttd - newinitd "${FILESDIR}"/openttd.initd-r2 openttd - fi -} - -pkg_postinst() { - xdg_icon_cache_update - - if ! use openmedia ; then - elog - elog "OpenTTD was compiled without the 'openmedia' USE flag." - elog - elog "In order to play, you must at least install" - elog "games-misc/opengfx, and games-misc/opensfx, or copy the " - elog "following 6 files from a version of Transport Tycoon Deluxe" - elog "(Windows or DOS) to shared or personal location." - elog "See /usr/share/doc/${PF}/directory_structure.md for more info." - elog - elog "From the Windows version you need: " - elog "sample.cat trg1r.grf trgcr.grf trghr.grf trgir.grf trgtr.grf" - elog "OR from the DOS version you need: " - elog "SAMPLE.CAT TRG1.GRF TRGC.GRF TRGH.GRF TRGI.GRF TRGT.GRF" - fi -} - -pkg_postrm() { - xdg_icon_cache_update -} -- cgit v1.2.3-65-gdbad