Remove duplicates in ab_partitions.txt
ab_partitions.txt is populated by AB_OTA_PARTITIONS which might be
appended in multiple makefiles resulting in duplicates, currently
this will result in payload being larger because it will include the
operations for that partition twice and the client will write that
partition twice when applying that payload.
This patch uses awk in brillo_update_payload when reading
ab_partitions.txt to remove the duplicates.
Test: generate a payload with duplicated entries in ab_partitions.txt
Change-Id: I07bd2401a64fbc77bbdc632901016e3860dee8d9
diff --git a/scripts/brillo_update_payload b/scripts/brillo_update_payload
index 868e723..61ecadf 100755
--- a/scripts/brillo_update_payload
+++ b/scripts/brillo_update_payload
@@ -397,7 +397,8 @@
if grep -v -E '^[a-zA-Z0-9_-]*$' "${ab_partitions_list}" >&2; then
die "Invalid partition names found in the partition list."
fi
- partitions=($(cat "${ab_partitions_list}"))
+ # Get partition list without duplicates.
+ partitions=($(awk '!seen[$0]++' "${ab_partitions_list}"))
if [[ ${#partitions[@]} -eq 0 ]]; then
die "The list of partitions is empty. Can't generate a payload."
fi