diff options
author | Bowgo Tsai <bowgotsai@google.com> | 2022-09-06 20:50:32 +0800 |
---|---|---|
committer | Bowgo Tsai <bowgotsai@google.com> | 2022-09-12 07:36:02 +0000 |
commit | 648ec81fa7b200a05419b4b4a25a03cc1c9f6c4c (patch) | |
tree | 265795eed1ab8844609724daf2707791bb0c8e51 | |
parent | 94b78702ed8bb44efc4b4ca6e2a83f5f0e519d91 (diff) | |
download | build-648ec81fa7b200a05419b4b4a25a03cc1c9f6c4c.tar.gz |
Builds boot-img.tar.gz for x86_64 GKI
Unlike arm64 GKI, currently x86_64 GKI artifacts only
include a boot.img without a boot-img.tar.gz. To support
x86_64 GKI certification, we also need to build a
boot-img.tar.gz for the signing server to start GKI
certification process.
Bug: 241497048
Test: BUILD_CONFIG=common/build.config.gki.x86_64 build/build.sh
Change-Id: Iee877975c6b613af1fecb6dbc310988d465ec7f5
Signed-off-by: Bowgo Tsai <bowgotsai@google.com>
(cherry picked from commit 3567ad13950c2619c5e29918d257d12a548a7853)
-rwxr-xr-x | build.sh | 4 | ||||
-rw-r--r-- | build_utils.sh | 51 |
2 files changed, 24 insertions, 31 deletions
@@ -427,8 +427,8 @@ # ${DIST_DIR}. # # if defined when $ARCH is x86_64, build a boot.img with the kernel image, -# bzImage under ${DIST_DIR}. No boot-img.tar.gz will be generated because -# currently there is only a x86_64 GKI image: the bzImage. +# bzImage under ${DIST_DIR}. Additionally, create an archive boot-img.tar.gz +# containing boot.img. # # if defined when $ARCH is neither arm64 nor x86_64, print an error message # then exist the build process. diff --git a/build_utils.sh b/build_utils.sh index 4e70f9c5..aac2cb7d 100644 --- a/build_utils.sh +++ b/build_utils.sh @@ -560,26 +560,6 @@ function gki_add_avb_footer() { --partition_name boot --partition_size "$2" } -function build_gki_artifacts_x86_64() { - kernel_path="${DIST_DIR}/bzImage" - boot_image_path="${DIST_DIR}/boot.img" - - if ! [ -f "${kernel_path}" ]; then - echo "ERROR: '${kernel_path}' doesn't exist" >&2 - exit 1 - fi - - GKI_MKBOOTIMG_ARGS=("--header_version" "4") - if [ -n "${GKI_KERNEL_CMDLINE}" ]; then - GKI_MKBOOTIMG_ARGS+=("--cmdline" "${GKI_KERNEL_CMDLINE}") - fi - GKI_MKBOOTIMG_ARGS+=("--kernel" "${kernel_path}") - GKI_MKBOOTIMG_ARGS+=("--output" "${boot_image_path}") - "${MKBOOTIMG_PATH}" "${GKI_MKBOOTIMG_ARGS[@]}" - - gki_add_avb_footer "${boot_image_path}" "$(gki_get_boot_img_size)" -} - # gki_dry_run_certify_bootimg <boot_image> <gki_artifacts_info_file> # The certify_bootimg script will be executed on a server over a GKI # boot.img during the official certification process, which embeds @@ -609,12 +589,23 @@ function build_gki_artifacts_info() { echo "${artifacts_info}" > "$1" } -function build_gki_artifacts_aarch64() { - if ! [ -f "${DIST_DIR}/Image" ]; then - echo "ERROR: '${DIST_DIR}/Image' doesn't exist" >&2 +# build_gki_boot_images <uncompressed kernel path>. +# The function builds boot-*.img for kernel images +# with the prefix of <uncompressed kernel path>. +# It also generates a boot-img.tar.gz containing those +# boot-*.img files. The uncompressed kernel image should +# exist, e.g., ${DIST_DIR}/Image, while other compressed +# kernel images are optional, e.g., ${DIST_DIR}/Image.gz. +function build_gki_boot_images() { + local uncompressed_kernel_path=$1 + + if ! [ -f "${uncompressed_kernel_path}" ]; then + echo "ERROR: '${uncompressed_kernel_path}' doesn't exist" >&2 exit 1 fi + uncompressed_kernel_image="$(basename "${uncompressed_kernel_path}")" + DEFAULT_MKBOOTIMG_ARGS=("--header_version" "4") if [ -n "${GKI_KERNEL_CMDLINE}" ]; then DEFAULT_MKBOOTIMG_ARGS+=("--cmdline" "${GKI_KERNEL_CMDLINE}") @@ -624,15 +615,17 @@ function build_gki_artifacts_aarch64() { build_gki_artifacts_info "${GKI_ARTIFACTS_INFO_FILE}" local images_to_pack=("$(basename "${GKI_ARTIFACTS_INFO_FILE}")") - for kernel_path in "${DIST_DIR}"/Image*; do + # Compressed kernel images, e.g., Image.gz, Image.lz4 have the same + # prefix as the uncompressed kernel image, e.g., Image. + for kernel_path in "${uncompressed_kernel_path}"*; do GKI_MKBOOTIMG_ARGS=("${DEFAULT_MKBOOTIMG_ARGS[@]}") GKI_MKBOOTIMG_ARGS+=("--kernel" "${kernel_path}") - kernel_image="$(basename "${kernel_path}")" - if [ "${kernel_image}" == "Image" ]; then + if [ "${kernel_path}" = "${uncompressed_kernel_path}" ]; then boot_image="boot.img" else - compression="${kernel_image#Image.}" + kernel_image="$(basename "${kernel_path}")" + compression="${kernel_image#"${uncompressed_kernel_image}".}" boot_image="boot-${compression}.img" fi @@ -657,9 +650,9 @@ function build_gki_artifacts() { check_mkbootimg_path if [ "${ARCH}" = "arm64" ]; then - build_gki_artifacts_aarch64 + build_gki_boot_images "${DIST_DIR}/Image" elif [ "${ARCH}" = "x86_64" ]; then - build_gki_artifacts_x86_64 + build_gki_boot_images "${DIST_DIR}/bzImage" else echo "ERROR: unknown ARCH to BUILD_GKI_ARTIFACTS: '${ARCH}'" >&2 exit 1 |