mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
Improvements to the linux build script
In no particular order: * Use `set -e`, because it prevents accidents, and means we can avoid lengthy &&-joined command chains. * Override defaults by setting env vars; this means people don't have to edit the script to change things. * Use an unpredictable and safely-created tmpdir for building; ain't nobody wants to cleanup from a tmpdir race condition attack. * Test for the presence of `git` and `make` *before* asking questions, and only prompt the user about them if they're missing. No need to bother people with unnecessary reading. * Automatically clean up the build directory after use. * Tidy up some indenting that had come asunder.
This commit is contained in:
parent
3e1599ac4b
commit
14cb72f912
1 changed files with 50 additions and 27 deletions
|
@ -1,30 +1,53 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
localPATH=`pwd`
|
|
||||||
export BUILD_CLIENT="0"
|
set -e
|
||||||
export BUILD_SERVER="1"
|
|
||||||
export USE_CURL="1"
|
export BUILD_CLIENT="${BUILD_CLIENT:-0}"
|
||||||
export USE_CODEC_OPUS="1"
|
export BUILD_SERVER="${BUILD_SERVER:-1}"
|
||||||
export USE_VOIP="1"
|
export USE_CURL="${USE_CURL:-1}"
|
||||||
export COPYDIR="~/ioquake3"
|
export USE_CODEC_OPUS="${USE_CODEC_OPUS:-1}"
|
||||||
IOQ3REMOTE="https://github.com/ioquake/ioq3.git"
|
export USE_VOIP="${USE_VOIP:-1}"
|
||||||
IOQ3LOCAL="/tmp/ioquake3compile"
|
export COPYDIR="${COPYDIR:-~/ioquake3}"
|
||||||
JOPTS="-j2"
|
IOQ3REMOTE="${IOQ3REMOTE:-https://github.com/ioquake/ioq3.git}"
|
||||||
echo "This process requires you to have the following installed through your distribution:
|
MAKE_OPTS="${MAKE_OPTS:--j2}"
|
||||||
make
|
|
||||||
git
|
if ! [ -x "$(command -v git)" ] || ! [ -x "$(command -v make)" ]; then
|
||||||
and all of the ioquake3 dependencies necessary for an ioquake3 server.
|
echo "This build script requires 'git' and 'make' to be installed." >&2
|
||||||
If you do not have the necessary dependencies this script will bail out.
|
echo "Please install them through your normal package installation system." >&2
|
||||||
Please post a message to http://discourse.ioquake.org/ asking for help and include whatever error messages you received during the compile phase.
|
exit 1
|
||||||
Please edit this script. Inside you will find a COPYDIR variable you can alter to change where ioquake3 will be installed to."
|
|
||||||
while true; do
|
|
||||||
read -p "Are you ready to compile ioquake3 in the $IOQ3LOCAL directory, and have it installed into $COPYDIR? " yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* )
|
|
||||||
if [ -x "$(command -v git)" ] && [ -x "$(command -v make)" ] ; then
|
|
||||||
git clone $IOQ3REMOTE $IOQ3LOCAL && cd $IOQ3LOCAL && make $JOPTS && make copyfiles && cd $localPATH && rm -rf $IOQ3LOCAL
|
|
||||||
fi
|
fi
|
||||||
exit;;
|
|
||||||
[Nn]* ) exit;;
|
echo " This build process requires all of the ioquake3 dependencies necessary for an ioquake3 server.
|
||||||
* ) echo "Please answer yes or no.";;
|
If you do not have the necessary dependencies the build will fail.
|
||||||
esac
|
|
||||||
|
Please post a message to http://discourse.ioquake.org/ asking for help and include whatever error messages you received during the compile phase.
|
||||||
|
|
||||||
|
We will be building from the git repo at ${IOQ3REMOTE}
|
||||||
|
The resulting binary will be installed to ${COPYDIR}
|
||||||
|
|
||||||
|
If you need to change these, please set variables as follows:
|
||||||
|
|
||||||
|
IOQ3REMOTE=https://github.com/something/something.git COPYDIR=~/somewhere $0"
|
||||||
|
|
||||||
|
BUILD_DIR="$(mktemp -d)"
|
||||||
|
trap "rm -rf $BUILD_DIR" EXIT
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -p "Are you ready to compile ioquake3 from ${IOQ3REMOTE}, and have it installed into $COPYDIR? " yn
|
||||||
|
case $yn in
|
||||||
|
[Yy]*)
|
||||||
|
git clone $IOQ3REMOTE $BUILD_DIR/ioq3
|
||||||
|
cd $BUILD_DIR/ioq3
|
||||||
|
make $MAKE_OPTS
|
||||||
|
make copyfiles
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
[Nn]*)
|
||||||
|
echo "aborting installation."
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Please answer yes or no."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue