Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 1 | #!/bin/bash -ex |
| 2 | usage () { |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 3 | echo "Create a Mixed Build archive with the given system and device archives." |
| 4 | echo |
| 5 | echo "Usage: $0 [-v <vendor_version>] [-m <modify_system_image_path>]" |
| 6 | echo " [-t <prebuilt_otatools_path>] [-p <override_vbmeta_image_path>]" |
| 7 | echo " [-b <override_boot_image_path>]" |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 8 | echo " [-s] system_build_dir device_build_dir out_dir" |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 9 | echo |
| 10 | echo "Options -v, -m, -t, -p, -b, -s must precede positional arguments." |
| 11 | echo |
| 12 | echo "vendor_version is the version of the vendor image when Keymaster v3" |
| 13 | echo " related modifications to the system image is necessary. Optional." |
| 14 | echo " eg. 8.1.0 for a mixed build of GSI and O-MR1 vendor image." |
| 15 | echo "modify_system_image_path is the path to the script that modifies the" |
| 16 | echo " system image, needed for Keymaster v3. Optional." |
| 17 | echo "prebuilt_otatools_path is the path to otatools.zip file that has all" |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 18 | echo " required host binaries to modify system image. It also must include" |
| 19 | echo " VINTF check tool to verify the compatibility of the given images." |
| 20 | echo " Optional." |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 21 | echo "override_vbmeta_image_path is the path to a vbmeta.img to use" |
| 22 | echo " to override the existing vbmeta.img of device. Optional." |
| 23 | echo "override_boot_image_path is the path to a boot imgage to use to" |
| 24 | echo " override the existing boot.img of device. Optional." |
| 25 | echo "-s is used to fetch and flash both product.img and system.img from" |
| 26 | echo " the system_build_dir for devices with a product partition." |
| 27 | echo " product.img will be removed if system_build_dir does not have" |
| 28 | echo " product.img when -s option is declared." |
| 29 | echo " By default, only system.img is flashed to the target device for" |
| 30 | echo " independent system update. No parameter required. Optional" |
| 31 | echo "system_build_dir is the path to the system build" |
| 32 | echo " eg. aosp_arm64_ab-userdebug." |
| 33 | echo "device_build_dir is the path to the device build" |
| 34 | echo " eg. sailfish-user." |
| 35 | echo "out_dir is the path to where the new build will be placed." |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 38 | # Print error message and exit. |
| 39 | # Usage: exit_badparam message |
| 40 | # |
| 41 | # message is a string to be displayed before exit. |
| 42 | exit_badparam () { |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 43 | echo "ERROR: $1" >&2 |
| 44 | usage |
| 45 | exit 1 |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | cleanup_and_exit () { |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 49 | readonly result="$?" |
| 50 | rm -rf "$TEMP_DIR" |
| 51 | exit "$result" |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | trap cleanup_and_exit EXIT |
| 55 | |
Hyunwoo Ko | 22da157 | 2019-05-16 18:01:35 +0900 | [diff] [blame] | 56 | while getopts :v:m:p:b:t:s opt; do |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 57 | case "$opt" in |
| 58 | v) |
| 59 | readonly VENDOR_VERSION="$OPTARG" |
| 60 | ;; |
| 61 | m) |
| 62 | readonly MODIFY_SYSTEM_SCRIPT="$OPTARG" |
| 63 | ;; |
| 64 | p) |
| 65 | readonly OVERRIDE_VBMETA_IMAGE_PATH="$OPTARG" |
| 66 | ;; |
| 67 | b) |
| 68 | readonly OVERRIDE_BOOT_IMAGE_PATH="$OPTARG" |
| 69 | ;; |
| 70 | t) |
| 71 | readonly OTATOOLS_ZIP="$OPTARG" |
| 72 | ;; |
| 73 | s) |
| 74 | readonly INCLUDE_PRODUCT=true |
| 75 | ;; |
| 76 | \?) |
| 77 | exit_badparam "Invalid options: -"$OPTARG"" |
| 78 | ;; |
| 79 | :) |
| 80 | exit_badparam "Option -"$OPTARG" requires an argument." |
| 81 | ;; |
| 82 | esac |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 83 | done |
| 84 | |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 85 | if [[ -z "${VENDOR_VERSION+x}" && ! -z "${MODIFY_SYSTEM_SCRIPT+x}" ]] || \ |
| 86 | [[ ! -z "${VENDOR_VERSION+x}" && -z "${MODIFY_SYSTEM_SCRIPT+x}" ]]; then |
| 87 | exit_badparam "Options -v and -m must be set together." |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 88 | fi |
| 89 | |
| 90 | shift "$((OPTIND-1))" |
| 91 | |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 92 | if [[ $# -lt 3 ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 93 | exit_badparam "Unexpected number of arguments" |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 94 | fi |
| 95 | |
Jae Shin | 341a55f | 2018-06-04 16:55:26 +0900 | [diff] [blame] | 96 | readonly SYSTEM_DIR="$1" |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 97 | readonly DEVICE_DIR="$2" |
| 98 | readonly DIST_DIR="$3" |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 99 | readonly TEMP_DIR="$(mktemp -d /tmp/"$(basename $0)"_XXXXXXXX)" |
| 100 | |
Justin Yun | 83631d6 | 2018-10-05 14:24:12 +0900 | [diff] [blame] | 101 | readonly SYSTEM_TARGET_FILES_ARCHIVE="$(find "$SYSTEM_DIR" -name "*-target_files-*.zip" -print)" |
Jae Shin | 341a55f | 2018-06-04 16:55:26 +0900 | [diff] [blame] | 102 | if [[ ! -f "$SYSTEM_TARGET_FILES_ARCHIVE" ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 103 | exit_badparam "Could not find system target files archive in $SYSTEM_DIR." |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 104 | fi |
| 105 | |
Justin Yun | 83631d6 | 2018-10-05 14:24:12 +0900 | [diff] [blame] | 106 | readonly DEVICE_ARCHIVE="$(find "$DEVICE_DIR" -name "*-img-*.zip" -print)" |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 107 | if [[ ! -f "$DEVICE_ARCHIVE" ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 108 | exit_badparam "Could not find device img archive in $DEVICE_DIR." |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 109 | fi |
| 110 | |
Justin Yun | 83631d6 | 2018-10-05 14:24:12 +0900 | [diff] [blame] | 111 | readonly DEVICE_TARGET_FILES_ARCHIVE="$(find "$DEVICE_DIR" -name "*-target_files-*.zip" -print)" |
Paul Trautrim | d2d8ac9 | 2018-06-29 16:19:10 +0900 | [diff] [blame] | 112 | if [[ ! -f "$DEVICE_TARGET_FILES_ARCHIVE" ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 113 | exit_badparam "Could not find device target_files archive in $DEVICE_DIR." |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 114 | fi |
| 115 | |
Jae Shin | f418b9b | 2018-08-09 12:57:20 +0900 | [diff] [blame] | 116 | if [[ ! -z "${MODIFY_SYSTEM_SCRIPT+x}" && ! -f "$MODIFY_SYSTEM_SCRIPT" ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 117 | exit_badparam "Script not found: "$MODIFY_SYSTEM_SCRIPT"" |
Jae Shin | f418b9b | 2018-08-09 12:57:20 +0900 | [diff] [blame] | 118 | fi |
| 119 | |
| 120 | if [[ ! -z "${OVERRIDE_VBMETA_IMAGE_PATH+x}" && ! -f "$OVERRIDE_VBMETA_IMAGE_PATH" ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 121 | exit_badparam "Specified vbmeta.img not found: "$OVERRIDE_VBMETA_IMAGE_PATH"" |
Jae Shin | f418b9b | 2018-08-09 12:57:20 +0900 | [diff] [blame] | 122 | fi |
| 123 | |
Hyunwoo Ko | 22da157 | 2019-05-16 18:01:35 +0900 | [diff] [blame] | 124 | if [[ ! -z "${OVERRIDE_BOOT_IMAGE_PATH+x}" && ! -f "$OVERRIDE_BOOT_IMAGE_PATH" ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 125 | exit_badparam "Specified boot image not found: "$OVERRIDE_BOOT_IMAGE_PATH"" |
Hyunwoo Ko | 22da157 | 2019-05-16 18:01:35 +0900 | [diff] [blame] | 126 | fi |
| 127 | |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 128 | readonly DEVICE_ARTIFACTS_DIR="$TEMP_DIR"/device_archive_artifacts |
| 129 | readonly DEVICE_IMAGES_DIR="$DEVICE_ARTIFACTS_DIR"/IMAGES |
Jae Shin | 341a55f | 2018-06-04 16:55:26 +0900 | [diff] [blame] | 130 | readonly SYSTEM_ARTIFACTS_DIR="$TEMP_DIR"/system_artifacts |
| 131 | readonly SYSTEM_IMAGES_DIR="$SYSTEM_ARTIFACTS_DIR"/IMAGES |
Justin Yun | 40da678 | 2018-10-05 14:54:17 +0900 | [diff] [blame] | 132 | readonly OTATOOLS_DIR="$TEMP_DIR"/otatools |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 133 | |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 134 | readonly SPL_PROPERTY_NAME="ro.build.version.security_patch" |
| 135 | readonly SYSTEM_BUILD_PROP="SYSTEM/build.prop" |
| 136 | |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 137 | declare -a EXTRACT_SYSTEM_FILE_LIST |
| 138 | EXTRACT_SYSTEM_FILE_LIST=( |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 139 | IMAGES/system.img \ |
| 140 | IMAGES/vbmeta.img \ |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 141 | "$SYSTEM_BUILD_PROP" \ |
Justin Yun | 07a77c8 | 2018-11-20 13:12:12 +0900 | [diff] [blame] | 142 | ) |
| 143 | |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 144 | declare -a EXTRACT_VINTF_SYSTEM_FILE_LIST |
| 145 | EXTRACT_VINTF_SYSTEM_FILE_LIST=( |
| 146 | "$SYSTEM_BUILD_PROP" \ |
| 147 | ) |
Justin Yun | 07a77c8 | 2018-11-20 13:12:12 +0900 | [diff] [blame] | 148 | |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 149 | declare -a EXTRACT_DEVICE_FILE_LIST |
| 150 | EXTRACT_DEVICE_FILE_LIST=( |
| 151 | */build.prop \ |
| 152 | META/* \ |
| 153 | ) |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 154 | |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 155 | declare -A SYSTEM_SEARCH_PATH |
| 156 | SYSTEM_SEARCH_PATH=( \ |
| 157 | [/system]="SYSTEM" \ |
| 158 | [/product]="PRODUCT SYSTEM/product" \ |
| 159 | [/system_ext]="SYSTEM_EXT SYSTEM/system_ext" \ |
| 160 | ) |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 161 | |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 162 | declare -A DEVICE_SEARCH_PATH |
| 163 | # Mixed build will not have /vendor to SYSTEM/vendor case |
| 164 | DEVICE_SEARCH_PATH=( \ |
| 165 | [/vendor]="VENDOR" \ |
| 166 | [/odm]="ODM VENDOR/odm" \ |
| 167 | ) |
| 168 | |
| 169 | ### |
| 170 | # Uncompress otatools.zip and get vintf file list. |
| 171 | if [[ ! -f "$OTATOOLS_ZIP" ]]; then |
| 172 | echo "WARNING: otatools.zip is missing. Add \"-t otatools.zip\" to enable checkvintf" |
| 173 | else |
| 174 | readonly OTATOOLS_AVAILABLE=true |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 175 | # Uncompress otatools |
| 176 | mkdir -p "$OTATOOLS_DIR" |
| 177 | unzip "$OTATOOLS_ZIP" bin/* lib64/* -d "$OTATOOLS_DIR" |
| 178 | # Set paths for using prebuilt host binaries. |
| 179 | export PATH="$OTATOOLS_DIR"/bin:"$PATH" |
| 180 | export LD_LIBRARY_PATH="$OTATOOLS_DIR"/lib64:"$LD_LIBRARY_PATH" |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 181 | |
| 182 | # Add vintf file to extract file list |
| 183 | declare -a VINTF_DUMP_FILE_LIST |
| 184 | VINTF_DUMP_FILE_LIST=( "$(checkvintf --dump-file-list)" ) |
| 185 | |
| 186 | for vintf_file_list in ${VINTF_DUMP_FILE_LIST[*]}; do |
| 187 | if [[ "$vintf_file_list" == */ ]]; then |
| 188 | vintf_file_list="$vintf_file_list"\* |
| 189 | # Create system vintf file list for system target files archive |
| 190 | for system_dir in "${!SYSTEM_SEARCH_PATH[@]}"; do |
| 191 | if [[ "$vintf_file_list" == "$system_dir"/* ]]; then |
| 192 | for search_dir in ${SYSTEM_SEARCH_PATH["$system_dir"]}; do |
| 193 | search_file=${vintf_file_list/$system_dir/$search_dir} |
| 194 | unzip -l "$SYSTEM_TARGET_FILES_ARCHIVE" "$search_file" > /dev/null && \ |
| 195 | EXTRACT_VINTF_SYSTEM_FILE_LIST+=( "$search_file" ) |
| 196 | done |
| 197 | break |
| 198 | fi |
| 199 | done |
| 200 | # Create device vintf file list for device target files archive |
| 201 | for device_dir in "${!DEVICE_SEARCH_PATH[@]}"; do |
| 202 | if [[ "$vintf_file_list" == "$device_dir"/* ]]; then |
| 203 | for search_dir in ${DEVICE_SEARCH_PATH["$device_dir"]}; do |
| 204 | search_file=${vintf_file_list/$device_dir/$search_dir} |
| 205 | unzip -l "$DEVICE_TARGET_FILES_ARCHIVE" "$search_file" > /dev/null && \ |
| 206 | EXTRACT_DEVICE_FILE_LIST+=( "$search_file" ) |
| 207 | done |
| 208 | break |
| 209 | fi |
| 210 | done |
| 211 | fi |
| 212 | done |
Justin Yun | 40da678 | 2018-10-05 14:54:17 +0900 | [diff] [blame] | 213 | fi |
| 214 | |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 215 | ### |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 216 | # Uncompress the system archives. |
| 217 | if [[ "$INCLUDE_PRODUCT" == true ]]; then |
| 218 | unzip -l "$SYSTEM_TARGET_FILES_ARCHIVE" | grep -q IMAGES/product.img && |
| 219 | EXTRACT_SYSTEM_FILE_LIST+=(IMAGES/product.img) |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 220 | fi |
| 221 | |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 222 | mkdir -p "$SYSTEM_ARTIFACTS_DIR" |
| 223 | # Get system images. |
| 224 | unzip "$SYSTEM_TARGET_FILES_ARCHIVE" "${EXTRACT_SYSTEM_FILE_LIST[@]}" \ |
| 225 | -d "$SYSTEM_ARTIFACTS_DIR" |
| 226 | |
| 227 | ### |
| 228 | # Uncompress the device archives. |
| 229 | mkdir -p "$DEVICE_IMAGES_DIR" |
| 230 | # Get device images. |
| 231 | unzip "$DEVICE_ARCHIVE" -d "$DEVICE_IMAGES_DIR" |
| 232 | # Get the device meta data. |
| 233 | unzip "$DEVICE_TARGET_FILES_ARCHIVE" "${EXTRACT_DEVICE_FILE_LIST[@]}" \ |
| 234 | -d "$DEVICE_ARTIFACTS_DIR" |
| 235 | |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 236 | ### |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 237 | # Modify system.img if vendor version is provided. |
| 238 | if [[ ! -z "${VENDOR_VERSION+x}" ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 239 | # Create copy of system target files package that can be modified |
| 240 | # since the original $SYSTEM_TARGET_FILES_ARCHIVE is a symlink to |
| 241 | # prebuilt files in cache |
| 242 | cp "$SYSTEM_TARGET_FILES_ARCHIVE" "$TEMP_DIR" |
| 243 | readonly COPY_SYSTEM_TARGET_FILES_ARCHIVE="$TEMP_DIR"/"$(basename "$SYSTEM_TARGET_FILES_ARCHIVE")" |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 244 | |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 245 | # Check compatibility of security patch level |
| 246 | readonly SYSTEM_SPL=$(sed -n -r "s/^"$SPL_PROPERTY_NAME"=(.*)$/\1/p" "$SYSTEM_ARTIFACTS_DIR"/"$SYSTEM_BUILD_PROP") |
| 247 | readonly VENDOR_SPL=$(sed -n -r "s/^"$SPL_PROPERTY_NAME"=(.*)$/\1/p" "$DEVICE_ARTIFACTS_DIR"/"$SYSTEM_BUILD_PROP") |
| 248 | declare -a args |
| 249 | args=(-v "$VENDOR_VERSION" "$COPY_SYSTEM_TARGET_FILES_ARCHIVE") |
| 250 | if [[ "$SYSTEM_SPL" != "$VENDOR_SPL" ]]; then |
| 251 | echo "Security patch level mismatch detected..." |
| 252 | echo " SPL of system: "$SYSTEM_SPL"" |
| 253 | echo " SPL of vendor: "$VENDOR_SPL"" |
| 254 | args+=("$VENDOR_SPL") |
| 255 | fi |
| 256 | "$MODIFY_SYSTEM_SCRIPT" "${args[@]}" |
| 257 | # Replace system.img with newly modified system.img |
| 258 | unzip -o "$COPY_SYSTEM_TARGET_FILES_ARCHIVE" IMAGES/system.img -d "$SYSTEM_ARTIFACTS_DIR" |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 259 | fi |
| 260 | |
Justin Yun | 14e2342 | 2019-10-10 12:04:26 +0900 | [diff] [blame] | 261 | # Check vintf |
| 262 | if [[ "$OTATOOLS_AVAILABLE" == true ]]; then |
| 263 | # Overwrite VINTF system matrix to device artifacts dir |
| 264 | unzip -o "$SYSTEM_TARGET_FILES_ARCHIVE" "${EXTRACT_VINTF_SYSTEM_FILE_LIST[@]}" \ |
| 265 | -d "$DEVICE_ARTIFACTS_DIR" |
| 266 | check_target_files_vintf "$DEVICE_ARTIFACTS_DIR" |
| 267 | fi |
| 268 | |
Jae Shin | 3af4201 | 2018-05-08 17:56:34 +0900 | [diff] [blame] | 269 | ### |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 270 | # Overwrite artifacts in the device archive to create the Mixed Build artifacts. |
Jae Shin | 341a55f | 2018-06-04 16:55:26 +0900 | [diff] [blame] | 271 | cp "$SYSTEM_IMAGES_DIR"/system.img "$DEVICE_IMAGES_DIR"/ |
Justin Yun | 07a77c8 | 2018-11-20 13:12:12 +0900 | [diff] [blame] | 272 | if [[ "$INCLUDE_PRODUCT" == true ]]; then |
Justin Yun | 74b00cb | 2019-01-04 14:45:08 +0900 | [diff] [blame] | 273 | if [[ -f "$SYSTEM_IMAGES_DIR"/product.img ]]; then |
| 274 | cp "$SYSTEM_IMAGES_DIR"/product.img "$DEVICE_IMAGES_DIR"/ |
| 275 | else |
| 276 | rm -f "$DEVICE_IMAGES_DIR"/product.img |
| 277 | # Removed product partition from required partition list |
| 278 | sed -i "/partition-exists=product$/d" "$DEVICE_IMAGES_DIR"/android-info.txt |
| 279 | fi |
Justin Yun | 07a77c8 | 2018-11-20 13:12:12 +0900 | [diff] [blame] | 280 | fi |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 281 | |
| 282 | # Only override vbmeta if it is already present since fastboot update will try |
| 283 | # to flash whatever is in the archive. |
| 284 | if [[ -f "$DEVICE_IMAGES_DIR"/vbmeta.img ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 285 | readonly VBMETA_IMAGE_PATH="${OVERRIDE_VBMETA_IMAGE_PATH:-"$SYSTEM_IMAGES_DIR"/vbmeta.img}" |
| 286 | cp "$VBMETA_IMAGE_PATH" "$DEVICE_IMAGES_DIR"/ |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 287 | fi |
| 288 | |
Hyunwoo Ko | 22da157 | 2019-05-16 18:01:35 +0900 | [diff] [blame] | 289 | # Override boot.img with the provided boot image file since fastboot update cmd |
| 290 | # will try to flash boot.img in the archive. |
| 291 | if [[ ! -z "${OVERRIDE_BOOT_IMAGE_PATH+x}" && -f "$DEVICE_IMAGES_DIR"/boot.img ]]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 292 | cp "$OVERRIDE_BOOT_IMAGE_PATH" "$DEVICE_IMAGES_DIR"/boot.img |
Hyunwoo Ko | 22da157 | 2019-05-16 18:01:35 +0900 | [diff] [blame] | 293 | fi |
| 294 | |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 295 | ### |
| 296 | # Create the Mixed Build archive. |
| 297 | ( |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 298 | cd "$DEVICE_IMAGES_DIR" |
| 299 | zip -r mixed.zip ./* |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 300 | ) |
| 301 | |
| 302 | ### |
| 303 | # Archive the artifacts. |
| 304 | if [ -n "$DIST_DIR" ]; then |
Justin Yun | 56cb76a | 2019-10-10 11:59:51 +0900 | [diff] [blame] | 305 | mkdir -p "$DIST_DIR" || true |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 306 | fi |
| 307 | # Archive all the device artifacts. |
Michael Schwartz | 56e3388 | 2018-05-24 20:57:29 -0700 | [diff] [blame] | 308 | rsync --archive --verbose --copy-links --exclude='logs' \ |
| 309 | "$DEVICE_DIR"/* "$DIST_DIR" |
Michael Schwartz | a0d9bd5 | 2017-11-02 10:19:42 -0700 | [diff] [blame] | 310 | # Overwrite the image archive with the Mixed Build archive. |
| 311 | OUT_ARCHIVE="$DIST_DIR"/"$(basename $DEVICE_ARCHIVE)" |
| 312 | cp "$DEVICE_IMAGES_DIR"/mixed.zip "$OUT_ARCHIVE" |
Justin Yun | 247e95a | 2019-01-07 10:36:49 +0900 | [diff] [blame] | 313 | # Overwrite android-info.txt with the updated one. |
| 314 | cp "$DEVICE_IMAGES_DIR"/android-info.txt "$DIST_DIR"/ |