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:" 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 # TODO(b/170638547) Remove the need for merge configs. 15 m) MERGE_CONFIG_DIR=${OPTARG} ;; 16 *) echo "Unexpected argument: -${OPTARG}" >&2 ;; 17 esac 18done 19 20if [[ -z "${TARGET}" ]]; then 21 echo "error: -t target argument not set" 22 exit 1 23fi 24if [[ -z "${DIST_DIR}" ]]; then 25 echo "error: -d dist dir argument not set" 26 exit 1 27fi 28if [[ -z "${VENDOR_DIR}" ]]; then 29 echo "error: -v vendor dir argument not set" 30 exit 1 31fi 32if [[ -z "${BUILD_ID}" ]]; then 33 echo "error: -b build id argument not set" 34 exit 1 35fi 36if [[ -z "${MERGE_CONFIG_DIR}" ]]; then 37 echo "error: -m merge config dir argument not set" 38 exit 1 39fi 40 41# Move the system-only build artifacts to a separate folder 42# so that the flashing tools use the merged files instead. 43readonly SYSTEM_DIR=${DIST_DIR}/system_build 44mkdir -p ${SYSTEM_DIR} 45mv -f ${DIST_DIR}/android-info.txt ${SYSTEM_DIR} 46mv -f ${DIST_DIR}/${TARGET}-*.zip ${SYSTEM_DIR} 47 48source build/envsetup.sh 49lunch ${TARGET}-userdebug 50 51out/host/linux-x86/bin/merge_target_files \ 52 --framework-target-files ${SYSTEM_DIR}/${TARGET}-target_files*.zip \ 53 --vendor-target-files ${VENDOR_DIR}/*-target_files-*.zip \ 54 --framework-item-list ${MERGE_CONFIG_DIR}/framework_item_list.txt \ 55 --framework-misc-info-keys ${MERGE_CONFIG_DIR}/framework_misc_info_keys.txt \ 56 --vendor-item-list ${MERGE_CONFIG_DIR}/vendor_item_list.txt \ 57 --allow-duplicate-apkapex-keys \ 58 --output-target-files ${DIST_DIR}/${TARGET}-target_files-${BUILD_ID}.zip \ 59 --output-img ${DIST_DIR}/${TARGET}-img-${BUILD_ID}.zip \ 60 --output-ota ${DIST_DIR}/${TARGET}-ota-${BUILD_ID}.zip 61 62# Copy bootloader.img, radio.img, and android-info.txt, needed for flashing. 63cp ${VENDOR_DIR}/bootloader.img ${DIST_DIR}/bootloader.img 64cp ${VENDOR_DIR}/radio.img ${DIST_DIR}/radio.img 65unzip -j -d ${DIST_DIR} \ 66 ${VENDOR_DIR}/*-target_files-*.zip \ 67 OTA/android-info.txt 68