diff options
author | Yi-Yo Chiang <yochiang@google.com> | 2021-04-29 20:10:36 +0800 |
---|---|---|
committer | Yi-Yo Chiang <yochiang@google.com> | 2021-05-08 20:14:35 +0800 |
commit | 075d444110b9881c2ee6298755617ece56e1f339 (patch) | |
tree | f3e9f6aee1c4114ad92d60801d1334d05b699875 | |
parent | fad827c2d15d004946b1dc76eb764a8d50841df0 (diff) | |
download | build-075d444110b9881c2ee6298755617ece56e1f339.tar.gz |
build.sh: Add INITRAMFS_VENDOR_RAMDISK_FRAGMENT_NAME
Add option to package kernel modules initramfs as a standalone ramdisk
fragment. Useful for testing as the entire set of kernel modules can be
replaced by post-processing.
Bug: 184490452
Test: Set INITRAMFS_VENDOR_RAMDISK_FRAGMENT_NAME and
INITRAMFS_VENDOR_RAMDISK_FRAGMENT_MKBOOTIMG_ARGS and build
Test: Presubmit
Change-Id: I76d20e4afc1888c09adc257adab3ff7c4cc2c868
-rwxr-xr-x | build.sh | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -214,6 +214,11 @@ # blocklist module_name # If BOOT_IMAGE_HEADER_VERSION >= 4, the following variable can be defined: # - VENDOR_BOOTCONFIG=<string of bootconfig parameters> +# - INITRAMFS_VENDOR_RAMDISK_FRAGMENT_NAME=<name of the ramdisk fragment> +# If BUILD_INITRAMFS is specified, then build the .ko and depmod files as +# a standalone vendor ramdisk fragment named as the given string. +# - INITRAMFS_VENDOR_RAMDISK_FRAGMENT_MKBOOTIMG_ARGS=<mkbootimg arguments> +# Refer to: https://source.android.com/devices/bootloader/partitions/vendor-boot-partitions#mkbootimg-arguments # # VENDOR_RAMDISK_CMDS # When building vendor boot image, VENDOR_RAMDISK_CMDS enables the build @@ -1116,22 +1121,29 @@ if [ ! -z "${BUILD_BOOT_IMG}" ] ; then cp "${VENDOR_FSTAB}" "${MKBOOTIMG_RAMDISK_STAGING_DIR}/first_stage_ramdisk/" fi + HAS_RAMDISK= MKBOOTIMG_RAMDISK_DIRS=() if [ -f "${VENDOR_RAMDISK_BINARY}" ] || [ -f "${VENDOR_FSTAB}" ]; then + HAS_RAMDISK="1" MKBOOTIMG_RAMDISK_DIRS+=("${MKBOOTIMG_RAMDISK_STAGING_DIR}") fi if [ "${BUILD_INITRAMFS}" = "1" ]; then - MKBOOTIMG_RAMDISK_DIRS+=("${INITRAMFS_STAGING_DIR}") + HAS_RAMDISK="1" + if [ -z "${INITRAMFS_VENDOR_RAMDISK_FRAGMENT_NAME}" ]; then + MKBOOTIMG_RAMDISK_DIRS+=("${INITRAMFS_STAGING_DIR}") + fi + fi + + if [ -z "${HAS_RAMDISK}" ] && [ -z "${SKIP_VENDOR_BOOT}" ]; then + echo "No ramdisk found. Please provide a GKI and/or a vendor ramdisk." + exit 1 fi if [ "${#MKBOOTIMG_RAMDISK_DIRS[@]}" -gt 0 ]; then MKBOOTIMG_RAMDISK_CPIO="${MKBOOTIMG_STAGING_DIR}/ramdisk.cpio" mkbootfs "${MKBOOTIMG_RAMDISK_DIRS[@]}" >"${MKBOOTIMG_RAMDISK_CPIO}" ${RAMDISK_COMPRESS} "${MKBOOTIMG_RAMDISK_CPIO}" >"${DIST_DIR}/ramdisk.${RAMDISK_EXT}" - elif [ -z "${SKIP_VENDOR_BOOT}" ]; then - echo "No ramdisk found. Please provide a GKI and/or a vendor ramdisk." - exit 1 fi if [ -z "${MKBOOTIMG_PATH}" ]; then @@ -1170,6 +1182,15 @@ if [ ! -z "${BUILD_BOOT_IMG}" ] ; then if [ -f "${DIST_DIR}/ramdisk.${RAMDISK_EXT}" ]; then MKBOOTIMG_ARGS+=("--vendor_ramdisk" "${DIST_DIR}/ramdisk.${RAMDISK_EXT}") fi + if [ "${BUILD_INITRAMFS}" = "1" ] \ + && [ -n "${INITRAMFS_VENDOR_RAMDISK_FRAGMENT_NAME}" ]; then + MKBOOTIMG_ARGS+=("--ramdisk_type" "DLKM") + for MKBOOTIMG_ARG in ${INITRAMFS_VENDOR_RAMDISK_FRAGMENT_MKBOOTIMG_ARGS}; do + MKBOOTIMG_ARGS+=("${MKBOOTIMG_ARG}") + done + MKBOOTIMG_ARGS+=("--ramdisk_name" "${INITRAMFS_VENDOR_RAMDISK_FRAGMENT_NAME}") + MKBOOTIMG_ARGS+=("--vendor_ramdisk_fragment" "${DIST_DIR}/initramfs.img") + fi fi else if [ -f "${DIST_DIR}/ramdisk.${RAMDISK_EXT}" ]; then |