brillo_update_payload: Pass postinstall config file to delta_generator.
If the target_files.zip contains META/postinstall_config.txt, then extract
it and pass the path to delta_generator.
BUG=b:24537566
TEST=Called brillo_update_payload with a target_files.zip that contains
postinstall_config.txt
Change-Id: I593c449e0194f3f72f4bcf712a03be472e12076d
Reviewed-on: https://chromium-review.googlesource.com/312550
Commit-Ready: Sen Jiang <[email protected]>
Tested-by: Sen Jiang <[email protected]>
Reviewed-by: Sen Jiang <[email protected]>
diff --git a/scripts/brillo_update_payload b/scripts/brillo_update_payload
index 282fbcf..22f07dc 100755
--- a/scripts/brillo_update_payload
+++ b/scripts/brillo_update_payload
@@ -170,6 +170,9 @@
FORCE_MAJOR_VERSION=""
FORCE_MINOR_VERSION=""
+# Path to the postinstall config file in target image if exists.
+POSTINSTALL_CONFIG_FILE=""
+
# read_option_int <file.txt> <option_key> [default_value]
#
# Reads the unsigned integer value associated with |option_key| in a key=value
@@ -318,7 +321,8 @@
FORCE_MAJOR_VERSION="2"
if [[ "${partitions_array}" == "SRC_PARTITIONS" ]]; then
- ue_config=$(create_tempfile "ue_config.XXXXXX")
+ # Source image
+ local ue_config=$(create_tempfile "ue_config.XXXXXX")
CLEANUP_FILES+=("${ue_config}")
if ! unzip -p "${image}" "META/update_engine_config.txt" \
>"${ue_config}"; then
@@ -331,6 +335,14 @@
"PAYLOAD_MINOR_VERSION" 2)
FORCE_MAJOR_VERSION=$(read_option_uint "${ue_config}" \
"PAYLOAD_MAJOR_VERSION" 2)
+ else
+ # Target image
+ local postinstall_config=$(create_tempfile "postinstall_config.XXXXXX")
+ CLEANUP_FILES+=("${postinstall_config}")
+ if unzip -p "${image}" "META/postinstall_config.txt" \
+ >"${postinstall_config}"; then
+ POSTINSTALL_CONFIG_FILE="${postinstall_config}"
+ fi
fi
local part part_file temp_raw filesize
@@ -428,6 +440,12 @@
GENERATOR_ARGS+=( --out_metadata_size_file="${FLAGS_metadata_size_file}" )
fi
+ if [[ -n "${POSTINSTALL_CONFIG_FILE}" ]]; then
+ GENERATOR_ARGS+=(
+ --new_postinstall_config_file="${POSTINSTALL_CONFIG_FILE}"
+ )
+ fi
+
echo "Running delta_generator with args: ${GENERATOR_ARGS[@]}"
"${GENERATOR}" "${GENERATOR_ARGS[@]}"