-
Notifications
You must be signed in to change notification settings - Fork 4
/
zanata-overlay-build
executable file
·174 lines (149 loc) · 4.52 KB
/
zanata-overlay-build
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash -eu
### NAME
### zanata-overlay-build Build overlay zip
###
### SYNOPSIS
### zanata-overlay-build [Options] -a
### zanata-overlay-build [Options] <version>
###
### OPTIONS
### -h: Show this help
###
### -a: Automatic detected
### Version will be detected from latest tag from git.
###
### -w: WAR file
### WAR file to be include in overlay.
###
###
### DESCRIPTION
### This program builds overlay zip from
### zanata-client and zanata-server.
###
SCRIPT_DIR=$(dirname $(readlink -q -f $0))
FUNCTION_SCRIPT_FILE=${SCRIPT_DIR}/zanata-functions
source "${FUNCTION_SCRIPT_FILE}"
trap exit_print_error EXIT
PROGRAM_NAME=$(basename $0)
### ENVIRONMENT
### MYSQL_CONNECTOR_JAVA_VER
: ${MYSQL_CONNECTOR_JAVA_VER:=5.1.19}
###
### WILDFLY_CLUSTERING_SINGLETON_VER
: ${WILDFLY_CLUSTERING_SINGLETON_VER:=10.1.0.Final}
##=== function definition Start ===
function maven_jar_download(){
local remotePath=$1
local artifactId=$2
local version=$3
local relativeDir=${4-}
local destDir=${OverlayWorkDir}/${relativeDir}
mkdir -p $destDir
wget -c -P ${destDir} "http://central.maven.org/maven2/$remotePath/$artifactId/$version/$artifactId-$version.jar"
}
function overlay_pack(){
local distro=$1
mkdir -p $OverlayWorkDir/$VersionTag/$distro
cd $OverlayWorkDir/$VersionTag/$distro
print_status -t "overlay $distro" -s "Start"
local zanataOverlayDir=$RepoDir/server/zanata-overlay/
print_status "Copy overlay files"
cp -vR $zanataOverlayDir/common/bin .
cp -vR $zanataOverlayDir/common/standalone .
cp -vR $zanataOverlayDir/distros/$distro/standalone .
print_status "Copy deployment files"
mkdir -p standalone/deployments
cp -R ${DeployCommonDir} standalone/
cp ${LocalZanataWar} standalone/deployments
if [[ -d $OverlayWorkDir/modules ]];then
print_status "Copy module files"
cp -R ${OverlayWorkDir}/modules .
fi
zip -x '*.zip' -9 -r ../zanata-$Version-$distro.zip *
OverlayBuiltArray+=($OverlayWorkDir/$VersionTag/zanata-$Version-$distro.zip)
}
##=== parsing Start ===
print_status -t parsing -s "Start"
AutoDetect=0
War=
OverlayBuiltArray=()
while getopts "haw:" opt;do
case $opt in
h )
zanata_script_help $0
exit ${EXIT_OK}
;;
a )
AutoDetect=1
;;
w )
if [[ $OPTARG =~ ^/ ]]; then
War=$OPTARG
else
War=$PWD/$OPTARG
fi
;;
* )
failed ${EXIT_FATAL_INVALID_OPTIONS} "$opt"
;;
esac
done
shift $((OPTIND-1))
## Get RepoName
RepoName=zanata-platform
## Get Version
if [ ${AutoDetect} -eq 0 ];then
if [ -z "${1-}" ];then
zanata_script_help $0
EXIT_MSG="Requires version. Please either specify version or use option -a"
exit ${EXIT_FATAL_INVALID_OPTIONS}
fi
Version=$1
else
## Auto detect version
Version=$(detect_module_version ${RepoName})
print_status " ${RepoName} version: $Version"
test -n "$Version"
exit_if_failed "$?" ${EXIT_FATAL_FAIL} "Failed to get version from ${RepoName} git repo"
fi
VersionTag=platform-$Version
##=== prepare Start ===
print_status -t prepare -s "Start"
## Ensure repo
ensure_repo $RepoName
RepoDir=${WORK_ROOT}/${RepoName}
cd ${RepoDir}
git fetch
git checkout $VersionTag
##=== Download Dependencies Start ===
print_status -t "download dependency" -s "Start"
OverlayWorkDir=${WORK_ROOT}/overlay
mkdir -p ${OverlayWorkDir}
cd ${OverlayWorkDir}
DeployVerDir=${OverlayWorkDir}/$VersionTag/standalone/deployments
mkdir -p ${DeployVerDir}
DeployCommonDir=${OverlayWorkDir}/deployments
mkdir -p ${DeployCommonDir}
maven_jar_download mysql mysql-connector-java ${MYSQL_CONNECTOR_JAVA_VER}
cp mysql-connector-java-${MYSQL_CONNECTOR_JAVA_VER}.jar ${DeployCommonDir}/mysql-connector-java.jar
##=== Get War Start ===
print_status -t "Get WAR" -s "Start"
LocalZanataWar=${DeployVerDir}/zanata.war
if [ ! -r ${LocalZanataWar} ];then
if [ -n "${War-}" ];then
cp $War $LocalZanataWar
else
wget -c -P ${VersionTag} https://github.com/zanata/zanata-platform/releases/download/${VersionTag}/zanata-war-${Version}.war
cp ${OverlayWorkDir}/$VersionTag/zanata-war-${Version}.war $LocalZanataWar
fi
fi
##=== zip Start ===
print_status -t "zip" -s "Start"
overlay_pack eap-7
overlay_pack wildfly
##=== summary Start ===
print_status -t "summary" -s "Start"
print_status "Built overlay files are:"
for f in "${OverlayBuiltArray[@]}";do
echo_stderr $f
done