53 lines
1.6 KiB
Bash
Executable file
53 lines
1.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [[ $# -ne 3 ]]; then
|
|
echo "Usage: $0 /path/to/server-linux-x86_64 GAME_VERSION GAME_COMMIT" >&2
|
|
exit 2
|
|
fi
|
|
|
|
source_dir="${1%/}"
|
|
game_version="$2"
|
|
game_commit="${3,,}"
|
|
repository_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
destination_dir="${repository_dir}/dist"
|
|
|
|
if [[ ! "${game_version}" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then
|
|
echo "GAME_VERSION must contain only letters, numbers, dots, underscores, or hyphens." >&2
|
|
exit 2
|
|
fi
|
|
if [[ ! "${game_commit}" =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "GAME_COMMIT must be the full 40-character Git commit." >&2
|
|
exit 2
|
|
fi
|
|
|
|
for filename in NETfishingServer.x86_64 NETfishingServer.pck; do
|
|
if [[ ! -f "${source_dir}/${filename}" ]]; then
|
|
echo "Missing ${source_dir}/${filename}" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
install -m 0755 "${source_dir}/NETfishingServer.x86_64" \
|
|
"${destination_dir}/NETfishingServer.x86_64"
|
|
install -m 0644 "${source_dir}/NETfishingServer.pck" \
|
|
"${destination_dir}/NETfishingServer.pck"
|
|
|
|
cd -- "${destination_dir}"
|
|
executable_sha256="$(sha256sum NETfishingServer.x86_64 | awk '{print $1}')"
|
|
pck_sha256="$(sha256sum NETfishingServer.pck | awk '{print $1}')"
|
|
|
|
apply_umask="$(umask)"
|
|
umask 022
|
|
printf '%s\n' \
|
|
"manifest_version=1" \
|
|
"game_version=${game_version}" \
|
|
"game_commit=${game_commit}" \
|
|
"export_preset=Linux Dedicated Server" \
|
|
"platform=linux-x86_64" \
|
|
"executable_sha256=${executable_sha256}" \
|
|
"pck_sha256=${pck_sha256}" \
|
|
> BUILD_INFO
|
|
umask "${apply_umask}"
|
|
sha256sum NETfishingServer.x86_64 NETfishingServer.pck BUILD_INFO > SHA256SUMS
|
|
echo "Staged dedicated server build in ${destination_dir}"
|