forked from phhusson/treble_experimentations
-
Notifications
You must be signed in to change notification settings - Fork 31
/
build-rom.sh
114 lines (96 loc) · 3.57 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
#!/bin/bash
rom_fp="$(date +%y%m%d)"
originFolder="$(dirname "$0")"
mkdir -p release/$rom_fp/
set -e
if [ "$#" -le 1 ];then
echo "Usage: $0 <android-8.1> <carbon|lineage|rr> '# of jobs'"
exit 0
fi
localManifestBranch=$1
rom=$2
if [ "$release" == true ];then
[ -z "$version" ] && exit 1
[ ! -f "$originFolder/release/config.ini" ] && exit 1
fi
if [ -z "$USER" ];then
export USER="$(id -un)"
fi
export LC_ALL=C
if [[ -n "$3" ]];then
jobs=$3
else
if [[ $(uname -s) = "Darwin" ]];then
jobs=$(sysctl -n hw.ncpu)
elif [[ $(uname -s) = "Linux" ]];then
jobs=$(nproc)
fi
fi
#We don't want to replace from AOSP since we'll be applying patches by hand
rm -f .repo/local_manifests/replace.xml
if [ "$rom" == "carbon" ];then
repo init -u https://github.com/CarbonROM/android -b cr-6.1
elif [ "$rom" == "lineage15" ];then
repo init -u https://github.com/LineageOS/android.git -b lineage-15.1
elif [ "$rom" == "lineage16" ];then
repo init -u https://github.com/LineageOS/android.git -b lineage-16.0
elif [ "$rom" == "rr" ];then
repo init -u https://github.com/ResurrectionRemix/platform_manifest.git -b pie
fi
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
if [ -z "$local_patches" ];then
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
else
rm -Rf patches
mkdir patches
unzip "$local_patches" -d patches
fi
#We don't want to replace from AOSP since we'll be applying patches by hand
rm -f .repo/local_manifests/replace.xml
repo sync -c -j$jobs --force-sync
rm -f device/*/sepolicy/common/private/genfs_contexts
(cd device/phh/treble; git clean -fdx; bash generate.sh $rom)
sed -i -e 's/BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736/BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648/g' device/phh/treble/phhgsi_arm64_a/BoardConfig.mk
if [ -f vendor/rr/prebuilt/common/Android.mk ];then
sed -i \
-e 's/LOCAL_MODULE := Wallpapers/LOCAL_MODULE := WallpapersRR/g' \
vendor/rr/prebuilt/common/Android.mk
fi
bash "$(dirname "$0")/apply-patches.sh" patches
. build/envsetup.sh
buildVariant() {
lunch $1
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
xz -c $OUT/system.img -T$jobs > release/$rom_fp/system-${2}.img.xz
}
repo manifest -r > release/$rom_fp/manifest.xml
buildVariant treble_arm64_avN-userdebug arm64-aonly-vanilla-nosu
buildVariant treble_arm64_agS-userdebug arm64-aonly-gapps-su
buildVariant treble_arm64_bvN-userdebug arm64-ab-vanilla-nosu
buildVariant treble_arm64_bgS-userdebug arm64-ab-gapps-su
buildVariant treble_arm_avN-userdebug arm-aonly-vanilla-nosu
buildVariant treble_arm_aoS-userdebug arm-aonly-gapps
buildVariant treble_a64_avN-userdebug arm32_binder64-aonly-vanilla-nosu
buildVariant treble_a64_agS-userdebug arm32_binder64-aonly-gapps-su
if [ "$release" == true ];then
(
rm -Rf venv
pip install virtualenv
export PATH=$PATH:~/.local/bin/
virtualenv -p /usr/bin/python3 venv
source venv/bin/activate
pip install -r $originFolder/release/requirements.txt
python $originFolder/release/push.py "${rom^}" "$version" release/$rom_fp/
rm -Rf venv
)
fi