From d253badb6c9a9452571127518ee9cf5cad745feb Mon Sep 17 00:00:00 2001 From: Will Drewry Date: Tue, 17 Aug 2010 14:09:41 -0500 Subject: [PATCH] build_image: make sure the factory_image size is propagated Verified rootfs-based factory installers fail because the ROOT_SIZE_BYTES is updated, but the information is not propagated to the boot.desc which cros_make_image_bootable uses. The result is that mod_image_for_test incorrectly appends the rootfs hash even though it is correctly computed. Random note: build_kernel_image uses dumpe2fs to compute the size, but cros_make_image_bootable uses the supplied size. These shouldn't diverge though the partition size should accomodate the addition of the hashes. TODO(wad) Add checking of sizes in cros_make_image_bootable TEST=x86-generic build image with --enable_rootfs_verification and --factory_install; then put in a machine and it no longer spewed dm-verity hash errors and the root hash checked successfully! BUG=chromium-os:5100 Review URL: http://codereview.chromium.org/3155025 Change-Id: I174e3661b80d83b25f3af95ff1eb77f634a7e797 --- build_image | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/build_image b/build_image index 066f20bc76..b1f493ee91 100755 --- a/build_image +++ b/build_image @@ -50,14 +50,14 @@ DEFINE_boolean dev_install ${FLAGS_FALSE} \ DEFINE_string arm_extra_bootargs "" \ "Additional command line options to pass to the ARM kernel." DEFINE_integer rootfs_partition_size 1024 \ - "rootfs parition size in MBs." + "rootfs partition size in MiBs." DEFINE_integer rootfs_size 720 \ - "rootfs filesystem size in MBs." + "rootfs filesystem size in MiBs." # ceil(0.1 * rootfs_size) is a good minimum. DEFINE_integer rootfs_hash_pad 8 \ - "MBs reserved at the end of the rootfs image." + "MiBs reserved at the end of the rootfs image." DEFINE_integer statefulfs_size 1024 \ - "stateful filesystem size in MBs." + "stateful filesystem size in MiBs." DEFINE_boolean preserve ${FLAGS_FALSE} \ "Attempt to preserve the previous build image if one can be found (unstable, \ kernel/firmware not updated)" @@ -97,8 +97,8 @@ fi if [ "$((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad))" -gt \ "${FLAGS_rootfs_partition_size}" ] ; then - error "rootfs ($((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) MB) is \ -bigger than partition (${FLAGS_rootfs_partition_size} MB)." + error "rootfs ($((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) MiB) is \ +bigger than partition (${FLAGS_rootfs_partition_size} MiB)." exit 1 fi @@ -453,15 +453,8 @@ create_base_image() { exit 1 fi - # Create root file system disk image to fit on a 1GB memory stick. - # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes. - # Minimize rootfs size for dev install shim and factory installer - if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] || - [ ${FLAGS_dev_install} -eq ${FLAGS_TRUE} ] ; then - ROOT_SIZE_BYTES=$((1024 * 1024 * 300)) - else - ROOT_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_rootfs_size})) - fi + # Create root file system disk image. + ROOT_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_rootfs_size})) # Pad out for the hash tree. ROOT_HASH_PAD=$((FLAGS_rootfs_hash_pad * 1024 * 1024)) @@ -655,6 +648,13 @@ if [[ $FLAGS_preserve -eq ${FLAGS_TRUE} ]] ; then fi fi +# Minimize rootfs size for dev install shim and factory installer +if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} -o \ + ${FLAGS_dev_install} -eq ${FLAGS_TRUE} ] ; then + info "Fixing the rootfs size at 300 MiB for the factory installer" + FLAGS_rootfs_size=300 +fi + # Create the boot.desc file which stores the build-time configuration # information needed for making the image bootable after creation with # cros_make_image_bootable.