From 38cbbbf2dfebfd0e246caf2e92db0a4291a3fb32 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 21 Oct 2020 15:14:30 -0400 Subject: [PATCH] Better script for docker (#54501) The linux one shot script is not a drop-in for the docker script. Let's separate the two. --- .github/CODEOWNERS | 2 + tools/LinuxOneShot/SetupProgram/PreCompile.sh | 4 +- tools/tgs4_scripts/PreCompile.sh | 62 +++++++++++++++++++ ...inuxOneShot_SetupProgram_For_PreCompile.sh | 0 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100755 tools/tgs4_scripts/PreCompile.sh delete mode 100644 tools/tgs4_scripts/SEE_LinuxOneShot_SetupProgram_For_PreCompile.sh diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 95f6fb10377..4df7c137c20 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -25,6 +25,8 @@ /code/modules/admin/verbs/adminhelp.dm @Cyberboss /code/modules/admin/verbs/adminpm.dm @Cyberboss /code/modules/mapping/ @Cyberboss +/tools/LinuxOneShot/ @Cyberboss +/tools/tgs4_scripts/ @Cyberboss # Jared-Fogle diff --git a/tools/LinuxOneShot/SetupProgram/PreCompile.sh b/tools/LinuxOneShot/SetupProgram/PreCompile.sh index 7eca9e4c95a..ba8859699b7 100644 --- a/tools/LinuxOneShot/SetupProgram/PreCompile.sh +++ b/tools/LinuxOneShot/SetupProgram/PreCompile.sh @@ -1,5 +1,7 @@ #!/bin/bash +# REPO MAINTAINERS: KEEP CHANGES TO THIS IN SYNC WITH /tools/tgs4_scripts/PreCompile.sh + set -e set -x @@ -26,7 +28,7 @@ if ! [ -x "$has_cargo" ]; then . ~/.profile fi -# apt packages +# apt packages, libssl needed by rust-g but not included in TGS barebones install if ! { [ -x "$has_git" ] && [ -x "$has_grep" ] && [ -f "/usr/lib/i386-linux-gnu/libssl.so" ] && [ -f "/usr/bin/mysql" ] && [ -d "/usr/include/mysql" ]; }; then echo "Installing apt dependencies..." if ! [ -x "$has_sudo" ]; then diff --git a/tools/tgs4_scripts/PreCompile.sh b/tools/tgs4_scripts/PreCompile.sh new file mode 100755 index 00000000000..545997c1120 --- /dev/null +++ b/tools/tgs4_scripts/PreCompile.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# REPO MAINTAINERS: KEEP CHANGES TO THIS IN SYNC WITH /tools/LinuxOneShot/SetupProgram/PreCompile.sh + +set -e +set -x + +#load dep exports +#need to switch to game dir for Dockerfile weirdness +original_dir=$PWD +cd "$1" +. dependencies.sh +cd "$original_dir" + +#find out what we have (+e is important for this) +set +e +has_git="$(command -v git)" +has_cargo="$(command -v ~/.cargo/bin/cargo)" +has_sudo="$(command -v sudo)" +has_grep="$(command -v grep)" +set -e + +# install cargo if needful +if ! [ -x "$has_cargo" ]; then + echo "Installing rust..." + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-host i686-unknown-linux-gnu + . ~/.profile +fi + +# apt packages, libssl needed by rust-g but not included in TGS barebones install +if ! { [ -x "$has_git" ] && [ -x "$has_grep" ] && [ -f "/usr/lib/i386-linux-gnu/libssl.so" ] }; then + echo "Installing apt dependencies..." + if ! [ -x "$has_sudo" ]; then + dpkg --add-architecture i386 + apt-get update + apt-get install -y git libssl-dev:i386 + rm -rf /var/lib/apt/lists/* + else + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install -y git libssl-dev:i386 + sudo rm -rf /var/lib/apt/lists/* + fi +fi + +#update rust-g +if [ ! -d "rust-g" ]; then + echo "Cloning rust-g..." + git clone https://github.com/tgstation/rust-g +else + echo "Fetching rust-g..." + cd rust-g + git fetch + cd .. +fi + +echo "Deploying rust-g..." +cd rust-g +git checkout "$RUST_G_VERSION" +~/.cargo/bin/cargo build --release +mv target/release/librust_g.so "$1/rust_g" +cd .. diff --git a/tools/tgs4_scripts/SEE_LinuxOneShot_SetupProgram_For_PreCompile.sh b/tools/tgs4_scripts/SEE_LinuxOneShot_SetupProgram_For_PreCompile.sh deleted file mode 100644 index e69de29bb2d..00000000000