-
Notifications
You must be signed in to change notification settings - Fork 2
/
make.sh
executable file
·119 lines (111 loc) · 4.08 KB
/
make.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
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
#!/bin/sh
# for 纪秀峰本人
MODULE_FILE_NAME=./site-lisp/submodules/modules
# for public
# MODULE_FILE_NAME=./site-lisp/submodules/modules_public
WORD_DIR=`pwd`/site-lisp/submodules
# ./make init
# ./make push
# ./make status
# ./make make
case "$1" in
"init" )
# 过滤掉开头的#的注释行
for url in `cat $MODULE_FILE_NAME|grep -v "^[ \t]*#" ` ; do
url=`echo $url|awk -F '.git:' '{print $1}'`
echo $url
mod=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $1}'`
branch=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $2}'`
abs_mod_path=$WORD_DIR/$mod
if [ -d $abs_mod_path ] && [ -d $abs_mod_path/.git ] ; then
# 如果库已经存在
echo $abs_mod_path
cd $abs_mod_path
git checkout $branch
git pull
if [ -f $abs_mod_path/.gitmodules ] ; then
git submodule init
git submodule update
fi
else
cd $WORD_DIR
echo git clone $url
git clone $url --depth 1
git checkout $branch
fi
done
;;
"push" )
# 过滤掉开头的#的注释行
for url in `cat $MODULE_FILE_NAME|grep -v "^[ \t]*#" ` ; do
mod=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $1}'`
branch=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $2}'`
abs_mod_path=$WORD_DIR/$mod
# url 中含jixiuf 是我有权限push的
if [ -d $abs_mod_path ] && [ -d $abs_mod_path/.git ] && [ `echo $url | grep -c "jixiuf"` -gt 0 ] ; then
# my private repos
echo git push $url
cd $abs_mod_path
git checkout $branch
git pull
git push
fi
done
;;
"status" )
# 过滤掉开头的#的注释行
for url in `cat $MODULE_FILE_NAME|grep -v "^[ \t]*#" ` ; do
mod=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $1}'`
branch=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $2}'`
abs_mod_path=$WORD_DIR/$mod
cd $abs_mod_path
echo $url
git status
echo
done
;;
"make" )
# 如果子模块下有Makefile
# run make in sub mods
# 过滤掉开头的#的注释行
for url in `cat $MODULE_FILE_NAME|grep -v "^[ \t]*#" ` ; do
mod=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $1}'`
branch=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $2}'`
abs_mod_path=$WORD_DIR/$mod
if [ -d $abs_mod_path ] && [ -d $abs_mod_path/.git ] ; then
if [ -f $abs_mod_path/Makefile ] ; then
cd $abs_mod_path
make
fi
if [ -f $abs_mod_path/bin/build ]; then
cd $abs_mod_path
sh ./bin/build
fi
fi
done
;;
"configure" )
# 如果子模块下有 ./configure
# run ./configure
# 过滤掉开头的#的注释行
for url in `cat $MODULE_FILE_NAME|grep -v "^[ \t]*#" ` ; do
mod=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $1}'`
branch=`echo $url|sed 's|.*/||g'|awk -F '.git:' '{print $2}'`
abs_mod_path=$WORD_DIR/$mod
if [ -d $abs_mod_path ] && [ -d $abs_mod_path/.git ] ; then
if [ -f $abs_mod_path/configure.in ] ; then
cd $abs_mod_path
echo $abs_mod_path
autoconf
fi
# 如果 ./configure存在
if [ -f $abs_mod_path/configure ] ; then
cd $abs_mod_path
echo $abs_mod_path
echo ./configure
sh ./configure
fi
fi
done
;;
esac