forked from rexbu/MobileCross
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·41 lines (36 loc) · 1.4 KB
/
setup.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
#!/bin/bash
action=$1
path=$2
modules=("bs" "basic" "libzip" "model")
remotes=("[email protected]:rexbu/bs.git" "[email protected]:rexbu/basic.git" "[email protected]:rexbu/libzip.git" "[email protected]:rexbu/model.git")
localdirs=("bs" "basic" "3rdparty/libzip" "model")
echo "---- start: ${BASH_SOURCE}"
if [ "$action" = "init" ];then
for ((i=0; i<${#modules[@]};i++)); do
git remote add ${modules[i]} ${remotes[i]}
git subtree add --prefix ${path}${localdirs[i]} ${modules[i]} master
setup=${path}${localdirs[i]}/setup.sh
if [ -f "$setup" ];then
$setup $action ${path}${localdirs[i]}/
fi
done
elif [ "$action" = "push" ];then
for ((i=0; i<${#modules[@]};i++)); do
setup=${path}${localdirs[i]}/setup.sh
if [ -f "$setup" ];then
$setup $action ${path}${localdirs[i]}/
fi
git subtree push --prefix ${path}${localdirs[i]} ${remotes[i]} master
done
elif [ "$action" = "pull" ];then
for ((i=0; i<${#modules[@]};i++)); do
setup=${path}${localdirs[i]}/setup.sh
if [ -f "$setup" ];then
$setup $action ${path}${localdirs[i]}/
fi
git subtree pull --prefix ${path}${localdirs[i]} ${remotes[i]} master
done
else
echo "please use ./setup.sh {action} {path}. action:init|push|pull. when path is current dir, don't use path. eg: ./setup.sh push"
fi
echo "#### end: ${BASH_SOURCE}"