forked from holatuwol/liferay-faster-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredeploy
executable file
·255 lines (191 loc) · 6.33 KB
/
redeploy
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/bash
applychanges() {
# If we specify 0, then don't compute any changes
if [ "0" == "$1" ]; then
return 0
fi
# Otherwise, compute all changes
if [ "" != "${NEW_BASELINE}" ]; then
$(dirname "${BASH_SOURCE[0]}")/gitchanges ${NEW_BASELINE}
elif [ "" == "$BASE_TAG" ]; then
$(dirname "${BASH_SOURCE[0]}")/gitchanges $BASE_BRANCH
else
$(dirname "${BASH_SOURCE[0]}")/gitchanges $BASE_TAG
fi
# If any of the folders that are affected is one that has
# one of the version range macros, make sure to fix it
for folder in $(git ls-files modules | grep build.gradle | xargs grep -l 'version: "\[' | dirnames); do
if [ "" != "$(grep -F "$folder" ${GIT_ROOT}/.redeploy/changes_gradle_2.txt)" ]; then
$(dirname "${BASH_SOURCE[0]}")/fixbnd $folder
fi
done
echo ""
echo "Deploying folders:"
cat ${GIT_ROOT}/.redeploy/changes_ant.txt | awk '{ print " * " $1 }'
echo ""
echo "Deploying modules:"
cat ${GIT_ROOT}/.redeploy/changes_gradle_1.txt ${GIT_ROOT}/.redeploy/changes_gradle_2.txt | awk '{ print " * " $1 }'
echo ""
# First, deploy portal libraries and global libraries
if [ "" != "$(grep '^lib/' ${GIT_ROOT}/.redeploy/changes.txt)" ]; then
echo "Deploying updated libraries"
if [ "" != "$(grep -F deploy-additional-jars ${GIT_ROOT}/build.xml)" ]; then
cd ${GIT_ROOT}
ant deploy-additional-jars
cd -
else
for file in $(grep '^lib/global/' ${GIT_ROOT}/.redeploy/changes.txt); do
cp $file $LIFERAY_HOME/$TOMCAT_FOLDER/lib/ext
done
for file in $(grep '^lib/portal/' ${GIT_ROOT}/.redeploy/changes.txt); do
cp $file $LIFERAY_HOME/$TOMCAT_FOLDER/webapps/ROOT/WEB-INF/lib
done
fi
fi
# Make sure that we have registry-api and anything else that is
# part of the portal-pre profile
checksnapshots
# Check to see if there is anything we need to deploy with ant
if [[ 0 -ne $(cat ${GIT_ROOT}/.redeploy/changes_gradle_1.txt | grep -c '^') ]] || [[ 0 -ne $(cat ${GIT_ROOT}/.redeploy/changes_ant.txt | grep -c '^') ]]; then
deployant
if [[ 0 -ne $? ]]; then
return 1
fi
if [ "" != "$(grep -F packageinfo ${GIT_ROOT}/.redeploy/changes.txt | grep -vF modules)" ]; then
cd modules/core/portal-bootstrap
gw deploy
cd -
fi
fi
# Finally, check to see if there is anything we need to deploy with gradle
if [[ 0 -ne $(cat ${GIT_ROOT}/.redeploy/changes_gradle_2.txt | grep -c '^') ]]; then
$(dirname "${BASH_SOURCE[0]}")/nodejs/cachenpm $NEW_BASELINE
deploymodules
if [[ 0 -ne $? ]]; then
return 1
fi
fi
if [ -f ${GIT_ROOT}/.redeploy/changes_ant.txt ] && [ "" != "$(grep util ${GIT_ROOT}/.redeploy/changes_ant.txt)" ]; then
if [ "ee-6.1.x" != "$BASE_BRANCH" ] && [ "ee-6.2.x" != "$BASE_BRANCH" ]; then
echo "Modified util-*.jar, must clear the osgi/state folder for WABs to be rebuilt"
fi
fi
# Undo changes to build-common.xml and modules/build.gradle
for file in build-common.xml modules/build.gradle; do
if [ ! -h $file ] && [ "" != "$(git ls-files $file)" ]; then
git checkout $file
fi
done
}
appserverprops() {
. $(dirname "${BASH_SOURCE[0]}")/appserverprops
}
cdroot() {
if [ -f "$GIT_ROOT/release.properties" ] || [ -f "${GIT_ROOT}/build-working-dir.xml" ]; then
builtin cd $GIT_ROOT
else
echo "Unable to find release.properties at version control root"
return 1
fi
}
checksnapshots() {
. $(dirname "${BASH_SOURCE[0]}")/checksnapshots
}
deployant() {
for folder in $(cat ${GIT_ROOT}/.redeploy/changes_ant.txt); do
if [ "" == "$(grep -F deploy $folder/build.xml)" ]; then
continue
fi
echo -e "\nBuilding $folder"
pushd $folder > /dev/null
if [ -f bnd.bnd ] && [ "" != "$(grep -F 'Bundle-Name' bnd.bnd)" ]; then
safeant deploy
elif [ "" != "$(grep -F deploy-fast build.xml)" ]; then
safeant deploy-fast
else
safeant deploy
fi
EXIT_STATUS=$?
popd > /dev/null
if [[ 0 -ne $EXIT_STATUS ]]; then
return $EXIT_STATUS
fi
done
}
deploymodules() {
cat /dev/null > ${GIT_ROOT}/.redeploy/changes_gradle_3.txt
for folder in $(cat ${GIT_ROOT}/.redeploy/changes_gradle_2.txt); do
if [ -f $folder/.lfrbuild-portal ]; then
export JENKINS_HOME=/tmp
local RELEASE_ID=$(echo $NEW_BASELINE | grep -o '[0-9]*$')
if [[ $NEW_BASELINE == fix-pack-* ]]; then
if [ "" == "$(grep -F hotfix $folder/bnd.bnd)" ]; then
sed -i.bak '/^Bundle-Version: /s@\(.*\)$@\1.hotfix-0-'${RELEASE_ID}'@g' $folder/bnd.bnd
fi
fi
echo $folder >> ${GIT_ROOT}/.redeploy/changes_gradle_3.txt
unziposgijar $folder
fi
done
cat /dev/null > ${GIT_ROOT}/.redeploy/deploy_gradle.txt
cat ${GIT_ROOT}/.redeploy/changes_gradle_3.txt | cut -d'/' -f 2- | tr '/' ':' | awk '{ print ":" $1 ":deploy" }' > ${GIT_ROOT}/.redeploy/deploy_gradle.txt
for module in $(cat ${GIT_ROOT}/.redeploy/changes_gradle_3.txt); do
if [ "" != "$(git ls-files $module | grep -F .jsp)" ]; then
echo "$module" | cut -d'/' -f 2- | tr '/' ':' | awk '{ print ":" $1 ":compileJSP" }' >> ${GIT_ROOT}/.redeploy/deploy_gradle.txt
fi
done
cd modules
cat ${GIT_ROOT}/.redeploy/deploy_gradle.txt | sort | xargs $(dirname "${BASH_SOURCE[0]}")/gw --continue
cd ..
}
dirnames() {
python $(dirname "${BASH_SOURCE[0]}")/dirnames.py
}
downloadbuild() {
. $(dirname "${BASH_SOURCE[0]}")/downloadbuild $1
}
gw() {
$(dirname "${BASH_SOURCE[0]}")/gw $@
}
install_jar() {
. $(dirname "${BASH_SOURCE[0]}")/installjar $1 $2 $3
}
redeploy() {
test -d ${LIFERAY_HOME} && find ${LIFERAY_HOME} -maxdepth 1 -type d -name 'tomcat-*' -exec rm -rf {} \;
rm -rf ${LIFERAY_HOME}/osgi ${LIFERAY_HOME}/tools ${LIFERAY_HOME}/work
rm -f ${LIFERAY_HOME}/.liferay-home ${LIFERAY_HOME}/.githash ${LIFERAY_HOME}/git-commit
downloadbuild $1 && applychanges $1
if [[ 0 -ne $? ]]; then
return 1
fi
appserverprops
$(dirname "${BASH_SOURCE[0]}")/dbjar
}
safeant() {
. $(dirname "${BASH_SOURCE[0]}")/nodejs/safeant $@
}
setopts() {
. $(dirname "${BASH_SOURCE[0]}")/setopts
}
unziposgijar() {
. $(dirname "${BASH_SOURCE[0]}")/unziposgijar $@
}
unzipportaljar() {
. $(dirname "${BASH_SOURCE[0]}")/unzipportaljar $@
}
setopts && cdroot
if [[ 0 -ne $? ]]; then
exit $?
fi
if [ -f git-commit-portal-ee ]; then
git clean -xdf -e '**/*.iml' -e '.gradle/gradle.properties' -e '.idea' -e '.m2' -e 'lib' -e "app.server.$USER.properties" -e "build.$USER.properties"
else
git clean -df
fi
CURRENT_HASH=$(git log -1 --pretty='%H')
appserverprops
if [[ 0 -ne $? ]]; then
exit $?
fi
mkdir -p "$HOME/.liferay/builds"
time redeploy $1