Skip to content

Commit 6b4e150

Browse files
committed
Create Unreal Tournament Install Script
1 parent 0cfd1fb commit 6b4e150

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

scriptmodules/ports/ut.sh

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/env bash
2+
3+
# This file is part of RetroPie-Extra, a supplement to RetroPie.
4+
# For more information, please visit:
5+
#
6+
# https://github.com/RetroPie/RetroPie-Setup
7+
# https://github.com/Exarkuniv/RetroPie-Extra
8+
#
9+
# See the LICENSE file distributed with this source and at
10+
# https://raw.githubusercontent.com/Exarkuniv/RetroPie-Extra/master/LICENSE
11+
#
12+
# This game works on i386, arm64, and amd64 package architectures
13+
#
14+
rp_module_id="ut"
15+
rp_module_desc="Unreal Tournament"
16+
rp_module_licence="PROP https://github.com/OldUnreal/UnrealTournamentPatches/blob/master/LICENSE.md"
17+
rp_module_help="Install game data by coping the contents of Maps/ Music/ Sounds/ Textures/ into their respective directories in $romdir/ports/ut/
18+
19+
Make sure you do not overwrite the Texture files that came with the patch, otherwise the in-game text will render incorrectly."
20+
rp_module_section="exp"
21+
rp_module_repo="https://github.com/OldUnreal/UnrealTournamentPatches/"
22+
rp_module_flags="!all x86 64bit"
23+
24+
function _get_branch_ut() {
25+
local version=$(curl https://api.github.com/repos/OldUnreal/UnrealTournamentPatches/releases/latest 2>&1 | grep -m 1 tag_name | cut -d\" -f4 | cut -dv -f2)
26+
echo -ne $version
27+
}
28+
29+
function depends_ut() {
30+
local depends="libsdl2-2.0-0 libopenal1"
31+
getDepends "${depends[@]}"
32+
}
33+
34+
function install_bin_ut() {
35+
local version="$(_get_branch_ut)"
36+
local arch="$(dpkg --print-architecture)"
37+
38+
# For some reason, it failed when using "$rp_module_repo", this works perfectly.
39+
local base_url="https://github.com/OldUnreal/UnrealTournamentPatches"
40+
local dl_file="OldUnreal-UTPatch${version}-Linux-${arch}.tar.bz2"
41+
local dl_url="${base_url}/releases/download/v${version}/${dl_file}"
42+
43+
# The download files use "x86" for the i386 architecture
44+
[[ "${arch}" == "i386" ]] && arch="x86"
45+
46+
downloadAndExtract "$dl_url" "$md_inst" "--no-same-owner"
47+
}
48+
49+
function __config_game_data() {
50+
local ut_game_dir=$1
51+
52+
if [[ ! -d "$romdir/ports/ut/$ut_game_dir" ]]; then
53+
mkdir -p "$romdir/ports/ut/$ut_game_dir"
54+
chown -R "$__user":"$__group" "$romdir/ports/ut/$ut_game_dir"
55+
else
56+
chown "$__user":"$__group" "$romdir/ports/ut/$ut_game_dir"
57+
fi
58+
59+
if [[ -d "$md_inst/$ut_game_dir" ]]; then
60+
cd "$md_inst/$ut_game_dir"
61+
for file in $(ls -d *); do
62+
63+
echo "Moving $md_inst/$ut_game_dir/$file -> $romdir/ports/$ut_game_dir/$file"
64+
65+
if [[ -d "$md_inst/$ut_game_dir/$file" ]]; then
66+
if [[ ! -d "$romdir/ports/ut/$ut_game_dir/$file" ]]; then
67+
mv "$md_inst/$ut_game_dir/$file" "$romdir/ports/ut/$ut_game_dir/$file"
68+
else
69+
rm -rf "$romdir/ports/ut/$ut_game_dir/$file"
70+
mv "$md_inst/$ut_game_dir/$file" "$romdir/ports/ut/$ut_game_dir/$file"
71+
fi
72+
else
73+
mv "$md_inst/$ut_game_dir/$file" "$romdir/ports/ut/$ut_game_dir/$file"
74+
fi
75+
done
76+
77+
rm -rf "$md_inst/$ut_game_dir"
78+
fi
79+
80+
ln -snf "$romdir/ports/ut/$ut_game_dir" "$md_inst/$ut_game_dir"
81+
}
82+
83+
function game_data_ut() {
84+
85+
for dir in Help Maps Music Sounds Textures Web; do
86+
87+
# Ensure we aren't moving files that are already in place.
88+
# Eliminates 'mv: '$src/$file' and '$dst/$file' are the same file' errors.
89+
if [[ ! -h "$md_inst/$dir" ]]; then
90+
__config_game_data "$dir"
91+
fi
92+
done
93+
94+
local bonus_pack_4_url="https://unreal-archive-files-s3.s3.us-west-002.backblazeb2.com/patches-updates/Unreal%20Tournament/Bonus%20Packs/utbonuspack4-zip.zip"
95+
downloadAndExtract "$bonus_pack_4_url" "$romdir/ports/ut/"
96+
97+
chown -R "$__user":"$__group" "$romdir/ports/ut"
98+
find "$romdir/ports/ut" -type f -exec chmod 644 {} \;
99+
find "$romdir/ports/ut" -type d -exec chmod 755 {} \;
100+
101+
}
102+
103+
104+
function configure_ut() {
105+
if isPlatform "x86"; then
106+
addPort "$md_id" "ut" "Unreal Tournament" "$md_inst/System64/ut-bin"
107+
else
108+
addPort "$md_id" "ut" "Unreal Tournament" "$md_inst/SystemARM64/ut-bin"
109+
fi
110+
111+
mkRomDir "ports/ut"
112+
113+
if [[ "$md_mode" == "install" ]]; then
114+
game_data_ut
115+
fi
116+
moveConfigDir "$home/.utpg" "$md_conf_root/ut"
117+
}

0 commit comments

Comments
 (0)