-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·174 lines (145 loc) · 4.51 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
#!/bin/bash
echo
echo "--------------------------------------"
echo " AOSP 15.0 Buildbot "
echo " by "
echo " ponces "
echo "--------------------------------------"
echo
set -e
BL=$PWD/treble_aosp
BD=$PWD/duo-de/builds
BV=$1
initRepos() {
echo "--> Initializing workspace"
repo init -u https://android.googlesource.com/platform/manifest -b android-15.0.0_r5 --git-lfs
echo
echo "--> Preparing local manifest"
mkdir -p .repo/local_manifests
cp $BL/build/default.xml .repo/local_manifests/default.xml
cp $BL/build/remove.xml .repo/local_manifests/remove.xml
echo
}
syncRepos() {
echo "--> Syncing repos"
repo forall -c 'git checkout -f'
repo forall -c 'git clean -fd'
repo sync -c --force-sync --no-clone-bundle --no-tags -j$(nproc --all) || repo sync -c --force-sync --no-clone-bundle --no-tags -j$(nproc --all)
echo
}
applyPatches() {
echo "--> Applying TrebleDroid patches"
bash $BL/patch.sh $BL trebledroid
echo
echo "--> Applying personal patches"
bash $BL/patch.sh $BL personal
echo
echo "--> Applying DUO-DE patches"
bash $BL/patch.sh $BL duo
echo
echo "--> Generating makefiles"
cd device/phh/treble
cp $BL/build/aosp.mk .
bash generate.sh aosp
cd ../../..
echo
}
setupEnv() {
echo "--> Setting up build environment"
source build/envsetup.sh &>/dev/null
mkdir -p $BD
echo
}
buildTrebleApp() {
echo "--> Building treble_app"
cd treble_app
bash build.sh release
cp TrebleApp.apk ../vendor/hardware_overlay/TrebleApp/app.apk
cd ..
echo
}
buildVariant() {
echo "--> Building $1"
lunch "$1"-ap3a-userdebug
make -j$(nproc --all) installclean
make -j$(nproc --all) systemimage
make -j$(nproc --all) target-files-package otatools
bash $BL/sign.sh "../archfx-priv/keys" $OUT/signed-target_files.zip
unzip -jqo $OUT/signed-target_files.zip IMAGES/system.img -d $OUT
mv $OUT/system.img $BD/system-"$1".img
echo "image copied to $BD/system-"$1".img"
echo
}
buildVndkliteVariant() {
echo "--> Building $1-vndklite"
cd treble_adapter
sudo bash lite-adapter.sh "64" $BD/system-"$1".img
mv s.img $BD/system-"$1"-vndklite.img
sudo rm -rf d tmp
cd ..
echo
}
buildVariants() {
# buildVariant treble_a64_bvN
# buildVariant treble_a64_bgN
buildVariant treble_arm64_bgN
# buildVariant treble_arm64_bvN
# buildVndkliteVariant treble_a64_bvN
# buildVndkliteVariant treble_a64_bgN
# buildVndkliteVariant treble_arm64_bvN
# buildVndkliteVariant treble_arm64_bgN
}
generatePackages() {
echo "--> Generating packages"
buildDate="$(date +%Y%m%d)"
find $BD/ -name "system-treble_*.img" | while read file; do
filename="$(basename $file)"
[[ "$filename" == *"_a64"* ]] && arch="arm32_binder64" || arch="arm64"
[[ "$filename" == *"_bvN"* ]] && variant="vanilla" || variant="gapps"
[[ "$filename" == *"-vndklite"* ]] && vndk="-vndklite" || vndk=""
name="aosp-${arch}-ab-${variant}${vndk}-15.0-$buildDate"
xz -cv "$file" -T0 > $BD/"$name".img.xz
done
rm -rf $BD/system-*.img
echo
}
generateOta() {
echo "--> Generating OTA file"
version="$(date +v%Y.%m.%d)"
buildDate="$(date +%Y%m%d)"
timestamp="$START"
json="{\"version\": \"$version\",\"date\": \"$timestamp\",\"variants\": ["
find $BD/ -name "aosp-*-15.0-$buildDate.img.xz" | sort | {
while read file; do
filename="$(basename $file)"
[[ "$filename" == *"-arm32"* ]] && arch="a64" || arch="arm64"
[[ "$filename" == *"-vanilla"* ]] && variant="v" || variant="g"
[[ "$filename" == *"-vndklite"* ]] && vndk="-vndklite" || vndk=""
name="treble_${arch}_b${variant}N${vndk}"
size=$(wc -c $file | awk '{print $1}')
url="https://github.com/archfx/duo-de/releases/download/$version/$filename"
json="${json} {\"name\": \"$name\",\"size\": \"$size\",\"url\": \"$url\"},"
done
json="${json%?}]}"
echo "$json" | jq . > $BL/config/ota.json
}
echo
}
uploadOTA() {
bash $BL/upload.sh
}
START=$(date +%s)
# initRepos
# syncRepos
# applyPatches
# setupEnv
# buildTrebleApp
# buildVariants
# generatePackages
# generateOta
uploadOTA
END=$(date +%s)
ELAPSEDM=$(($(($END-$START))/60))
ELAPSEDS=$(($(($END-$START))-$ELAPSEDM*60))
echo "--> Buildbot completed in $ELAPSEDM minutes and $ELAPSEDS seconds"
echo