forked from phhusson/treble_experimentations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-rom.sh
executable file
·126 lines (112 loc) · 3.12 KB
/
build-rom.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
#!/bin/bash
if [[ ${0##*/} == -* ]]; then
echo "Do not source the file!"
echo "Run it as bash"
echo " ./build-rom.sh"
return 1
else
echo
fi
rom_fp="$(date +%y%m%d)"
mkdir -p release/$rom_fp/
set -e
nl=`echo -e $'\n.'`
nl=${nl%.}
read -e -i "android-8.1" -p "manifest branch for device tree: " localManifestBranch
echo -e $'\n'
read -e -i "all" -p "Type of build? $nl a for arm64 A_only partition $nl b for arm64 A/B $nl a_arm for arm A_only $nl 'all' for building all types $nl >> " buildtype
echo -e $'\n'
read -e -p "Number of jobs? (number) (def:all) " jobv
echo -e $'\n'
read -e -n1 -i "Y" -p "Sync the ROM again (Y/N) " syncv
echo -e $'\n'
read -e -n1 -i "Y" -p "Patch the ROM (Y/N) " patchv
echo -e $'\n'
read -e -n1 -i "Y" -p "Clean the build dir and trees? (Y/N) " cleanv
echo -e $'\n'
read -e -p "ROM name: " rom
if [ -n "$jobv" ]
then
jobs=$jobv
else
jobs=$(nproc)
fi
if [ "$syncv" = "Y" ]; then
echo "Syncing @ j=${jobs}"
if [ -d .repo/local_manifests ] ;then
( cd .repo/local_manifests; git fetch; git reset --hard; git checkout origin/$localManifestBranch)
else
git clone https://github.com/phhusson/treble_manifest .repo/local_manifests -b $localManifestBranch
fi
rm -f .repo/local_manifests/replace.xml
if [ -d patches ];then
( cd patches; git fetch; git reset --hard; git checkout origin/$localManifestBranch)
else
git clone https://github.com/phhusson/treble_patches patches -b $localManifestBranch
fi
repo sync -c -j${jobs} --force-sync
elif [ "$syncv" = "N" ]; then
echo "Will not sync"
else
exit "Wrong choice of sync"
fi
if [ "$cleanv" = "Y" ]; then
echo Cleaning
# We don't want to replace from AOSP since we'll be applying patches by hand
rm -f .repo/local_manifests/replace.xml
rm -f .repo/local_manifests/opengapps.xml
(cd device/phh/treble; git clean -fdx; bash generate.sh $rom)
elif [ "$cleanv" = "N" ]; then
echo "Will not clean the repos and DIRs"
else
exit "Wrong choice of clean"
fi
if [ "$patchv" = "Y" ]; then
echo Patching
bash "$(dirname "$0")/apply-patches.sh" patches
elif [ "$patchv" = "N" ]; then
echo "Will not patch"
else
exit "Wrong choice of patch"
fi
function buildVar {
. build/envsetup.sh
lunch $lname
make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp installclean
make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp -j${jobs} systemimage
make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp vndk-test-sepolicy
cp $OUT/system.img release/$rom_fp/system-${rom}-${lname}.img
repo manifest -r > release/$rom_fp/manifest.xml
}
function build {
echo "$nl Building $nl"
echo "Partition layout is:$nl $buildtype"
case $buildtype in
"a")
lname=treble_arm64_avN-userdebug
buildVar treble_arm64_avN-userdebug arm64-aonly
;;
"b")
lname=treble_arm64_bvN-userdebug
buildVar treble_arm64_bvN-userdebug arm64-ab
;;
"a_arm")
lname=treble_arm64_avN-userdebug
buildVar treble_arm_avN-userdebug arm-aonly
;;
"all")
lname=treble_arm64_avN-userdebug
buildVar treble_arm64_avN-userdebug arm64-aonly
lname=treble_arm64_bvN-userdebug
buildVar treble_arm64_bvN-userdebug arm64-ab
lname=treble_arm64_avN-userdebug
buildVar treble_arm_avN-userdebug arm-aonly
;;
*)
echo " Missing"
echo -e '\n'
echo "Chose a right build target"
exit 1
esac
}
build