summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury Khmel <khmel@google.com>2018-03-03 14:48:38 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-20 00:00:26 -0700
commit754e56bff6911fdd667b6c03d8b7ba1269dba966 (patch)
treee916cc57e6a4b7c083cd975113bd5709f4f5537d
parent4c84e077858c809ee80a9a6f9b38185cf7dcded7 (diff)
downloadvboot-factory-poppy-10509.B.tar.gz
arc: Enable packages cache generation during sign stage.factory-poppy-10509.B
This regenerates packages cache during signing the image once apks are changed due timestamp and key update. TEST=Build image, sign it useing devkeys and deploy to device. Perform user sign-in and enable ARC. Test logcat and everything is clear. BUG=b:74108152 Change-Id: I4809a1f87c8b8f52094054dbb4c8ba3e059aee89 Reviewed-on: https://chromium-review.googlesource.com/948064 Commit-Ready: Yury Khmel <khmel@google.com> Tested-by: Yury Khmel <khmel@google.com> Reviewed-by: Mike Frysinger <vapier@chromium.org>
-rwxr-xr-xscripts/image_signing/sign_android_image.sh46
1 files changed, 45 insertions, 1 deletions
diff --git a/scripts/image_signing/sign_android_image.sh b/scripts/image_signing/sign_android_image.sh
index 5a6d321a..c8238704 100755
--- a/scripts/image_signing/sign_android_image.sh
+++ b/scripts/image_signing/sign_android_image.sh
@@ -96,6 +96,11 @@ build flavor '${flavor_prop}'."
# Copy the content instead of mv to avoid owner/mode changes.
sudo cp "${aligned_apk}" "${apk}" && rm -f "${aligned_apk}"
+ # Set timestamp rounded to second since squash file system has resolution
+ # in seconds. Required in order for the packages cache generator output is
+ # compatible with the packed file system.
+ sudo touch "${apk}" -t "$(date +%m%d%H%M.%S)"
+
: $(( counter_${keyname} += 1 ))
: $(( counter_total += 1 ))
done < <(find "${system_mnt}/system" -type f -name '*.apk' -print0)
@@ -218,7 +223,7 @@ main() {
local compression_method=$(sudo unsquashfs -s "${system_img}" | \
awk '$1 == "Compression" { print $2 }')
- info "Unpacking squashfs image to ${system_img}"
+ info "Unpacking squashfs system image to ${system_mnt}"
sudo "${unsquashfs}" -x -f -no-progress -d "${system_mnt}" "${system_img}"
snapshot_file_properties "${system_mnt}" > "${working_dir}/properties.orig"
@@ -235,6 +240,45 @@ main() {
die "Unexpected change of file property, diff\n${d}"
fi
+ # Packages cache needs to be regenerated when the key and timestamp are
+ # changed for apks.
+ local packages_cache="${system_mnt}/system/etc/packages_cache.xml"
+ if [[ -f "${packages_cache}" ]]; then
+ if type -P aapt &>/dev/null; then
+ info "Regenerating packages cache ${packages_cache}"
+ # For the sanity check.
+ local packages_before=$(grep "<package " "${packages_cache}" | wc -l)
+ local vendor_mnt=$(make_temp_dir)
+ local vendor_img="${android_dir}/vendor.raw.img"
+ local jar_lib="lib/arc-cache-builder/org.chromium.arc.cachebuilder.jar"
+ info "Unpacking squashfs vendor image to ${vendor_mnt}/vendor"
+ # Vendor image is not updated during this step. However we have to include
+ # vendor apks to re-generated packages cache which exists in one file for
+ # both system and vendor images.
+ sudo "${unsquashfs}" -x -f -no-progress -d "${vendor_mnt}/vendor" \
+ "${vendor_img}"
+ if ! arc_generate_packages_cache "${system_mnt}" "${vendor_mnt}" \
+ "${working_dir}/packages_cache.xml"; then
+ die "Failed to generate packages cache."
+ fi
+ sudo cp "${working_dir}/packages_cache.xml" "${packages_cache}"
+ # Set android-root as an owner.
+ sudo chown 655360:655360 "${packages_cache}"
+ local packages_after=$(grep "<package " "${packages_cache}" | wc -l)
+ if [[ "${packages_before}" != "${packages_after}" ]]; then
+ die "failed to verify the packages count after the regeneration of " \
+ "the packages cache. Expected ${packages_before} but found " \
+ "${packages_after} packages in pacakges_cache.xml"
+ fi
+ else
+ warn "aapt tool could not be found. Could not regenerate the packages " \
+ "cache. Outdated pacakges_cache.xml is removed."
+ sudo rm "${packages_cache}"
+ fi
+ else
+ info "Packages cache ${packages_cache} does not exist. Skip regeneration."
+ fi
+
info "Repacking squashfs image"
local old_size=$(stat -c '%s' "${system_img}")
# Overwrite the original image.