forked from AntaresOne/android_vendor_jdc
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·304 lines (284 loc) · 8.3 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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#! /bin/bash
# _____ __________
# __ / / _ \/ ___/_ _/__ ___ ___ _
# / // / // / /__ / // -_) _ `/ ' \
# \___/____/\___/ /_/ \__/\_,_/_/_/_/
#
# Copyright 2018 JDCTeam
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TEAM_NAME="JDCTeam"
TARGET=jflte
VARIANT=userdebug
LOS_VER=15.1
VERSION_BRANCH=opt-cm-15.1
OUT="out/target/product/jflte"
AROMA_DIR=aroma
ROM_VERSION=6
export OPTIMIZED_LINEAGEOS_VERSION=$ROM_VERSION
export ANDROID_HOME=~/Android/Sdk
buildROM()
{
echo "Building..."
time schedtool -B -n 1 -e ionice -n 1 make otapackage -j12 "$@"
if [ "$?" == 0 ]; then
echo "Build done"
mv $OUT/lineage*.zip $OUT/Optimized-LineageOS-15.1-Version$ROM_VERSION.zip
else
echo "Build failed"
fi
croot
}
anythingElse() {
echo " "
echo " "
echo "Anything else?"
select more in "Yes" "No"; do
case $more in
Yes ) bash build.sh; break;;
No ) exit 0; break;;
esac
done ;
}
getBuild() {
croot
rm -rf build
repo sync build/make
repo sync build/kati
repo sync build/soong
repo sync build/blueprint
echo -e "\e[1;91m==============================================================="
echo -e "\e[0m "
echo -e "\e[1;91mPlease update your device tree,aroma,Substratum"
echo ""
echo "==============================================================="
echo -e "\e[0m "
}
upstreamMerge() {
croot
echo "Refreshing manifest"
repo init -u git://github.com/"$TEAM_NAME"/manifests.git -b "$VERSION_BRANCH"
echo "Syncing projects"
repo sync --force-sync
echo "Upstream merging"
## Our snippet/manifest
ROOMSER=.repo/manifests/snippets/optcm.xml
# Lines to loop over
CHECK=$(cat ${ROOMSER} | grep -e "<remove-project" | cut -d= -f3 | sed 's/revision//1' | sed 's/\"//g' | sed 's|/>||g')
## Upstream merging for forked repos
while read -r line; do
echo "Upstream merging for $line"
rm -rf $line
repo sync $line
cd "$line"
git branch -D "$VERSION_BRANCH"
git checkout -b "$VERSION_BRANCH"
UPSTREAM=$(sed -n '1p' UPSTREAM)
BRANCH=$(sed -n '2p' UPSTREAM)
git pull https://www.github.com/"$UPSTREAM" "$BRANCH"
git push origin "$VERSION_BRANCH"
croot
done <<< "$CHECK"
}
useAroma()
{
LOG="Unzipping files to repack with AROMA..."/$(date +"%T")
if [ ! -d "$AROMA_DIR" ]; then
echo "No AROMA directory found.Please check your sources"
break;
fi
FILENAME=Optimized-LineageOS-"$LOS_VER"-"$(date +%Y%m%d)"-"$TARGET"-AROMA
echo " "
LATEST=$(ls -t | grep -v .zip.md5 | grep .zip | head -n 1)
TEMP2=tmpAroma
if [ -d "$TEMP2" ]; then
rm -rf "$TEMP2"
fi
mkdir "$TEMP2"
echo "Unpacking ROM to temp folder"
unzip -q "$LATEST" -d"$TEMP2"
echo "Removing META-INF folder"
rm -rf "$TEMP2"/META-INF
echo "Copying Aroma Installer"
cp -r "$AROMA_DIR"/jdc "$TEMP2"/jdc
cp -r "$AROMA_DIR"/xbin "$TEMP2"/xbin
cp -r "$AROMA_DIR"/META-INF "$TEMP2"/META-INF
cd "$TEMP2"
echo "Repacking ROM"
zip -rq9 ../"$FILENAME".zip *
cd ..
echo "Creating MD5"
md5sum "$FILENAME".zip > "$FILENAME".zip.md5
echo "Cleaning up"
rm -rf "$TEMP2"
echo "Done"
LOG="Added AROMA.Build finished successfully"/$(date +"%T")
}
audit ()
{
croot
rm -rf policies_from_audit.txt
cd external/selinux/prebuilts/bin
adb pull /sys/fs/selinux/policy
adb logcat -b all -d | ./audit2allow -p policy > ../../../../policies_from_audit.txt
echo " "
echo "Policies produced"
echo " "
}
createRemotes ()
{
croot
#vendor/jdc
cd vendor/jdc
git remote remove origin
git remote add origin [email protected]:jdcteam/android_vendor_jdc.git
croot
#vendor/samsung
cd vendor/samsung
git remote remove origin
git remote add origin [email protected]:jdcteam/proprietary_vendor_samsung.git
croot
#vendor/lineage
cd vendor/lineage
git remote remove origin
git remote add origin [email protected]:jdcteam/android_vendor_lineage.git
croot
#device/qcom/sepolicy
cd device/qcom/sepolicy
git remote remove origin
git remote add origin [email protected]:jdcteam/android_device_qcom_sepolicy.git
croot
#device/samsung/jf-common
cd device/samsung/jf-common
git remote remove origin
git remote add origin [email protected]:jdcteam/android_device_samsung_jf-common.git
croot
#device/samsung/jflte
cd device/samsung/jflte
git remote remove origin
git remote add origin [email protected]:jdcteam/android_device_samsung_jflte.git
croot
#device/samsung/qcom-common
cd device/samsung/qcom-common
git remote remove origin
git remote add origin [email protected]:jdcteam/android_device_samsung_qcom-common.git
croot
#packages/apps/Settings
cd packages/apps/Settings
git remote remove origin
git remote add origin [email protected]:jdcteam/android_packages_apps_Settings.git
croot
#packages/apps/LineageParts
cd packages/apps/LineageParts
git remote remove origin
git remote add origin [email protected]:jdcteam/android_packages_apps_LineageParts.git
croot
#packages/apps/CarrierConfig
cd packages/apps/CarrierConfig
git remote remove origin
git remote add origin [email protected]:jdcteam/android_packages_apps_CarrierConfig.git
croot
#frameworks/opt/telephony
cd frameworks/opt/telephony
git remote remove origin
git remote add origin [email protected]:jdcteam/android_frameworks_opt_telephony.git
croot
#aroma
cd AromaInstaller
git remote remove origin
git remote add origin [email protected]:jdcteam/AromaInstaller.git
croot
#dalvik
cd dalvik
git remote remove origin
git remote add origin [email protected]:jdcteam/android_dalvik.git
croot
#system/core
cd system/core
git remote remove origin
git remote add origin [email protected]:jdcteam/android_system_core.git
croot
#frameworks/base
cd frameworks/base
git remote remove origin
git remote add origin [email protected]:jdcteam/android_frameworks_base.git
croot
#bionic
cd bionic
git remote remove origin
git remote add origin [email protected]:jdcteam/android_bionic.git
croot
#art
cd art
git remote remove origin
git remote add origin [email protected]:jdcteam/android_art.git
croot
#lineage-sdk
cd lineage-sdk
git remote remove origin
git remote add origin [email protected]:jdcteam/android_lineage-sdk.git
croot
#build
cd build/make
git remote remove origin
git remote add origin [email protected]:jdcteam/android_build.git
croot
#soong
cd build/soong
git remote remove origin
git remote add origin [email protected]:jdcteam/android_build_soong.git
croot
#fw/native
cd frameworks/native
git remote remove origin
git remote add origin [email protected]:jdcteam/android_frameworks_native.git
croot
#adiutor
cd buffcoreapp
git remote remote origin
git remote add origin [email protected]:jdcteam/BuffCoreApp.git
croot
echo " "
echo "Remotes refreshed..."
echo " "
}
buildAdiutor () {
croot
cd kerneladiutor
./gradlew clean
./gradlew build
}
echo " "
echo -e "\e[1;91mWelcome to the $TEAM_NAME build script"
echo -e "\e[0m "
echo "Setting up build environment..."
. build/envsetup.sh > /dev/null
echo "Setting build target $TARGET""..."
lunch lineage_"$TARGET"-"$VARIANT" > /dev/null
echo " "
echo -e "\e[1;91mPlease make your selections carefully"
echo -e "\e[0m "
echo " "
select build in "Refresh manifest,repo sync and upstream merge" "Build ROM" "Add Aroma Installer to ROM" "Refresh build directory" "Refresh remotes" "Produce audit2allow results" "Build Kernel Adiutor" "Exit"; do
case $build in
"Refresh manifest,repo sync and upstream merge" ) upstreamMerge; getBuild;anythingElse; break;;
"Build ROM" ) buildROM; anythingElse; break;;
"Add Aroma Installer to ROM" ) useAroma; anythingElse; break;;
"Refresh build directory" ) getBuild; anythingElse; break;;
"Refresh remotes" ) createRemotes; anythingElse; break;;
"Produce audit2allow results" ) audit; anythingElse; break;;
"Build Kernel Adiutor" ) buildAdiutor; anythingElse; break;;
"Exit" ) exit 0; break;;
esac
done
exit 0