• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:" 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    *) 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 "${HAS_RADIO_IMG}" ]]; then
37  HAS_RADIO_IMG="true"
38fi
39
40# Move the system-only build artifacts to a separate folder
41# so that the flashing tools use the merged files instead.
42readonly SYSTEM_DIR=${DIST_DIR}/system_build
43mkdir -p ${SYSTEM_DIR}
44mv -f ${DIST_DIR}/android-info.txt ${SYSTEM_DIR}
45mv -f ${DIST_DIR}/${TARGET}-*.zip ${SYSTEM_DIR}
46
47source build/envsetup.sh
48lunch ${TARGET}-userdebug
49
50EXTRA_FLAGS=""
51if [[ "${MERGE_CONFIG_DIR}" ]]; then
52  EXTRA_FLAGS+=" --framework-item-list ${MERGE_CONFIG_DIR}/framework_item_list.txt \
53  --framework-misc-info-keys ${MERGE_CONFIG_DIR}/framework_misc_info_keys.txt \
54  --vendor-item-list ${MERGE_CONFIG_DIR}/vendor_item_list.txt"
55fi
56out/host/linux-x86/bin/merge_target_files \
57  --framework-target-files ${SYSTEM_DIR}/${TARGET}-target_files*.zip \
58  --vendor-target-files ${VENDOR_DIR}/*-target_files-*.zip \
59  --allow-duplicate-apkapex-keys \
60  --output-target-files ${DIST_DIR}/${TARGET}-target_files-${BUILD_ID}.zip \
61  --output-img  ${DIST_DIR}/${TARGET}-img-${BUILD_ID}.zip \
62  --output-ota  ${DIST_DIR}/${TARGET}-ota-${BUILD_ID}.zip \
63  ${EXTRA_FLAGS}
64
65# Copy bootloader.img, radio.img, and android-info.txt, needed for flashing.
66cp ${VENDOR_DIR}/bootloader.img ${DIST_DIR}/bootloader.img
67# Copy radio.img unless arg is "false" (eg. Android TV targets)
68if [[ $HAS_RADIO_IMG = "true" ]]; then
69  cp ${VENDOR_DIR}/radio.img ${DIST_DIR}/radio.img
70fi
71
72# Copy vendor otatools.zip, needed by sign_target_files_apks
73if [[ -f "${VENDOR_DIR}/otatools.zip" ]]; then
74  cp ${VENDOR_DIR}/otatools.zip ${DIST_DIR}/otatools_vendor.zip
75fi
76
77unzip -j -d ${DIST_DIR} \
78  ${VENDOR_DIR}/*-target_files-*.zip \
79  OTA/android-info.txt