-
Notifications
You must be signed in to change notification settings - Fork 15
/
build_slider.sh
executable file
·142 lines (127 loc) · 5.03 KB
/
build_slider.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
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
function exit_if_error {
if [ $1 -ne 0 ]; then
echo "ERROR: $2: retval=$1" >&2
exit $1
fi
}
function add_boot_hash_footer {
eval `grep "\<BUILD_GKI_BOOT_IMG_LZ4_SIZE=" aosp/build.config.gki.aarch64`
local spl_month=$((($(date +'%m') + 3) % 12))
local spl_year="$(date +'%Y')"
if [ $((${spl_month} % 3)) -gt 0 ]; then
# Round up to the next quarterly platform release (QPR) month
spl_month=$((${spl_month} + 3 - (${spl_month} % 3)))
fi
if [ "${spl_month}" -lt "$(date +'%m')" ]; then
# rollover to the next year
spl_year="$((${spl_year} + 1))"
fi
local spl_date=$(printf "%d-%02d-05\n" ${spl_year} ${spl_month})
local additional_props=""
if [ -n "${spl_date}" ]; then
additional_props="--prop com.android.build.boot.security_patch:${spl_date}"
fi
build/kernel/build-tools/path/linux-x86/avbtool add_hash_footer \
--image ${DIST_DIR}/boot.img \
--partition_name boot \
--partition_size ${BUILD_GKI_BOOT_IMG_LZ4_SIZE} \
${additional_props}
}
BUILD_STAGING_KERNEL=${BUILD_STAGING_KERNEL:-0}
TRIM_NONLISTED_KMI=${TRIM_NONLISTED_KMI:-1}
LTO=${LTO:-thin}
KMI_SYMBOL_LIST_STRICT_MODE=${ENABLE_STRICT_KMI:-1}
DEFAULT_CONFIG="private/gs-google/build.config.slider"
DEVICE_KERNEL_BUILD_CONFIG=${DEVICE_KERNEL_BUILD_CONFIG:-${DEFAULT_CONFIG}}
GKI_KERNEL_PREBUILTS_DIR=
GKI_KERNEL_BUILD_CONFIG=
GKI_KERNEL_OUT_DIR=
CHECK_DIRTY_AOSP=0
MAKE_CORE_KERNEL=0
if [ "${BUILD_AOSP_KERNEL}" = "1" -o "${BUILD_STAGING_KERNEL}" = "1" -o -n "${GKI_DEFCONFIG_FRAGMENT}" ]; then
MAKE_CORE_KERNEL=1
else
CHECK_DIRTY_AOSP=1
MAKE_CORE_KERNEL=0
fi
if [ "${MAKE_CORE_KERNEL}" = "0" ]; then
USING_PREBUILTS=1
GKI_KERNEL_PREBUILTS_DIR=$(readlink -m "prebuilts/boot-artifacts/kernel/")
else
USING_PREBUILTS=
if [ "${BUILD_STAGING_KERNEL}" = "1" ]; then
GKI_KERNEL_OUT_DIR=android13-5.10-pixel-staging
GKI_KERNEL_BUILD_CONFIG=aosp-staging/build.config.gki.aarch64
else
GKI_KERNEL_OUT_DIR=android13-5.10
GKI_KERNEL_BUILD_CONFIG=aosp/build.config.gki.aarch64
fi
fi
if [ "${LTO}" = "none" ]; then
echo "LTO=none requires disabling KMI_SYMBOL_STRICT_MODE. Setting to 0..."
KMI_SYMBOL_LIST_STRICT_MODE=0
fi
if [ -n "${BUILD_ABI}" ]; then
echo "The ABI update workflow has changed. Please read go/gki-p21-workflow"
echo " for instructions on updating ABI/symbol list."
exit_if_error 1 "BUILD_ABI is deprecated"
fi
if [ "${MAKE_CORE_KERNEL}" = "0" ]; then
if [ "${LTO}" = "none" ]; then
echo "LTO=none requires BUILD_AOSP_KERNEL=1, BUILD_STAGING_KERNEL=1, or"
echo " GKI_DEFCONFIG_FRAGMENT to be set."
exit_if_error 1 "LTO=none requires building the kernel"
fi
elif [ "${BUILD_AOSP_KERNEL}" = "1" -a "${BUILD_STAGING_KERNEL}" = "1" ]; then
echo "BUILD_AOSP_KERNEL=1 is incompatible with BUILD_STAGING_KERNEL."
exit_if_error 1 "Flags incompatible with BUILD_AOSP_KERNEL detected"
fi
# These are for build.sh, so they should be exported.
export LTO
export KMI_SYMBOL_LIST_STRICT_MODE
export TRIM_NONLISTED_KMI
export BASE_OUT=${OUT_DIR:-out}/mixed/
export DIST_DIR=${DIST_DIR:-${BASE_OUT}/dist/}
export USING_PREBUILTS
DEVICE_KERNEL_BUILD_CONFIG=${DEVICE_KERNEL_BUILD_CONFIG} \
GKI_KERNEL_BUILD_CONFIG=${GKI_KERNEL_BUILD_CONFIG} \
GKI_KERNEL_OUT_DIR=${GKI_KERNEL_OUT_DIR} \
GKI_KERNEL_PREBUILTS_DIR=${GKI_KERNEL_PREBUILTS_DIR} \
GKI_DEFCONFIG_FRAGMENT=${GKI_DEFCONFIG_FRAGMENT} \
./build_mixed.sh "$@"
exit_if_error $? "Failed to create mixed build"
if [ -n "${USING_PREBUILTS}" ]; then
# Add an SPL to the prebuilt boot image so that you don't have to wipe your
# device when flashing. This is handled already when building the kernel.
add_boot_hash_footer
fi
if [ -f ${GKI_KERNEL_PREBUILTS_DIR}/vmlinux ]; then
SHA_FILE=vmlinux
else
SHA_FILE=boot.img
fi
# If BUILD_AOSP_KERNEL and BUILD_STAGING_KERNEL is not explicitly set,
# be sure that there are no aosp/ changes not present in the prebuilt.
if [ "${CHECK_DIRTY_AOSP}" != "0" ]; then
PREBUILTS_SHA=$(strings ${GKI_KERNEL_PREBUILTS_DIR}/${SHA_FILE} |
grep "Linux version 5.10" |
sed -n "s/^.*-g\([0-9a-f]\{12\}\)-.*/\1/p")
pushd aosp/ > /dev/null
# The AOSP sha can sometimes be longer than 12 characters; fix its length.
AOSP_SHA=$(git log -1 --abbrev=12 --pretty="format:%h")
if [ "${PREBUILTS_SHA}" != "${AOSP_SHA}" -o -n \
"$(git --no-optional-locks status -uno --porcelain ||
git diff-index --name-only HEAD)" ]; then
echo "WARNING: There are aosp/ changes which are not in the prebuilts."
echo " Because you did not specify BUILD_AOSP_KERNEL/BUILD_STAGING_KERNEL=0"
echo " or 1, $0 defaulted to building with"
echo " the prebuilts. Please be aware that your changes to aosp/ will not"
echo " be present in the final images. If you have made changes to aosp/,"
echo " it is recommended to explicitly set BUILD_AOSP_KERNEL/BUILD_STAGING_KERNEL=0"
echo " if you wish to use the prebuilts, or to 1 if you wish to build any"
echo " local changes you may have."
fi
popd > /dev/null
fi