From 8187c23b38b388d6d82b0bc5f20250e1d64c897f Mon Sep 17 00:00:00 2001 From: Howard Chen Date: Mon, 13 Dec 2021 14:33:20 +0800 Subject: [PATCH] Update kernel prebuilts with local artifacts Bug: 198363484 Test: \ development/gsi/build_with_kernel/fetch_kernel.sh && \ development/gsi/build_with_kernel/repack_kernels.sh && \ development/gsi/build_with_kernel/update_kernel_prebuilts_510_arm64.sh Change-Id: I88e167be7aff70ff52abee875997d8e9a5c51e79 --- gsi/build_with_kernel/repack_kernels.sh | 2 +- .../repack_kernels_common.sh | 52 +++++++++++++++++++ .../update_kernel_prebuilts_510_arm64.sh | 22 ++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100755 gsi/build_with_kernel/update_kernel_prebuilts_510_arm64.sh diff --git a/gsi/build_with_kernel/repack_kernels.sh b/gsi/build_with_kernel/repack_kernels.sh index 4d28ea749..91e3d8070 100755 --- a/gsi/build_with_kernel/repack_kernels.sh +++ b/gsi/build_with_kernel/repack_kernels.sh @@ -34,4 +34,4 @@ prepare_kernel_image \ prepare_kernel_modules \ "artifacts/common-android13-5_10-kernel_virt_aarch64" \ "5.10" \ - "arm64" \ + "arm64" diff --git a/gsi/build_with_kernel/repack_kernels_common.sh b/gsi/build_with_kernel/repack_kernels_common.sh index e0df9956e..2d9bed32c 100755 --- a/gsi/build_with_kernel/repack_kernels_common.sh +++ b/gsi/build_with_kernel/repack_kernels_common.sh @@ -41,6 +41,10 @@ function prepare_lz4() fi } +# +# This function copies kernel prebuilts from build chaining path to a staging +# output directory. +# function prepare_kernel_image() { local prebuilt_path=$1 @@ -58,6 +62,8 @@ function prepare_kernel_image() fi mkdir -p "${out_root}" + + printf "%-38s %20s\n" "copy kernel ${kernel_version} ${arch} ${build_variant} to" "${out_root}" if [[ "$arch" == "x86_64" ]]; then cp "${prebuilts_root}/bzImage" "${out_root}/kernel-${kernel_version}${postfix}" else @@ -80,6 +86,10 @@ function prepare_kernel_image() EOF } +# +# This function copies kernel module prebuilts from the build chaining path to a +# staging output directory. +# function prepare_kernel_modules() { local prebuilt_path=$1 @@ -91,11 +101,53 @@ function prepare_kernel_modules() local dist_root="${DIST_DIR}/kernel/${kernel_version}" local initramfs_root="${out_root}/initramfs" + rm -rf ${initramfs_root} mkdir -p "${initramfs_root}" + printf "%-38s %20s\n" "copy kernel modules ${kernel_version} ${arch} to" "${initramfs_root}" "${LZ4}" -dcfm "${prebuilts_root}/initramfs.img" | (cd "${initramfs_root}"; cpio -imd) for x in $(find "${initramfs_root}" -type f -name "*.ko"); do cp "$x" "${out_root}" done } + +# +# This function updates kernel prebuilts with the local staging directory. +# +function update_kernel_prebuilts_with_artifact +{ + local kernel_version=$1 + local arch=$2 + local out_root="${OUT_DIR}/target/kernel/${kernel_version}/${arch}" + local prebuilts_dir="kernel/prebuilts/${kernel_version}/${arch}/" + local list="\ + kernel-5.10-allsyms \ + kernel-5.10-gz-allsyms \ + kernel-5.10-lz4-allsyms \ + kernel-5.10 \ + kernel-5.10-gz \ + kernel-5.10-lz4" + printf "%20s\n --> %20s\n" "${out_root}" "${prebuilts_dir}" + for f in ${list}; do + cp -f ${out_root}/$f ${prebuilts_dir} + done +} + +# +# This function updates kernel module prebuilts with the local staging directory. +# +function update_kernel_module_prebuilts_with_artifact +{ + local kernel_version=$1 + local arch=$2 + local out_root="${OUT_DIR}/target/kernel/${kernel_version}/${arch}" + local initramfs_root="${out_root}/initramfs" + local prebuilts_dir="kernel/prebuilts/common-modules/virtual-device/${kernel_version}/${arch}/" + + printf "%20s\n --> %20s\n" "${initramfs_root}" "${prebuilts_dir}" + rm -f ${prebuilts_dir}/*.ko + for x in $(find "${initramfs_root}" -type f -name "*.ko"); do + cp -f ${x} ${prebuilts_dir} + done +} diff --git a/gsi/build_with_kernel/update_kernel_prebuilts_510_arm64.sh b/gsi/build_with_kernel/update_kernel_prebuilts_510_arm64.sh new file mode 100755 index 000000000..21dd04ece --- /dev/null +++ b/gsi/build_with_kernel/update_kernel_prebuilts_510_arm64.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Copyright (C) 2021 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source development/gsi/build_with_kernel/repack_kernels_common.sh + +set -e + +update_kernel_prebuilts_with_artifact "5.10" "arm64" +update_kernel_module_prebuilts_with_artifact "5.10" "arm64"