forked from xonotic/xonotic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
all
executable file
·125 lines (111 loc) · 1.96 KB
/
all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh
# vim: filetype=zsh
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
# I use this in EVERY shell script ;)
LF="
"
ESC=""
d00=`pwd`
case "$0" in
/*/all)
export d0="${0%/all}"
;;
*/all)
export d0="$d00/${0%/all}"
;;
*/all.xonotic.sh)
;;
*)
$ECHO "Cannot find myself."
$ECHO "Please run this script with the working directory inside a Xonotic checkout."
;;
esac
cd "$d0"
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...
cp "$SELF" ../all.xonotic.sh
export WE_HATE_OUR_USERS=1
exec ../all.xonotic.sh "$@"
;;
esac
;;
esac
msg()
{
$ECHO >&2 "$ESC""[1m$*$ESC""[m"
}
self=`git hash-object "$SELF"`
checkself()
{
self_new=`git hash-object "$SELF"`
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" "$@"
else
msg "Please try $SELF update, and then retry your requested operation."
exit 1
fi
fi
return 0
}
verbose()
{
msg "+ $*"
"$@"
}
yesno()
{
yesno=
while [ x"$yesno" != x"y" -a x"$yesno" != x"n" ]; do
eval "$2"
$ECHO "$1"
if ! IFS= read -r yesno; then
yesno=n
break
fi
done
[ x"$yesno" = x"y" ]
}
enter()
{
$2 cd "$1" || exit 1
check_mergeconflict "$1" # defined in git.subr
}
if [ "$#" = 0 ]; then
set -- help
fi
cmd=$1
shift
# project config
. "$d0/misc/tools/all/config.subr"
# shared commands
handled=false
. "$d0/misc/tools/all/git.subr" "$@"
# optional modules
$handled || . "$d0/misc/tools/all/release.subr" "$@"
$handled || . "$d0/misc/tools/all/xonotic.subr" "$@"
if ! $handled; then
if [ x"$cmd" != x"help" ]; then
$ECHO "Run $SELF help for help."
exit 1
fi
fi