xonotic/all

119 lines
1.9 KiB
Plaintext
Raw Normal View History

2010-03-18 15:46:07 +00:00
#!/bin/sh
# vim: filetype=zsh
2010-03-18 15:46:07 +00:00
set -e
if [ -n "$ZSH_VERSION" ]; then
setopt SH_WORD_SPLIT
fi
if [ -z "$ECHO" ]; then
if echo "\\\\" | grep .. >/dev/null; then
ECHO=echo
else
ECHO=`which echo`
fi
fi
2010-03-18 15:46:07 +00:00
# I use this in EVERY shell script ;)
LF="
"
ESC=""
d00=`pwd`
while ! [ -f ./all ]; do
if [ x"`pwd`" = x"/" ]; then
$ECHO "Cannot find myself."
$ECHO "Please run this script with the working directory inside a Xonotic checkout."
exit 1
fi
cd ..
done
export d0=`pwd`
SELF="$d0/all"
# If we are on WINDOWS:
case "$0" in
all|*/all)
case "`uname`" in
MINGW*|Win*)
# Windows hates users. So this script has to copy itself elsewhere first...
2010-04-02 18:35:19 +00:00
cp "$SELF" ../all.xonotic.sh
export WE_HATE_OUR_USERS=1
exec ../all.xonotic.sh "$@"
;;
esac
;;
esac
2010-03-29 13:21:24 +00:00
msg()
{
$ECHO >&2 "$ESC""[1m$*$ESC""[m"
2010-03-29 13:21:24 +00:00
}
2010-06-22 15:05:06 +00:00
self=`git hash-object "$SELF"`
2010-03-29 13:21:24 +00:00
checkself()
{
2010-06-22 15:05:06 +00:00
self_new=`git hash-object "$SELF"`
2010-03-29 13:21:24 +00:00
if [ x"$self" != x"$self_new" ]; then
msg "./all has changed."
if [ -z "$XONOTIC_FORBID_RERUN_ALL" ]; then
msg "Rerunning the requested operation to make sure."
export XONOTIC_FORBID_RERUN_ALL=1
exec "$SELF" "$@"
2010-03-29 13:21:24 +00:00
else
msg "Please try $SELF update, and then retry your requested operation."
2010-03-29 13:21:24 +00:00
exit 1
fi
fi
2010-03-29 13:24:49 +00:00
return 0
2010-03-29 13:21:24 +00:00
}
verbose()
{
2010-03-29 13:21:24 +00:00
msg "+ $*"
"$@"
}
2010-05-09 17:40:25 +00:00
yesno()
{
yesno=
while [ x"$yesno" != x"y" -a x"$yesno" != x"n" ]; do
2010-05-15 18:11:23 +00:00
eval "$2"
$ECHO "$1"
2011-03-09 17:47:38 +00:00
if ! IFS= read -r yesno; then
yesno=n
break
fi
2010-05-09 17:40:25 +00:00
done
[ x"$yesno" = x"y" ]
}
2010-04-02 19:11:17 +00:00
enter()
{
2010-07-18 15:18:15 +00:00
$2 cd "$1" || exit 1
2012-03-01 13:09:29 +00:00
check_mergeconflict "$1" # defined in git.subr
}
2010-03-18 15:57:21 +00:00
if [ "$#" = 0 ]; then
set -- help
fi
2010-03-18 15:46:07 +00:00
cmd=$1
shift
2012-03-01 13:09:29 +00:00
# project config
. "$d0/misc/tools/all/config.subr"
2012-03-01 13:09:29 +00:00
# shared commands
handled=false
. "$d0/misc/tools/all/git.subr" "$@"
2012-03-01 13:09:29 +00:00
# optional modules
$handled || . "$d0/misc/tools/all/release.subr" "$@"
$handled || . "$d0/misc/tools/all/xonotic.subr" "$@"
2012-03-01 13:09:29 +00:00
if ! $handled; then
if [ x"$cmd" != x"help" ]; then
$ECHO "Run $SELF help for help."
exit 1
fi
2012-03-01 13:09:29 +00:00
fi