summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatoshi Niwa <niwa@google.com>2021-07-01 17:18:57 +0900
committerCommit Bot <commit-bot@chromium.org>2021-07-08 07:10:18 +0000
commit5d590145f0b0e40f64cacc2acfa1d3b0a7b595f8 (patch)
treede09f0f4c57350e15f9d1ac527bea4b1f858f9e3
parent9ea1e75805cfb7523729c5f5d48df0d05ced1b11 (diff)
downloadvboot-5d590145f0b0e40f64cacc2acfa1d3b0a7b595f8.tar.gz
Detect compression type and use the same one for re-packing the image
After crrev/i/3949327, compression type is not simply determined by ARC type. BUG=b:180894807 TEST=sign_official_build.sh and check the log message BRANCH=none Signed-off-by: Satoshi Niwa <niwa@google.com> Cq-Depend: chromium:2999963 Cq-Depend: chrome-internal:3949327 Change-Id: I4b1bf452e0d033b4bb8c2f2c1f91819741f9885c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2999823 Tested-by: Satoshi Niwa <niwa@chromium.org> Reviewed-by: Yury Khmel <khmel@chromium.org> Reviewed-by: Satoshi Niwa <niwa@chromium.org> Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org> Auto-Submit: Satoshi Niwa <niwa@chromium.org> Commit-Queue: Satoshi Niwa <niwa@chromium.org>
-rwxr-xr-xscripts/image_signing/sign_android_image.sh20
1 files changed, 14 insertions, 6 deletions
diff --git a/scripts/image_signing/sign_android_image.sh b/scripts/image_signing/sign_android_image.sh
index cb45fe9e..771dc37d 100755
--- a/scripts/image_signing/sign_android_image.sh
+++ b/scripts/image_signing/sign_android_image.sh
@@ -262,7 +262,6 @@ main() {
# Keep this aligned with
# src/private-overlays/project-cheets-private/scripts/board_specific_setup.sh
local system_image=""
- local compression_flags=""
local selinux_dir="${root_fs_dir}/etc/selinux"
local file_contexts=""
local vm_candidate="${root_fs_dir}/opt/google/vms/android/system.raw.img"
@@ -270,11 +269,9 @@ main() {
"${root_fs_dir}/opt/google/containers/android/system.raw.img")
if [[ -f "${vm_candidate}" ]]; then
system_image="${vm_candidate}"
- compression_flags="-comp lz4 -Xhc -b 256K"
file_contexts="${selinux_dir}/arc/contexts/files/android_file_contexts_vm"
elif [[ -f "${container_candidate}" ]]; then
system_image="${container_candidate}"
- compression_flags="-comp gzip"
file_contexts="${selinux_dir}/arc/contexts/files/android_file_contexts"
else
die "System image does not exist"
@@ -297,6 +294,19 @@ main() {
die "System image does not exist: ${system_img}"
fi
+ # NOTE: Keep compression_flags aligned with
+ # src/private-overlays/project-cheets-private/scripts/board_specific_setup.sh
+ local compression_flags=""
+ local compression=$(sudo "${unsquashfs}" -s "${system_img}" \
+ | grep -e ^"Compression\s")
+ if [[ "${compression}" == "Compression gzip" ]]; then
+ compression_flags="-comp gzip"
+ elif [[ "${compression}" == "Compression lz4" ]]; then
+ compression_flags="-comp lz4 -Xhc -b 256K"
+ else
+ die "Unexpected compression type: ${compression}"
+ fi
+
if ! type -P zipalign &>/dev/null || ! type -P signapk &>/dev/null \
|| ! type -P apksigner &>/dev/null; then
# TODO(victorhsieh): Make this an error. This is not treating as error
@@ -367,12 +377,10 @@ main() {
info "Packages cache ${packages_cache} does not exist. Skip regeneration."
fi
- info "Repacking squashfs image"
+ info "Repacking squashfs image with compression flags '${compression_flags}'"
local old_size=$(stat -c '%s' "${system_img}")
# Remove old system image to prevent mksquashfs tries to merge both images.
sudo rm -rf "${system_img}"
- # Note, compression_flags is a combination of flags. Keep this aligned with
- # src/private-overlays/project-cheets-private/scripts/board_specific_setup.sh
sudo mksquashfs "${system_mnt}" "${system_img}" \
${compression_flags} -context-file "${file_contexts}" -mount-point "/" \
-no-progress