94 lines
2.0 KiB
Bash
Executable File
94 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eux
|
|
|
|
# just podman things
|
|
export DBUS_SESSION_BUS_ADDRESS=
|
|
|
|
NAME=xash-builder
|
|
|
|
HLRTEST_REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
|
|
|
|
source .env
|
|
|
|
build-image-hlsdk() {
|
|
podman build -t ubuntu-hlsdk -f Containerfile.hlsdk
|
|
}
|
|
|
|
build-image() {
|
|
podman build -t ubuntu-xash-builder -f Containerfile
|
|
}
|
|
|
|
build() {
|
|
build-image-hlsdk
|
|
build-image
|
|
}
|
|
|
|
git_short() {
|
|
local dir="${1:-.}"
|
|
local hash dirty_flag
|
|
|
|
# Get short commit hash
|
|
hash=$(cd "$dir" && git rev-parse --short HEAD 2>/dev/null)
|
|
|
|
if [[ -z "$hash" ]]; then
|
|
echo "Not a git repository" >&2
|
|
return 1
|
|
fi
|
|
|
|
# Check for uncommitted changes (staged or unstaged)
|
|
dirty_flag=$(cd "$dir" && git status --porcelain --untracked-files=no 2>/dev/null)
|
|
|
|
if [[ -n "$dirty_flag" ]]; then
|
|
echo "${hash}-dirty"
|
|
else
|
|
echo "$hash"
|
|
fi
|
|
}
|
|
|
|
render-test() {
|
|
local OUTPUT="${HLRTEST_REPO_DIR}/render/work"
|
|
mkdir -p "${OUTPUT}"
|
|
|
|
local HLRTEST_REVISION=$(git_short "${HLRTEST_REPO_DIR}")
|
|
local XASH3D_REVISION=$(git_short "${XASH3D_RT_REPO_DIR}")
|
|
local PBR_REVISION=$(git_short "${HALFLIFE_PBR_REPO_DIR}")
|
|
|
|
# Make sure the image's ubuntu (uid=1000) user can write to the output
|
|
#chmod -R o+rw "${OUTPUT}"
|
|
|
|
podman run -it --rm \
|
|
--name ${NAME} \
|
|
--userns=keep-id:uid=1000,gid=1000 \
|
|
\
|
|
--cap-drop=ALL \
|
|
--security-opt=no-new-privileges \
|
|
--read-only \
|
|
--tmpfs /tmp \
|
|
\
|
|
-e HLRTEST_REVISION="${HLRTEST_REVISION}" \
|
|
-e XASH3D_REVISION="${XASH3D_REVISION}" \
|
|
-e PBR_REVISION="${PBR_REVISION}" \
|
|
\
|
|
-v /dev/dri/renderD128:/dev/dri/renderD128:ro \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
\
|
|
-v /opt/hl \
|
|
-v /home/ubuntu \
|
|
-v ${HALFLIFE_PBR_REPO_DIR}/valve/pbr:/opt/hl/valve/pbr:ro \
|
|
-v ${HALFLIFE_PBR_REPO_DIR}/valve/bluenoise:/opt/hl/valve/bluenoise:ro \
|
|
\
|
|
-v ${XASH3D_RT_REPO_DIR}:/build/xash3d-fwgs:O \
|
|
\
|
|
-v ${HLRTEST_REPO_DIR}:/build/HLRTest:O \
|
|
-v ${OUTPUT}:/build/HLRTest/render/work \
|
|
\
|
|
ubuntu-xash-builder:latest \
|
|
"$@"
|
|
}
|
|
|
|
shell() {
|
|
podman exec -it ${NAME} /bin/bash
|
|
}
|
|
|
|
time "$@"
|