-
Notifications
You must be signed in to change notification settings - Fork 4
/
update.sh
executable file
·71 lines (59 loc) · 1.37 KB
/
update.sh
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
#!/bin/sh
CWD=`dirname $(readlink -f $0)`
cd $CWD
case $1 in
dev)
CHANNEL="dev"
;;
beta)
CHANNEL="beta"
;;
*)
CHANNEL="production"
esac
if [ "$CHANNEL" != "dev" ]; then
VERSIONS=`$CWD/check_update.sh $CHANNEL`
case "$VERSIONS" in
noupdate,*)
echo "no updates available"
exit 1;;
update,*)
RELEASE=`echo "$VERSIONS" | cut -d',' -f3`
VERSION=`echo "$VERSIONS" | cut -d',' -f4`
echo "updating to $VERSION"
esac
fi
git_fetch_all() {
git fetch --all
}
git_checkout_version() {
if [ ! -z "$VERSION" ]; then
git checkout $VERSION
else
git checkout master
git pull
fi
}
git_update_submodules() {
SUBMODULE_LIST=`git submodule status | awk '{print $2}'`
HAS_REPOS_W_CHANGED_URLS=""
for SUBMOD in $SUBMODULE_LIST; do
cd $CWD/$SUBMOD
REPO_URL=`git remote -v | grep fetch | awk '{print $2}'`
cd $CWD
MANIFEST_URL=`egrep -A1 "path = $SUBMOD\$" .gitmodules | grep url | awk '{print $3}'`
if [ "$MANIFEST_URL" != "$REPO_URL" ]; then
echo "changed repo URL $SUBMOD $REPO_URL $MANIFEST_URL"
HAS_REPOS_W_CHANGED_URLS="YES"
rm -rf $CWD/$SUBMOD
rm -rf $CWD/.git/modules/$SUBMOD
fi
done
cd $CWD
git submodule sync > /dev/null &&
git submodule update --init --recursive --depth 100
}
update_release_file() {
echo "$RELEASE" > "$CWD/.current_release"
}
git_fetch_all && git_checkout_version && git_update_submodules && update_release_file