You've already forked FullGameInstallers
mirror of
https://github.com/OldUnreal/FullGameInstallers.git
synced 2026-04-02 21:44:58 -07:00
feat: added UT2004 installers
This commit is contained in:
committed by
stijn-volckaert
parent
c6da8122f8
commit
83a35233f9
Executable
+190
@@ -0,0 +1,190 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck source-path=SCRIPTDIR
|
||||
# ARGBASH_SET_INDENT([ ])
|
||||
# ARG_HELP([Compile a standalone version of unshield])
|
||||
# ARG_VERSION_AUTO([1.0],['OldUnreal <https://oldunreal.com>'])
|
||||
# DEFINE_SCRIPT_DIR([_SCRIPT_DIR])
|
||||
# ARGBASH_GO()
|
||||
# needed because of Argbash --> m4_ignore([
|
||||
### START OF CODE GENERATED BY Argbash v2.11.0 one line above ###
|
||||
# Argbash is a bash code generator used to get arguments parsing right.
|
||||
# Argbash is FREE SOFTWARE, see https://argbash.dev for more info
|
||||
|
||||
|
||||
die()
|
||||
{
|
||||
local _ret="${2:-1}"
|
||||
test "${_PRINT_HELP:-no}" = yes && print_help >&2
|
||||
echo "$1" >&2
|
||||
exit "${_ret}"
|
||||
}
|
||||
|
||||
|
||||
begins_with_short_option()
|
||||
{
|
||||
local first_option all_short_options='hv'
|
||||
first_option="${1:0:1}"
|
||||
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
|
||||
}
|
||||
|
||||
# THE DEFAULTS INITIALIZATION - OPTIONALS
|
||||
|
||||
|
||||
print_help()
|
||||
{
|
||||
printf '%s\n' "Compile a standalone version of unshield"
|
||||
printf 'Usage: %s [-h|--help] [-v|--version]\n' "$0"
|
||||
printf '\t%s\n' "-h, --help: Prints help"
|
||||
printf '\t%s\n' "-v, --version: Prints version"
|
||||
}
|
||||
|
||||
|
||||
parse_commandline()
|
||||
{
|
||||
local _key
|
||||
while test $# -gt 0
|
||||
do
|
||||
_key="$1"
|
||||
case "$_key" in
|
||||
-h|--help)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
-h*)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
-v|--version)
|
||||
printf '%s %s\n\n%s\n%s\n' "build-unshield.sh" "1.0" 'Compile a standalone version of unshield' 'OldUnreal <https://oldunreal.com>'
|
||||
exit 0
|
||||
;;
|
||||
-v*)
|
||||
printf '%s %s\n\n%s\n%s\n' "build-unshield.sh" "1.0" 'Compile a standalone version of unshield' 'OldUnreal <https://oldunreal.com>'
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
parse_commandline "$@"
|
||||
|
||||
# OTHER STUFF GENERATED BY Argbash
|
||||
_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || { echo "Couldn't determine the script's running directory, which probably matters, bailing out" >&2; exit 2; }
|
||||
|
||||
### END OF CODE GENERATED BY Argbash (sortof) ### ])
|
||||
# [ <-- needed because of Argbash
|
||||
|
||||
# Enable Bash Strict Mode
|
||||
set -euo pipefail
|
||||
|
||||
command::get_arch() {
|
||||
local DETECTED_ARCHITECTURE
|
||||
DETECTED_ARCHITECTURE=$(uname -m)
|
||||
|
||||
case "${DETECTED_ARCHITECTURE}" in
|
||||
x86_64 | amd64)
|
||||
echo "amd64"
|
||||
;;
|
||||
aarch64)
|
||||
echo "arm64"
|
||||
;;
|
||||
i386 | i686)
|
||||
echo "x86"
|
||||
;;
|
||||
*)
|
||||
die "Unknown Architecture"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
command::main() {
|
||||
local CONTAINER_ENGINE=""
|
||||
|
||||
if command -v podman &>/dev/null; then
|
||||
CONTAINER_ENGINE="podman"
|
||||
elif command -v docker &>/dev/null; then
|
||||
CONTAINER_ENGINE="docker"
|
||||
fi
|
||||
|
||||
if [[ -z "${CONTAINER_ENGINE}" ]]; then
|
||||
die "You must have podman or docker installed"
|
||||
fi
|
||||
|
||||
# Use Valve's Sniper SDK as base target
|
||||
local BUILD_IMAGE="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest"
|
||||
local BUILD_IMAGE_ARM64="registry.gitlab.steamos.cloud/steamrt/sniper/sdk/arm64:latest"
|
||||
|
||||
# This relies on qemu-user-static and qemu-user-static-binfmt to work, so make sure you have these dependencies installed
|
||||
"${CONTAINER_ENGINE}" run \
|
||||
--rm \
|
||||
--platform=linux/amd64 \
|
||||
-v "${_SCRIPT_DIR}/..:/mnt/repo:rw" \
|
||||
-e "OU_IS_BUILDING_IN_PODMAN=yes" \
|
||||
"${BUILD_IMAGE}" \
|
||||
"bash" "/mnt/repo/bin/build-unshield.sh"
|
||||
|
||||
"${CONTAINER_ENGINE}" run \
|
||||
--rm \
|
||||
--platform=linux/arm64 \
|
||||
-v "${_SCRIPT_DIR}/..:/mnt/repo:rw" \
|
||||
-e "OU_IS_BUILDING_IN_PODMAN=yes" \
|
||||
"${BUILD_IMAGE_ARM64}" \
|
||||
"bash" "/mnt/repo/bin/build-unshield.sh"
|
||||
}
|
||||
|
||||
command::build() {
|
||||
local UNSHIELD_VERSION="1.6.2"
|
||||
local UNSHIELD_REPO="https://github.com/twogood/unshield.git"
|
||||
|
||||
local ARCHITECTURE
|
||||
ARCHITECTURE=$(command::get_arch)
|
||||
|
||||
local TLD_LINUX_REPO
|
||||
TLD_LINUX_REPO=$(realpath "${_SCRIPT_DIR}/..")
|
||||
|
||||
local WORK_DIR="${TLD_LINUX_REPO}/.tmp/unshield.git"
|
||||
|
||||
mkdir -p "${WORK_DIR}"
|
||||
|
||||
# Checkout a clean version of unshield
|
||||
if [[ ! -d "${WORK_DIR}/.git" ]]; then
|
||||
git clone --branch "${UNSHIELD_VERSION}" --depth 1 "${UNSHIELD_REPO}" "${WORK_DIR}"
|
||||
fi
|
||||
|
||||
cd "${WORK_DIR}"
|
||||
git reset --hard &>/dev/null && git clean --force -dfx &>/dev/null
|
||||
|
||||
# Make sure the checked out code matches the desired version
|
||||
local GIT_CURRENT_REF
|
||||
GIT_CURRENT_REF="$(git describe --exact-match --tags)"
|
||||
|
||||
if [[ "${GIT_CURRENT_REF}" != "${UNSHIELD_VERSION}" ]]; then
|
||||
git fetch --tags --prune && git checkout "tags/${UNSHIELD_VERSION}"
|
||||
fi
|
||||
|
||||
# Execute build
|
||||
mkdir -p "${WORK_DIR}/build"
|
||||
cd "${WORK_DIR}/build"
|
||||
cmake \
|
||||
-DOPENSSL_USE_STATIC_LIBS=ON \
|
||||
-DZLIB_USE_STATIC_LIBS=ON \
|
||||
-DBUILD_STATIC=ON "${WORK_DIR}" && make
|
||||
|
||||
mkdir -p "${TLD_LINUX_REPO}/deps"
|
||||
cp "${WORK_DIR}/build/src/unshield" "${TLD_LINUX_REPO}/deps/unshield-${ARCHITECTURE}"
|
||||
|
||||
cd "${WORK_DIR}"
|
||||
git reset --hard &>/dev/null && git clean --force -dfx &>/dev/null
|
||||
}
|
||||
|
||||
if [[ "${OU_IS_BUILDING_IN_PODMAN:-}" != "yes" ]]; then
|
||||
command::main
|
||||
else
|
||||
command::build
|
||||
fi
|
||||
|
||||
# ] <-- needed because of Argbash
|
||||
Reference in New Issue
Block a user