forked from KoysX/treble_DerpFest_GSI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
133 lines (114 loc) · 3.21 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
#!/bin/bash
echo
echo "--------------------------------------"
echo " DerpFest AOSP 13.0 Build "
echo " by "
echo " KoysX "
echo " Origin author: ponces "
echo "--------------------------------------"
echo
set -e
BL=$PWD/treble_DerpFest_GSI
BD=$PWD/treble_DerpFest_GSI/GSI
initRepos() {
if [ ! -d .repo ]; then
echo "--> Initializing workspace"
repo init -u https://github.com/DerpFest-AOSP/manifest.git -b 13 --depth=1
echo
echo "--> Preparing local manifest"
mkdir -p .repo/local_manifests
cp $BL/manifest.xml .repo/local_manifests/aosp.xml
echo
fi
}
syncRepos() {
echo "--> Syncing repos"
repo sync -c --force-sync --optimized-fetch --no-tags --no-clone-bundle --prune -j8
echo
}
applyPatches() {
echo "--> Applying pre patches"
bash $BL/apply-patches.sh $BL pre
echo
echo "--> Applying trebledroid patches"
bash $BL/apply-patches.sh $BL trebledroid
echo
echo "--> Applying misc patches"
bash $BL/apply-patches.sh $BL misc
echo
echo "--> Generating makefiles"
cd device/phh/treble
cp $BL/derp.mk .
bash generate.sh derp
cd ../../..
echo
}
setupEnv() {
echo "--> Setting up build environment"
source build/envsetup.sh
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
}
buildGappsVariant() {
echo "--> Building treble_arm64_bgN"
lunch treble_arm64_bgN-userdebug
make -j$(nproc --all) installclean
make -j$(nproc --all) systemimage
mv $OUT/system.img $BD/system-treble_arm64_bgN.img
echo
}
generatePackages() {
echo "--> Generating packages"
buildDate="$(date +%Y%m%d)"
xz -cv $BD/system-treble_arm64_bvN.img -T0 > $BD/DerpFest-arm64_bvN-13.0-unofficial-$buildDate.img.xz
rm -rf $BD/system-*.img
echo
}
generateOta() {
echo "--> Generating OTA file"
version="$(date +v%Y.%m.%d)"
timestamp="$START"
json="{\"version\": \"$version\",\"date\": \"$timestamp\",\"variants\": ["
find $BD/ -name "DerpFest-*" | sort | {
while read file; do
filename="$(basename $file)"
if [[ $filename == *"mini"* ]]; then
name="treble_arm64_bgN-mini"
elif [[ $filename == *"pico"* ]]; then
name="treble_arm64_bgN-pico"
else
name="treble_arm64_bgN"
fi
size=$(wc -c $file | awk '{print $1}')
url="https://github.com/KoysX/treble_DerpFest_GSI/releases/download/$version/$filename"
json="${json} {\"name\": \"$name\",\"size\": \"$size\",\"url\": \"$url\"},"
done
json="${json%?}]}"
echo "$json" | jq . > $BL/ota.json
}
echo
}
START=$(date +%s)
initRepos
syncRepos
applyPatches
setupEnv
buildTrebleApp
buildGappsVariant
buildMiniVariant
buildPicoVariant
generatePackages
#generateOta
END=$(date +%s)
ELAPSEDM=$(($(($END-$START))/60))
ELAPSEDS=$(($(($END-$START))-$ELAPSEDM*60))
echo "--> Buildbot completed in $ELAPSEDM minutes and $ELAPSEDS seconds"
echo