-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·114 lines (97 loc) · 2.89 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
#!/bin/bash
#
# Copyright (C) 2019-2024 Panagiotis Englezos <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
#
# Override host metadata to make builds more reproducible and avoid leaking info
export BUILD_USERNAME=penglezos
export BUILD_HOSTNAME=android-build
# Device defaults
DEVICE='raphael'
BUILD_TYPE='userdebug'
# Setup ccache
export CCACHE_EXEC=$(command -v ccache)
export CCACHE_DIR=$(pwd)/.ccache
export USE_CCACHE=1
ccache -M 50G
# Setup zram
zram () {
sudo swapoff --all
sudo modprobe zram
sudo zramctl /dev/zram0 --algorithm zstd --size 64G
sudo mkswap -U clear /dev/zram0
sudo swapon --priority 100 /dev/zram0
}
# Clean sources
clean () {
source build/envsetup.sh
breakfast ${DEVICE} ${BUILD_TYPE}
make clean
}
installclean () {
source build/envsetup.sh
breakfast ${DEVICE} ${BUILD_TYPE}
make installclean
}
# Sync sources & apply patches
sync () {
repo init -u https://github.com/LineageOS/android.git -b lineage-21.0 --git-lfs
rm -rf .repo/local_manifests && mkdir -p .repo/local_manifests
curl https://raw.githubusercontent.com/penglezos/android_vendor_extra/lineage-21/.repo/local_manifests/lineage.xml -o .repo/local_manifests/lineage.xml
repo sync -c -j$(nproc --all) --force-sync --no-clone-bundle --no-tags
. build/envsetup.sh
croot
PATCHES_PATH=$PWD/vendor/extra/patches
for project_name in $(cd "${PATCHES_PATH}"; echo */); do
project_path="$(tr _ / <<<$project_name)"
cd $(gettop)/${project_path}
git am "${PATCHES_PATH}"/${project_name}/*.patch --no-gpg-sign
git am --abort &> /dev/null
done
croot
}
# Build ROM
build () {
source build/envsetup.sh
breakfast ${DEVICE} ${BUILD_TYPE}
make bacon
./tools/generatejson.sh
}
# Build kernel image
kernel () {
source build/envsetup.sh
breakfast ${DEVICE} ${BUILD_TYPE}
make bootimage
}
# Build recovery image
recovery () {
source build/envsetup.sh
breakfast ${DEVICE} ${BUILD_TYPE}
make recoveryimage
}
# Usage information when there are no arguments
if [[ $# -eq 0 ]]; then
echo -e "\nUsage: ./build.sh [options]\n"
echo "Options:"
echo " -z, --zram Setup zram"
echo " -c, --clean Clean entire build directory"
echo " -i, --installclean Dirty build"
echo " -s, --sync Sync sources and apply patches"
echo " -b, --build Perform ROM build"
echo " -k, --kernel Perform kernel image build"
echo " -r, --recovery Perform recovery image build"
echo ""
exit 0
fi
# Parse arguments
while [[ "$#" -gt 0 ]]; do case $1 in
-z|--zram) zram;;
-c|--clean) clean;;
-i|--installclean) installclean;;
-s|--sync) sync;;
-b|--build) build;;
-k|--kernel) kernel;;
-r|--recovery) recovery;;
*) echo "Unknown parameter passed: $1"; exit 1;;
esac; shift; done