forked from jesssu/VoEnabler
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbuild.sh
executable file
·69 lines (61 loc) · 1.28 KB
/
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
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
#!/usr/bin/env bash
## VoEnabler
createZip() {
#remove if force enabled
[[ ${2} -eq 1 ]] && [[ -f ${1} ]] && rm -f ${1}
if [[ ${3} -eq 1 ]]; then
echo "DRYRUN:${DRYRUN}, ${VFILE} not created"
else
#create archive
echo "creating ${VFILE}"
zip -r ./${1} META-INF module.prop system.prop customize.sh README.md
ls -al *.zip
fi
}
usage() {
echo -e "\n$0:\t [d,f,h,v]"
echo -e "\t-v\tversion: define version for zip filename."
echo -e "\t-d\tDryRun: is set, then no zip file is created"
echo -e "\t-f\tForce, overwrite existing zip if any"
echo -e "\t-h\tHelp: this help"
echo -e "\t-l\tlatest: build zip with latest commit"
}
#Main
#process options
VERSION=""
FORCE=0
DRYRUN=0
LATEST=0
while getopts "dfhlv:" option; do
case $option in
d)
DRYRUN=1
;;
f)
FORCE=1
;;
h)
usage
exit 1
;;
l)
LATEST=1
FORCE=1
;;
v)
VERSION=$OPTARG
;;
esac
done
#set filename
if [[ ${LATEST} == 1 ]]; then
VFILE=voenabler-latest.zip
else
VFILE=voenabler-v${VERSION}.zip
fi
#check version naming
if [[ ! ${VERSION} =~ [0-9]\.[0-9]$ ]] && [[ ${LATEST} == 0 ]]; then
echo -e "\nError, VERSION string is incorrect (${VERSION}): expected x.y where x and y are integers\n"
exit 1
fi
createZip ${VFILE} ${FORCE} ${DRYRUN}