-
Notifications
You must be signed in to change notification settings - Fork 9
/
init.sh
executable file
·77 lines (67 loc) · 1.54 KB
/
init.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
72
73
74
75
76
#!/bin/bash
#
# clone all the subrepo
#
function print_help(){
echo "./init.sh [--tags TAGNAME | --source | -h]"
echo ""
echo " --source check out only the source code and not the entire GIT repo"
echo " --tags TAGNAME download the TAGNAME version of the code"
echo ""
}
while [ $# -ge 1 ]; do
case "$1" in
--)
# No more options left.
shift
break
;;
--source)
SOURCE=true
baseURL="http://github.com/rocksclusters"
;;
--tag)
tag_name=$2
shift
;;
-h)
print_help
exit 0
;;
esac
shift
done
SubModule=`cat .gitignore`
remote=`git remote -v|awk '{print $2}'|head -n 1`
baseRemote=`dirname $remote`
start_time=$(date +%s)
pushd src/roll
for i in $SubModule;
do
modName=`basename $i`
if [ "$SOURCE" ]; then
#if tag_name is not defined set it to master
test $tag_name || tag_name=master
if [ "$tag_name" == "master" ] ; then
wget -nv -O $modName.tar.gz $baseURL/$modName/archive/$tag_name.tar.gz || exit 1
else
# maybe that branch is not defined for this repo let's skip it
wget -nv -O $modName.tar.gz $baseURL/$modName/archive/$tag_name.tar.gz || continue
fi
tar -xzf $modName.tar.gz || exit 1
mv $modName-$tag_name $modName || exit 1
rm $modName.tar.gz
else
echo " Cloning $baseRemote/$modName.git repository"
git clone $baseRemote/$modName.git $modName || exit 1
echo tag name $tag_name
if [ "$tag_name" ]; then
pushd $modName
git checkout "$tag_name"
popd
fi
fi
done
popd
finish_time=$(date +%s)
echo "Time duration: $((finish_time - start_time)) secs."