DO NOT MERGE: Parse Android .map files for unknown filesystem.
When generating a filesystem during the Android build, we also generate
a text file with .map extension with the list of files and the blocks
in the filesystem they are located.
For filesystems unsupported in delta_generator (like squashfs) we use
this text file to produce efficient delta payloads.
Bug: 28150981
Test: Added unittest for parsing. Generated a delta payload of a squashfs image.
(cherry-pick from 20bdc70e540e021c4a26553dfdbfd2fabe8ea432)
Change-Id: I5b83241622903259d5d40ae73f3f908756a77afd
diff --git a/scripts/brillo_update_payload b/scripts/brillo_update_payload
index 1649106..8d51118 100755
--- a/scripts/brillo_update_payload
+++ b/scripts/brillo_update_payload
@@ -187,6 +187,11 @@
declare -A SRC_PARTITIONS
declare -A DST_PARTITIONS
+# Associative arrays for the .map files associated with each src/dst partition
+# file in SRC_PARTITIONS and DST_PARTITIONS.
+declare -A SRC_PARTITIONS_MAP
+declare -A DST_PARTITIONS_MAP
+
# A list of temporary files to remove during cleanup.
CLEANUP_FILES=()
@@ -420,6 +425,12 @@
part_file="${temp_raw}"
fi
+ # Extract the .map file (if one is available).
+ part_map_file=$(create_tempfile "${part}.map.XXXXXX")
+ CLEANUP_FILES+=("${part_map_file}")
+ unzip -p "${image}" "IMAGES/${part}.map" >"${part_map_file}" || \
+ part_map_file=""
+
# delta_generator only supports images multiple of 4 KiB. For target images
# we pad the data with zeros if needed, but for source images we truncate
# down the data since the last block of the old image could be padded on
@@ -437,6 +448,7 @@
fi
eval "${partitions_array}[\"${part}\"]=\"${part_file}\""
+ eval "${partitions_array}_MAP[\"${part}\"]=\"${part_map_file}\""
echo "Extracted ${partitions_array}[${part}]: ${filesize} bytes"
done
}
@@ -467,27 +479,34 @@
GENERATOR_ARGS=( -out_file="${FLAGS_payload}" )
local part old_partitions="" new_partitions="" partition_names=""
+ local old_mapfiles="" new_mapfiles=""
for part in "${!DST_PARTITIONS[@]}"; do
if [[ -n "${partition_names}" ]]; then
partition_names+=":"
new_partitions+=":"
old_partitions+=":"
+ new_mapfiles+=":"
+ old_mapfiles+=":"
fi
partition_names+="${part}"
new_partitions+="${DST_PARTITIONS[${part}]}"
old_partitions+="${SRC_PARTITIONS[${part}]:-}"
+ new_mapfiles+="${DST_PARTITIONS_MAP[${part}]:-}"
+ old_mapfiles+="${SRC_PARTITIONS_MAP[${part}]:-}"
done
# Target image args:
GENERATOR_ARGS+=(
-partition_names="${partition_names}"
-new_partitions="${new_partitions}"
+ -new_mapfiles="${new_mapfiles}"
)
if [[ "${payload_type}" == "delta" ]]; then
# Source image args:
GENERATOR_ARGS+=(
-old_partitions="${old_partitions}"
+ -old_mapfiles="${old_mapfiles}"
)
if [[ -n "${FORCE_MINOR_VERSION}" ]]; then
GENERATOR_ARGS+=( --minor_version="${FORCE_MINOR_VERSION}" )