2015-04-11 16:34:10 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# This should be run inside a folder that contains MM:S, otherwise, it will checkout things into "mms-dependencies".
|
|
|
|
|
|
|
|
trap "exit" INT
|
|
|
|
|
|
|
|
ismac=0
|
|
|
|
iswin=0
|
|
|
|
|
|
|
|
archive_ext=tar.gz
|
|
|
|
decomp="tar zxf"
|
|
|
|
|
|
|
|
if [ `uname` = "Darwin" ]; then
|
|
|
|
ismac=1
|
|
|
|
elif [ `uname` != "Linux" ] && [ -n "${COMSPEC:+1}" ]; then
|
|
|
|
iswin=1
|
|
|
|
archive_ext=zip
|
|
|
|
decomp=unzip
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "metamod-source" ]; then
|
|
|
|
echo "Could not find a Metamod:Source repository; make sure you aren't running this script inside it."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
checkout ()
|
|
|
|
{
|
|
|
|
if [ ! -d "$name" ]; then
|
|
|
|
git clone $repo -b $branch $name
|
|
|
|
if [ -n "$origin" ]; then
|
|
|
|
cd $name
|
|
|
|
git remote rm origin
|
|
|
|
git remote add origin $origin
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
cd $name
|
|
|
|
git checkout $branch
|
|
|
|
git pull origin $branch
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
sdks=( csgo hl2dm nucleardawn l4d2 dods l4d css tf2 insurgency sdk2013 dota )
|
|
|
|
|
|
|
|
if [ $ismac -eq 0 ]; then
|
|
|
|
# Add these SDKs for Windows or Linux
|
2015-05-06 23:51:54 +02:00
|
|
|
sdks+=( orangebox blade episode1 bms )
|
2015-04-11 16:34:10 +02:00
|
|
|
|
|
|
|
# Add more SDKs for Windows only
|
|
|
|
if [ $iswin -eq 1 ]; then
|
|
|
|
sdks+=( darkm swarm bgt eye contagion )
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check out a local copy as a proxy.
|
|
|
|
if [ ! -d "hl2sdk-proxy-repo" ]; then
|
|
|
|
git clone --mirror https://github.com/alliedmodders/hl2sdk hl2sdk-proxy-repo
|
|
|
|
else
|
|
|
|
cd hl2sdk-proxy-repo
|
|
|
|
git fetch
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
for sdk in "${sdks[@]}"
|
|
|
|
do
|
|
|
|
repo=hl2sdk-proxy-repo
|
|
|
|
origin="https://github.com/alliedmodders/hl2sdk"
|
|
|
|
name=hl2sdk-$sdk
|
|
|
|
branch=$sdk
|
|
|
|
checkout
|
|
|
|
done
|
|
|
|
|
2020-07-31 19:08:41 +02:00
|
|
|
python_cmd=`command -v python`
|
|
|
|
if [ -z "$python_cmd" ]; then
|
|
|
|
python_cmd=`command -v python3`
|
|
|
|
|
|
|
|
if [ -z "$python_cmd" ]; then
|
|
|
|
echo "No suitable installation of Python detected"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
`$python_cmd -c "import ambuild2"` 2>&1 1>/dev/null
|
2015-04-11 16:34:10 +02:00
|
|
|
if [ $? -eq 1 ]; then
|
2020-07-31 19:08:41 +02:00
|
|
|
echo "AMBuild is required to build Metamod:Source"
|
|
|
|
|
|
|
|
`$python_cmd -m pip --version` 2>&1 1>/dev/null
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
echo "The detected Python installation does not have PIP"
|
|
|
|
echo "Installing the latest version of PIP available (VIA \"get-pip.py\")"
|
|
|
|
|
|
|
|
get_pip="./get-pip.py"
|
|
|
|
get_pip_url="https://bootstrap.pypa.io/get-pip.py"
|
|
|
|
|
|
|
|
if [ `command -v wget` ]; then
|
|
|
|
wget $get_pip_url -O $get_pip
|
|
|
|
elif [ `command -v curl` ]; then
|
|
|
|
curl -o $get_pip $get_pip_url
|
|
|
|
else
|
|
|
|
echo "Failed to locate wget or curl. Install one of these programs to download 'get-pip.py'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
$python_cmd $get_pip
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
echo "Installation of PIP has failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-04-11 16:34:10 +02:00
|
|
|
repo="https://github.com/alliedmodders/ambuild"
|
|
|
|
origin=
|
|
|
|
branch=master
|
|
|
|
name=ambuild
|
|
|
|
checkout
|
|
|
|
|
2020-07-31 19:08:41 +02:00
|
|
|
if [ $iswin -eq 1 ] || [ $ismac -eq 1 ]; then
|
|
|
|
$python_cmd -m pip install ./ambuild
|
2015-04-11 16:34:10 +02:00
|
|
|
else
|
2015-09-25 04:17:47 +02:00
|
|
|
echo "Installing AMBuild at the user level. Location can be: ~/.local/bin"
|
2020-07-31 19:08:41 +02:00
|
|
|
$python_cmd -m pip install --user ./ambuild
|
2015-04-11 16:34:10 +02:00
|
|
|
fi
|
|
|
|
fi
|