summaryrefslogtreecommitdiff
path: root/games-fps/unreal-tournament/unreal-tournament-469f_rc6.ebuild
blob: 6280ed29a418f5a1fedd2801b2ea5da2172f4181 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit desktop xdg

DESCRIPTION="Modern build of the Unreal Tournament (99) engine"
HOMEPAGE="https://www.oldunreal.com/downloads/unrealtournament/oldunreal-patches-for-unrealtournament-version-469/"
SRC_URI="
	amd64? ( https://github.com/OldUnreal/UnrealTournamentPatches/releases/download/v${PV//_/-}/OldUnreal-UTPatch${PV%_*}-Linux-amd64.tar.bz2 )
	arm64? ( https://github.com/OldUnreal/UnrealTournamentPatches/releases/download/v${PV//_/-}/OldUnreal-UTPatch${PV%_*}-Linux-arm64.tar.bz2 )
	x86? ( https://github.com/OldUnreal/UnrealTournamentPatches/releases/download/v${PV//_/-}/OldUnreal-UTPatch${PV%_*}-Linux-x86.tar.bz2 )
	mirror+https://dev.gentoo.org/~chewi/distfiles/${PN}.png
"
S="${WORKDIR}"

LICENSE="Epic-TOS Apache-2.0 BSD BSD-2 HappyBunny libpng2 MIT OFL-1.1 ZLIB" # See LICENSE.md
SLOT="0"
KEYWORDS="-* ~amd64 ~arm64 ~x86"
IUSE="dedicated l10n_ca l10n_de l10n_el l10n_es l10n_fr l10n_it l10n_nl l10n_pt l10n_ru opengl swr vulkan video_cards_lima video_cards_panfrost"
RESTRICT="bindist mirror strip"

UT_DEPEND="games-fps/unreal-tournament-data-436_p4"

BDEPEND="
	dev-util/patchelf
"
RDEPEND="
	media-libs/libsdl3[opengl?,vulkan?]
	media-libs/libsndfile
	media-libs/libxmp
	media-libs/openal
	media-libs/sdl3-ttf
	media-sound/mpg123-base
	dedicated? ( acct-user/unreal )
	opengl? ( media-libs/libglvnd )
	vulkan? ( media-libs/vulkan-loader )
"
PDEPEND="
	>=${UT_DEPEND}
"

DIR="/opt/${PN}"
QA_PREBUILT="*"

PATCHES=(
	"${FILESDIR}"/${PN}-wasd.patch
	"${FILESDIR}"/${PN}-winsys.patch
)

src_prepare() {
	default

	# Fix NEEDED entry for libmpg123.
	# https://github.com/OldUnreal/UnrealTournamentPatches/issues/2053
	patchelf --replace-needed libmpg123.so{,.0} System/ALAudio.so || die

	# Remove bundled libraries. LAME doesn't seem to be used.
	rm -v System/lib{mp3lame,mpg123,openal,SDL3*,sndfile,xmp}.so* || die

	# This audio driver requires libfmod, which is missing on amd64 and arm64.
	if ! use x86; then rm -v System/Cluster.so || die; fi

	# Drop unwanted localisation files.
	local dir lang
	for dir in SystemLocalized/*; do
		lang=${dir#*/}
		lang=${lang:0:2}
		[[ ${lang} == in ]] && continue
		[[ ${lang} == ct ]] && lang=ca # Catalan
		use "l10n_${lang}" || rm -rv "${dir}" || die
	done
}

src_configure() {
	if use vulkan; then
		declare -g GameRenderDevice="VulkanDrv.VulkanRenderDevice"
	elif use opengl; then
		# XOpenGLDrv rendering is broken on Panfrost and probably Lima.
		# https://github.com/OldUnreal/UnrealTournamentPatches/issues/2107
		if use video_cards_lima || use video_cards_panfrost; then
			declare -g GameRenderDevice="OpenGLDrv.OpenGLRenderDevice"
		else
			declare -g GameRenderDevice="XOpenGLDrv.XOpenGLRenderDevice"
		fi
	elif use swr; then
		declare -g GameRenderDevice="SoftDrv.SoftwareRenderDevice"
	else
		unset GameRenderDevice
	fi

	if [[ -n ${GameRenderDevice} ]]; then
		einfo "Enforcing the ${GameRenderDevice} renderer."
	else
		einfo "Not enforcing the renderer. Change the USE flags to enforce it."
	fi
}

src_install() {
	insinto "${DIR}"
	doins -r */

	local exes=( System/{*-bin,*.so*} )
	fperms a+x "${exes[@]/#/${DIR}/}"

	sed \
		-e "s:@EPREFIX@:${EPREFIX}:g" \
		-e "s:@GameRenderDevice@:${GameRenderDevice}:g" \
		"${FILESDIR}/wrapper.sh" | newbin - ${PN}

	# ucc does not benefit from the wrapper.
	dosym -r "${DIR}/System"/ucc-bin /usr/bin/${PN}-ucc

	doicon -s 128 "${DISTDIR}/${PN}.png"
	make_desktop_entry --eapi9 ${PN} -n "Unreal Tournament" \
		-C "Epic's popular first-person shooter"

	if use dedicated; then
		newconfd "${FILESDIR}"/${PN}-ded.confd ${PN}-ded
		newinitd "${FILESDIR}"/${PN}-ded.initd ${PN}-ded
	fi

	dodoc ReleaseNotes.md
}