-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·197 lines (175 loc) · 5.37 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
#! /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
LOS_VER=19.1
VERSION_BRANCH=opt-cm-19.1
OUT="out/target/product/jflte"
ROM_VERSION=7.0
export ANDROID_HOME=~/Android/Sdk
# you may also need:
#sudo mkdir /mnt/ccache
sudo mount --bind /home/side/.ccache /mnt/ccache
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
export CCACHE_DIR=/mnt/ccache
buildTest()
{
export z=`date "+%H%M%S-%d%m%y"`
export OPTIMIZED_LINEAGEOS_VERSION="$ROM_VERSION - BETA"
export LOS_VER=19.1
echo "Building..."
make -j16 otapackage
#time schedtool -B -n 1 -e ionice -n 1 make otapackage -j10 "$@"
if [ "$?" == 0 ]; then
echo "Build done"
mv $OUT/lineage*.zip $OUT/OptLos-$LOS_VER-V$ROM_VERSION-$z.zip
adb shell twrp wipe cache
adb shell twrp wipe dalvik
adb shell twrp wipe data
adb shell twrp wipe system
adb push Opti* /sdcard
else
echo "Build failed"
fi
croot
}
buildRelease()
{
export OPTIMIZED_LINEAGEOS_VERSION="$ROM_VERSION - Release"
export LOS_VER=19.1
echo "Building..."
make -j16 otapackage
#time schedtool -B -n 1 -e ionice -n 1 make otapackage -j10 "$@"
if [ "$?" == 0 ]; then
echo "Build done"
mv $OUT/lineage*.zip Optimized-LineageOS-$LOS_VER-V$ROM_VERSION.zip
adb shell twrp wipe cache
adb shell twrp wipe dalvik
adb shell twrp wipe data
adb shell twrp wipe system
adb push Opti* /sdcard
else
echo "Build failed"
fi
croot
}
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/optlos.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"
}
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
ROOMSER=.repo/manifests/snippets/optlos.xml
# Lines to loop over
CHECK=$(cat ${ROOMSER} | grep -e "<project" | grep -e "jdc" | cut -d= -f3 | sed 's/remote//1' | sed 's/JDCTeam//1' | sed 's/\"//g' | sed 's/\///g' )
## Upstream merging for forked repos
while read -r line; do
x=$(echo ${line} | sed 's/_/\//1' | sed 's/android\///1' | sed 's/platform\///1' | sed 's/_/\//1' | sed 's/_/\//1' | sed 's/proprietary\///g' | sed 's/build/build\/make/g' | sed 's/-pie//g')
croot
cd "$x"
git remote add origin [email protected]:jdcteam/$line.git
#echo "$x"
#echo "git remote add origin [email protected]:jdcteam/$line.git"
#echo "----"
done <<< "$CHECK"
#Fix up manifest
cd .repo/manifests
git branch -D opt-cm-19.0
git checkout -b opt-cm-19.0
git remote remove origin
git remote add origin [email protected]:jdcteam/manifests.git
croot
echo " "
echo "Remotes refreshed..."
echo " "
}
buildAdiutor () {
croot
cd kerneladiutor
./gradlew clean
./gradlew build
}
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 ;
}
echo " "
echo -e "\e[1;91mWelcome to the $TEAM_NAME build script"
echo -e "\e[0m "
echo "Setting up build environment for $TARGET.."
. build/envsetup.sh && lunch lineage_$TARGET-userdebug
echo -e "\e[1;91mPlease make your selections carefully"
echo -e "\e[0m "
echo " "
select build in "Upstream merge" "Build Test" "Build Release" "Refresh remotes" "Produce audit2allow results" "Build Kernel Adiutor" "Exit"; do
case $build in
"Upstream merge" ) upstreamMerge; anythingElse; break;;
"Build Test" ) buildTest; anythingElse; break;;
"Build Release" ) buildRelease; 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