mod_image_for_recovery: fix mkfs error
mod_image_for_recovery.sh minimizes stateful partition by sending an
'--adjust_part=<new_stateful_size>' into build_gpt_image. However, the
--adjust_part does not handled correctly in many part of the script,
especially inside mk_fs().
Fix this bug by skipping the redundant mk_fs() call.
BUG=chromium:1114569
TEST=mod_image_for_recovery.sh -b sarien \
--image chromiumos_test_image.bin \
--kernel_image recovery_vmlinuz.image
Change-Id: Iab086f782ed3060aa85e16b8fdea5f4ae31f5397
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosutils/+/2346083
Tested-by: Ting Shen <phoenixshen@chromium.org>
Auto-Submit: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
diff --git a/build_library/disk_layout_util.sh b/build_library/disk_layout_util.sh
index 25114b5..daa435a 100644
--- a/build_library/disk_layout_util.sh
+++ b/build_library/disk_layout_util.sh
@@ -526,13 +526,11 @@
build_gpt_image() {
local outdev="$1"
local disk_layout="$2"
- local adjust_part="$3"
# Build the partition table and partition script.
local partition_script_path
partition_script_path="$(dirname "${outdev}")/partition_script.sh"
- write_partition_script "${disk_layout}" "${partition_script_path}" \
- "${adjust_part}"
+ write_partition_script "${disk_layout}" "${partition_script_path}"
run_partition_script "${outdev}" "${partition_script_path}"
# Emit the gpt scripts so we can use them from here on out.
diff --git a/mod_image_for_recovery.sh b/mod_image_for_recovery.sh
index dd76aa7..f595907 100755
--- a/mod_image_for_recovery.sh
+++ b/mod_image_for_recovery.sh
@@ -387,11 +387,12 @@
# with correct layout.
rm -f "${dst_img}"
- # Temporarily disable set -u because there's some empty array expansion in
- # build_gpt_image.
- set +u
- build_gpt_image "${dst_img}" recovery "STATE:=$(( stateful_blocks * 512 ))"
- set -u
+ # Build the partition table.
+ local partition_script_path
+ partition_script_path="$(dirname "${dst_img}")/partition_script.sh"
+ write_partition_script recovery "${partition_script_path}" \
+ "STATE:=$(( stateful_blocks * 512 ))"
+ run_partition_script "${dst_img}" "${partition_script_path}"
}
# Copy the partitions one by one from source image to destination image,