-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sh
44 lines (37 loc) · 904 Bytes
/
build.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
#!/bin/bash
baseDIR=$(cd "$(dirname "$0")" || exit; pwd)
if [ -f "${baseDIR}/$1" ]; then
rm "${baseDIR}/$1"
fi
moduleFile="${baseDIR}/module_file"
cd ${baseDIR}
# 构建zip命令
zipCmd="zip -r -o -X $1 ./ "
# 遍历目录下的文件,如果不在排除列表中则添加到zip命令中
for file in $(ls -a "$baseDIR"); do
# echo "---${file##*/}---"
# filename=$(basename "$file")
# echo "===$filename==="
if [[ "${file}" == ".." || "${file}" == "." ]]; then
continue;
fi
add="A"
while read white;do
if [[ "${white}" == "${file}" ]]; then
# echo "===$white *=* $file======";
add="N";
break;
fi
done < $moduleFile
if [[ "$add" == "A" ]]; then
if [ -d $file ];then
zipCmd="${zipCmd} -x '${file}/*'"
else
zipCmd="${zipCmd} -x '$file'"
fi
fi
done
# 打印最终的zip命令
echo "$zipCmd"
# 执行zip命令
eval "$zipCmd"