2014-02-06 07:28:29 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# This should be run inside a folder that contains sourcemod, otherwise, it will checkout things into "sm-dependencies".
|
|
|
|
|
|
|
|
trap "exit" INT
|
|
|
|
|
2022-04-20 14:34:47 +02:00
|
|
|
download_mysql=1
|
|
|
|
|
2020-07-30 15:36:24 +02:00
|
|
|
# List of HL2SDK branch names to download.
|
|
|
|
# ./checkout-deps.sh -s tf2,css
|
2022-04-20 14:34:47 +02:00
|
|
|
# Disable downloading of mysql libraries.
|
|
|
|
# ./checkout-deps.sh -m
|
|
|
|
while getopts ":s:m" opt; do
|
2020-07-30 15:36:24 +02:00
|
|
|
case $opt in
|
|
|
|
s) IFS=', ' read -r -a sdks <<< "$OPTARG"
|
|
|
|
;;
|
2022-04-20 14:34:47 +02:00
|
|
|
m) download_mysql=0
|
|
|
|
;;
|
2020-07-30 15:36:24 +02:00
|
|
|
\?) echo "Invalid option -$OPTARG" >&2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2014-02-06 07:28:29 +01:00
|
|
|
ismac=0
|
2014-02-07 02:45:35 +01:00
|
|
|
iswin=0
|
|
|
|
|
|
|
|
archive_ext=tar.gz
|
2014-12-20 11:32:15 +01:00
|
|
|
decomp="tar zxf"
|
2014-02-07 02:45:35 +01:00
|
|
|
|
2014-02-06 07:28:29 +01:00
|
|
|
if [ `uname` = "Darwin" ]; then
|
|
|
|
ismac=1
|
2014-02-07 02:45:35 +01:00
|
|
|
elif [ `uname` != "Linux" ] && [ -n "${COMSPEC:+1}" ]; then
|
|
|
|
iswin=1
|
|
|
|
archive_ext=zip
|
|
|
|
decomp=unzip
|
2014-02-06 07:28:29 +01:00
|
|
|
fi
|
|
|
|
|
2014-05-25 10:53:58 +02:00
|
|
|
if [ ! -d "sourcemod" ]; then
|
2014-02-06 07:28:29 +01:00
|
|
|
if [ ! -d "sourcemod-1.5" ]; then
|
2014-02-16 02:13:13 +01:00
|
|
|
echo "Could not find a SourceMod repository; make sure you aren't running this script inside it."
|
|
|
|
exit 1
|
2014-02-06 07:28:29 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
getmysql ()
|
|
|
|
{
|
|
|
|
if [ ! -d $mysqlfolder ]; then
|
|
|
|
if [ `command -v wget` ]; then
|
|
|
|
wget $mysqlurl -O $mysqlfolder.$archive_ext
|
|
|
|
elif [ `command -v curl` ]; then
|
|
|
|
curl -o $mysqlfolder.$archive_ext $mysqlurl
|
|
|
|
else
|
|
|
|
echo "Failed to locate wget or curl. Install one of these programs to download MySQL."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
$decomp $mysqlfolder.$archive_ext
|
|
|
|
mv $mysqlver $mysqlfolder
|
|
|
|
rm $mysqlfolder.$archive_ext
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# 32-bit MySQL
|
2018-03-20 22:12:30 +01:00
|
|
|
mysqlfolder=mysql-5.5
|
2014-02-06 07:28:29 +01:00
|
|
|
if [ $ismac -eq 1 ]; then
|
|
|
|
mysqlver=mysql-5.5.28-osx10.5-x86
|
2016-04-15 23:15:40 +02:00
|
|
|
mysqlurl=https://cdn.mysql.com/archives/mysql-5.5/$mysqlver.$archive_ext
|
2014-02-07 02:45:35 +01:00
|
|
|
elif [ $iswin -eq 1 ]; then
|
2018-03-20 22:12:30 +01:00
|
|
|
mysqlver=mysql-5.5.54-win32
|
|
|
|
mysqlurl=https://cdn.mysql.com/archives/mysql-5.5/$mysqlver.$archive_ext
|
2014-02-07 02:45:35 +01:00
|
|
|
# The folder in the zip archive does not contain the substring "-noinstall", so strip it
|
|
|
|
mysqlver=${mysqlver/-noinstall}
|
2014-02-06 07:28:29 +01:00
|
|
|
else
|
|
|
|
mysqlver=mysql-5.6.15-linux-glibc2.5-i686
|
2016-04-15 23:15:40 +02:00
|
|
|
mysqlurl=https://cdn.mysql.com/archives/mysql-5.6/$mysqlver.$archive_ext
|
2014-02-06 07:28:29 +01:00
|
|
|
fi
|
2022-04-20 14:34:47 +02:00
|
|
|
if [ $download_mysql -eq 1 ]; then
|
|
|
|
getmysql
|
|
|
|
fi
|
2014-02-06 07:28:29 +01:00
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
# 64-bit MySQL
|
2018-03-20 22:12:30 +01:00
|
|
|
mysqlfolder=mysql-5.5-x86_64
|
2017-12-20 08:56:23 +01:00
|
|
|
if [ $ismac -eq 1 ]; then
|
|
|
|
mysqlver=mysql-5.5.28-osx10.5-x86_64
|
|
|
|
mysqlurl=https://cdn.mysql.com/archives/mysql-5.5/$mysqlver.$archive_ext
|
2020-08-07 04:53:06 +02:00
|
|
|
elif [ $iswin -eq 1 ]; then
|
|
|
|
mysqlver=mysql-5.5.54-winx64
|
|
|
|
mysqlurl=https://cdn.mysql.com/archives/mysql-5.5/$mysqlver.$archive_ext
|
|
|
|
else
|
2017-12-20 08:56:23 +01:00
|
|
|
mysqlver=mysql-5.6.15-linux-glibc2.5-x86_64
|
|
|
|
mysqlurl=https://cdn.mysql.com/archives/mysql-5.6/$mysqlver.$archive_ext
|
2014-02-06 07:28:29 +01:00
|
|
|
fi
|
2022-04-20 14:34:47 +02:00
|
|
|
if [ $download_mysql -eq 1 ]; then
|
|
|
|
getmysql
|
|
|
|
fi
|
2014-02-06 07:28:29 +01:00
|
|
|
|
|
|
|
checkout ()
|
|
|
|
{
|
|
|
|
if [ ! -d "$name" ]; then
|
2014-05-25 10:53:58 +02:00
|
|
|
git clone $repo -b $branch $name
|
|
|
|
if [ -n "$origin" ]; then
|
|
|
|
cd $name
|
2020-05-09 00:12:21 +02:00
|
|
|
git remote set-url origin $origin
|
2014-05-25 10:53:58 +02:00
|
|
|
cd ..
|
|
|
|
fi
|
2014-02-06 07:28:29 +01:00
|
|
|
else
|
|
|
|
cd $name
|
2020-05-09 00:12:21 +02:00
|
|
|
if [ -n "$origin" ]; then
|
|
|
|
git remote set-url origin ../$repo
|
|
|
|
fi
|
2014-05-25 10:53:58 +02:00
|
|
|
git checkout $branch
|
|
|
|
git pull origin $branch
|
2020-05-09 00:12:21 +02:00
|
|
|
if [ -n "$origin" ]; then
|
|
|
|
git remote set-url origin $origin
|
|
|
|
fi
|
2014-02-06 07:28:29 +01:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-12-19 18:15:45 +01:00
|
|
|
name=mmsource-1.12
|
2021-09-22 21:05:40 +02:00
|
|
|
branch=master
|
2014-05-25 10:53:58 +02:00
|
|
|
repo="https://github.com/alliedmodders/metamod-source"
|
|
|
|
origin=
|
2014-02-06 07:28:29 +01:00
|
|
|
checkout
|
|
|
|
|
2020-07-30 15:36:24 +02:00
|
|
|
if [ -z ${sdks+x} ]; then
|
|
|
|
sdks=( csgo hl2dm nucleardawn l4d2 dods l4d css tf2 insurgency sdk2013 doi )
|
2020-07-28 19:16:51 +02:00
|
|
|
|
2020-07-30 15:36:24 +02:00
|
|
|
if [ $ismac -eq 0 ]; then
|
|
|
|
# Add these SDKs for Windows or Linux
|
2022-10-24 21:27:32 +02:00
|
|
|
sdks+=( orangebox blade episode1 bms pvkii )
|
2020-07-28 19:16:51 +02:00
|
|
|
|
2020-07-30 15:36:24 +02:00
|
|
|
# Add more SDKs for Windows only
|
|
|
|
if [ $iswin -eq 1 ]; then
|
|
|
|
sdks+=( darkm swarm bgt eye contagion )
|
|
|
|
fi
|
2014-02-07 02:45:35 +01:00
|
|
|
fi
|
2014-02-06 07:28:29 +01:00
|
|
|
fi
|
|
|
|
|
2014-05-25 10:53:58 +02:00
|
|
|
# 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
|
|
|
|
|
2014-02-06 07:28:29 +01:00
|
|
|
for sdk in "${sdks[@]}"
|
|
|
|
do
|
2014-05-25 10:53:58 +02:00
|
|
|
repo=hl2sdk-proxy-repo
|
|
|
|
origin="https://github.com/alliedmodders/hl2sdk"
|
2014-02-06 07:28:29 +01:00
|
|
|
name=hl2sdk-$sdk
|
2014-05-25 10:53:58 +02:00
|
|
|
branch=$sdk
|
2014-02-06 07:28:29 +01:00
|
|
|
checkout
|
|
|
|
done
|
|
|
|
|
2021-03-07 13:50:15 +01:00
|
|
|
python_cmd=`command -v python3`
|
2020-07-28 19:16:51 +02:00
|
|
|
if [ -z "$python_cmd" ]; then
|
2021-03-07 13:50:15 +01:00
|
|
|
python_cmd=`command -v python`
|
2020-07-28 19:16:51 +02:00
|
|
|
|
|
|
|
if [ -z "$python_cmd" ]; then
|
|
|
|
echo "No suitable installation of Python detected"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-03-07 13:50:15 +01:00
|
|
|
$python_cmd -c "import ambuild2" 2>&1 1>/dev/null
|
2014-02-16 02:13:13 +01:00
|
|
|
if [ $? -eq 1 ]; then
|
2020-07-28 19:16:51 +02:00
|
|
|
echo "AMBuild is required to build SourceMod"
|
|
|
|
|
2021-03-07 13:50:15 +01:00
|
|
|
$python_cmd -m pip --version 2>&1 1>/dev/null
|
2020-07-28 19:16:51 +02:00
|
|
|
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
|
|
|
|
|
2014-05-25 10:53:58 +02:00
|
|
|
repo="https://github.com/alliedmodders/ambuild"
|
|
|
|
origin=
|
|
|
|
branch=master
|
|
|
|
name=ambuild
|
2014-02-16 02:13:13 +01:00
|
|
|
checkout
|
|
|
|
|
2020-05-14 01:51:31 +02:00
|
|
|
if [ $iswin -eq 1 ] || [ $ismac -eq 1 ]; then
|
2020-07-28 19:16:51 +02:00
|
|
|
$python_cmd -m pip install ./ambuild
|
2014-02-16 02:13:13 +01:00
|
|
|
else
|
2015-04-02 08:51:18 +02:00
|
|
|
echo "Installing AMBuild at the user level. Location can be: ~/.local/bin"
|
2020-07-28 19:16:51 +02:00
|
|
|
$python_cmd -m pip install --user ./ambuild
|
2014-02-16 02:13:13 +01:00
|
|
|
fi
|
|
|
|
fi
|