forked from holatuwol/liferay-faster-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskipmp
executable file
·175 lines (127 loc) · 5.58 KB
/
skipmp
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
#!/bin/bash
checkappbnd() {
(
for dir in $(grep -F app.bnd ${GIT_ROOT}/.redeploy/lsfiles.txt | dirnames); do
if [ "" == "$(grep "^${dir}/.*/.lfrbuild-portal$" ${GIT_ROOT}/.redeploy/lsfiles.txt)" ]; then
continue
fi
echo ${dir}/app.bnd
done
) | xargs grep -F Liferay-Releng-App-Title | cut -d' ' -f 3-
}
dirnames() {
python $(dirname "${BASH_SOURCE[0]}")/dirnames.py
}
getparent() {
. $(dirname "${BASH_SOURCE[0]}")/getparent
}
lsfiles() {
git ls-files modules | grep -vF '/src/' > ${GIT_ROOT}/.redeploy/lsfiles.txt
if [ -f git-commit-portal ]; then
git ls-tree -r $(cat git-commit-portal) --name-only -- modules | grep -vF '/src/' >> ${GIT_ROOT}/.redeploy/lsfiles.txt
fi
cat .redeploy/lsfiles.txt | grep -F '/build.gradle' > ${GIT_ROOT}/.redeploy/gradle_list.txt
cat .redeploy/lsfiles.txt | grep -vF '/src/' | grep -F '/bnd.bnd' | xargs grep -F Bundle-SymbolicName | \
grep -vF '{' | sed 's/Bundle-SymbolicName: //g' > ${GIT_ROOT}/.redeploy/bnd_list.txt
}
setopts() {
. $(dirname "${BASH_SOURCE[0]}")/setopts
}
skipmp() {
if [ ! -f build.properties ]; then
return 0
fi
if [ -f build.$USER.properties ] && [ "" != "$(grep -F build.include.dirs build.properties)" ]; then
if [ "" != "$(grep -F build.include.dirs build.$USER.properties)" ]; then
echo "build.include.dirs has already been set in build.$USER.properties"
echo "Assuming that you do not want to use skipmp"
return 0
fi
if [ "" != "$(grep -F build.exclude.dirs build.$USER.properties)" ]; then
echo "build.exclude.dirs has already been set in build.$USER.properties"
echo "Assuming that you do not want to use skipmp"
return 0
fi
fi
git ls-files -v | grep '^h ' | cut -d' ' -f 2 | grep -F '.lfrbuild-portal' | xargs git update-index --no-assume-unchanged
git status | grep -F deleted | grep -F '.lfrbuild-portal' | cut -d':' -f 2 | xargs git checkout
getparent
lsfiles
if [ -f $HOME/lpkgs.txt ]; then
BUNDLE_APPS=$(cat $HOME/lpkgs.txt)
elif [ "7.0.x" == "${BASE_BRANCH}" ] || [ "7.0.x-private" == "${BASE_BRANCH}" ]; then
BUNDLE_APPS=$(echo -e 'Collaboration\nForms and Workflow\nFoundation\nStatic\nWeb Experience\nPush\nSAML 2.0 Provider')
else
BUNDLE_APPS=$(checkappbnd)
fi
echo "Restricting build to the following applications:"
echo "${BUNDLE_APPS}"
cat /dev/null > .excludes
for file in $(grep -F app.bnd ${GIT_ROOT}/.redeploy/lsfiles.txt); do
app=$(grep Liferay-Releng-App-Title $file | cut -d' ' -f 3-)
is_bundled=$(echo "$BUNDLE_APPS" | grep "^\s*${app}\s*\$")
if [ "" != "$is_bundled" ]; then
continue
fi
public_app="$(dirname $file)"
if [ "" == "$(grep "^${public_app}/.*/.lfrbuild-portal$" ${GIT_ROOT}/.redeploy/lsfiles.txt)" ]; then
continue
fi
echo $public_app >> .excludes
private_app="modules/private/$(echo $public_app | cut -d'/' -f 2-)"
if [ -d $private_app ]; then
echo $private_app >> .excludes
fi
done
for file in $(grep -F modules/private ${GIT_ROOT}/.redeploy/lsfiles.txt | grep -F .lfrbuild-portal | grep -F -- '-dxp'); do
public_app=$(echo $file | sed 's@/private/@/@g' | sed 's@-dxp@@g' | dirnames)
if [ -d $public_app ]; then
echo $public_app >> .excludes
fi
done
echo -en "\n\n"
if [[ 0 -eq $(cat .excludes | grep -c '^') ]]; then
echo "No modules will be excluded in this build"
rm .excludes
return 0
fi
cat .excludes
transitiveexcludes
local all_excludes=$(grep -Ff .excludes ${GIT_ROOT}/.redeploy/lsfiles.txt | grep -F .lfrbuild-portal | sort -u)
local git_excludes=$(cat .excludes | xargs git ls-files | grep -F .lfrbuild-portal | sort -u)
echo "$all_excludes" | dirnames | awk '{ print "Excluding " $1 }'
echo "$git_excludes" | xargs git update-index --assume-unchanged
echo "$all_excludes" | xargs rm -f
}
transitiveexcludes() {
if [[ 0 -eq $(cat .excludes | grep -c '^') ]]; then
return 0
fi
cp -f .excludes .excludes_transitive
old_count=0
new_count=$(cat .excludes | sort -u | grep -c '^')
while [[ $old_count -ne $new_count ]]; do
old_count=$new_count
cat /dev/null > .excludes_transitive
sed 's@^modules/private@@g' .excludes | sed 's@^modules@@g' | tr '/' ':' | sort -u | awk '{ print "provided project(\"" $1 ":" }' > .excludes_project
sed 's@^modules/private@@g' .excludes | sed 's@^modules@@g' | tr '/' ':' | sort -u | awk '{ print "provided project(\"" $1 "\"" }' >> .excludes_project
sed 's@^modules/private@@g' .excludes | sed 's@^modules@@g' | tr '/' ':' | sort -u | awk '{ print "compileOnly project(\"" $1 ":" }' >> .excludes_project
sed 's@^modules/private@@g' .excludes | sed 's@^modules@@g' | tr '/' ':' | sort -u | awk '{ print "compileOnly project(\"" $1 "\"" }' >> .excludes_project
sed 's@^modules/private@@g' .excludes | sed 's@^modules@@g' | tr '/' ':' | sort -u | awk '{ print "compileInclude project(\"" $1 ":" }' >> .excludes_project
sed 's@^modules/private@@g' .excludes | sed 's@^modules@@g' | tr '/' ':' | sort -u | awk '{ print "compileInclude project(\"" $1 "\"" }' >> .excludes_project
if [[ 0 -ne "$(grep -c '^' .excludes_project)" ]]; then
cat ${GIT_ROOT}/.redeploy/gradle_list.txt | xargs grep -lFf .excludes_project | dirnames >> .excludes_transitive
fi
grep -Ff .excludes ${GIT_ROOT}/.redeploy/bnd_list.txt | cut -d ':' -f 2 > .excludes_library
if [[ 0 -ne "$(grep -c '^' .excludes_library)" ]]; then
cat ${GIT_ROOT}/.redeploy/gradle_list.txt | xargs grep -lFf .excludes_library | dirnames >> .excludes_transitive
fi
mv .excludes .excludes_old
cat .excludes_old .excludes_transitive | sort -u > .excludes
rm .excludes_old .excludes_project .excludes_library
new_count=$(cat .excludes | grep -c '^')
done
rm -f .excludes_transitive
}
setopts
skipmp