mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-20 20:46:03 +08:00
Update from SDK 2013
This commit is contained in:

committed by
Nicholas Hastings

parent
6d5c024820
commit
94b660e16e
43
sdk_container
Normal file
43
sdk_container
Normal file
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function run_in_sniper() {
|
||||
script_file=$(basename -- "$script")
|
||||
check_env=$(sha256sum -- "$script" | cut -d " " -f 1)
|
||||
|
||||
if [[ ! -f /run/.containerenv ]]; then
|
||||
# Check if podman exists
|
||||
if ! command -v podman &> /dev/null; then
|
||||
echo "Error: podman is not installed. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Let's say we run as /home/misyl/my_mod/src/myscript
|
||||
# We want to mount /home/misyl/my_mod, and then launch
|
||||
# src/myscript inside of that.
|
||||
#
|
||||
# The below achieves that.
|
||||
mod_src_dir=$(pwd)
|
||||
mod_src_dir_name=$(basename -- "$mod_src_dir")
|
||||
mod_base_dir=$(dirname -- "$mod_src_dir")
|
||||
|
||||
image="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest"
|
||||
echo "Running script inside $image"
|
||||
exec podman run \
|
||||
--env "$check_env=$script_file" \
|
||||
--env "CCACHE_DIR=${CCACHE_DIR:-$HOME/.ccache}" \
|
||||
--userns=keep-id \
|
||||
--rm -it \
|
||||
--mount type=bind,\"source="${CCACHE_DIR:-$HOME/.ccache}"\",\"target="${CCACHE_DIR:-$HOME/.ccache}"\" \
|
||||
--mount type=bind,\"source="$mod_base_dir"\",target=/my_mod/ \
|
||||
"$image" \
|
||||
/my_mod/"$mod_src_dir_name"/"$script_file" \
|
||||
"$@"
|
||||
fi
|
||||
|
||||
if [[ $(printenv -- "$check_env") != "$script_file" ]]; then
|
||||
echo "Can't run in a nested container setup. Sorry! :("
|
||||
exit 1
|
||||
fi
|
||||
}
|
Reference in New Issue
Block a user