1#!/bin/bash 2 3# Thin wrapper around merge_target_files for vendor-frozen targets to 4# allow flag changes to be made in a presubmit-guarded change. 5 6set -e 7 8while getopts ":t:d:v:b:m:r:s:p:" option ; do 9 case "${option}" in 10 t) TARGET=${OPTARG} ;; 11 d) DIST_DIR=${OPTARG} ;; 12 v) VENDOR_DIR=${OPTARG} ;; 13 b) BUILD_ID=${OPTARG} ;; 14 m) MERGE_CONFIG_DIR=${OPTARG} ;; 15 r) HAS_RADIO_IMG=${OPTARG} ;; 16 s) TRUNK_STAGING=${OPTARG} ;; 17 p) SUPER_IMG=${OPTARG} ;; 18 *) echo "Unexpected argument: -${OPTARG}" >&2 ;; 19 esac 20done 21 22if [[ -z "${TARGET}" ]]; then 23 echo "error: -t target argument not set" 24 exit 1 25fi 26if [[ -z "${DIST_DIR}" ]]; then 27 echo "error: -d dist dir argument not set" 28 exit 1 29fi 30if [[ -z "${VENDOR_DIR}" ]]; then 31 echo "error: -v vendor dir argument not set" 32 exit 1 33fi 34if [[ -z "${BUILD_ID}" ]]; then 35 echo "error: -b build id argument not set" 36 exit 1 37fi 38if [[ -z "${HAS_RADIO_IMG}" ]]; then 39 HAS_RADIO_IMG="true" 40fi 41if [[ -z "${TRUNK_STAGING}" ]]; then 42 TARGET_RELEASE="${TARGET}" 43else 44 TARGET_RELEASE="${TARGET}-${TRUNK_STAGING}" 45fi 46if [[ -n "${SUPER_IMG}" ]]; then 47 BUILD_SUPER_IMG="true" 48fi 49 50# Move the system-only build artifacts to a separate folder 51# so that the flashing tools use the merged files instead. 52readonly SYSTEM_DIR=${DIST_DIR}/system_build 53mkdir -p ${SYSTEM_DIR} 54mv -f ${DIST_DIR}/android-info.txt ${SYSTEM_DIR} 55mv -f ${DIST_DIR}/${TARGET}-*.zip ${SYSTEM_DIR} 56 57source build/envsetup.sh 58lunch ${TARGET_RELEASE}-userdebug 59 60 61EXTRA_FLAGS="" 62if [[ "${MERGE_CONFIG_DIR}" ]]; then 63 EXTRA_FLAGS+=" --framework-item-list ${MERGE_CONFIG_DIR}/framework_item_list.txt \ 64 --framework-misc-info-keys ${MERGE_CONFIG_DIR}/framework_misc_info_keys.txt \ 65 --vendor-item-list ${MERGE_CONFIG_DIR}/vendor_item_list.txt" 66fi 67 68out/host/linux-x86/bin/merge_target_files \ 69 --framework-target-files ${SYSTEM_DIR}/${TARGET}-target_files*.zip \ 70 --vendor-target-files ${VENDOR_DIR}/*-target_files-*.zip \ 71 --allow-duplicate-apkapex-keys \ 72 --output-target-files ${DIST_DIR}/${TARGET}-target_files-${BUILD_ID}.zip \ 73 --output-img ${DIST_DIR}/${TARGET}-img-${BUILD_ID}.zip \ 74 --output-ota ${DIST_DIR}/${TARGET}-ota-${BUILD_ID}.zip \ 75 ${EXTRA_FLAGS} 76 77# Copy bootloader.img, radio.img, and android-info.txt, needed for flashing. 78cp ${VENDOR_DIR}/bootloader.img ${DIST_DIR}/bootloader.img 79# Copy radio.img unless arg is "false" (eg. Android TV targets) 80if [[ $HAS_RADIO_IMG = "true" ]]; then 81 cp ${VENDOR_DIR}/radio.img ${DIST_DIR}/radio.img 82fi 83 84# Copy vendor otatools.zip, needed by sign_target_files_apks 85if [[ -f "${VENDOR_DIR}/otatools.zip" ]]; then 86 cp ${VENDOR_DIR}/otatools.zip ${DIST_DIR}/otatools_vendor.zip 87fi 88 89#Build super image if required 90if [[ $BUILD_SUPER_IMG = "true" ]]; then 91 out/host/linux-x86/bin/build_super_image \ 92 ${DIST_DIR}/${TARGET}-target_files-${BUILD_ID}.zip \ 93 ${DIST_DIR}/super.img 94 unzip -j -o -d ${DIST_DIR} ${DIST_DIR}/${TARGET}-img-${BUILD_ID}.zip 95fi 96 97unzip -j -o -d ${DIST_DIR} \ 98 ${VENDOR_DIR}/*-target_files-*.zip \ 99 OTA/android-info.txt 100