crosutils/make_universal_factory_shim: allow images in arbitrary layout (for factory branch)

We need more flexible image creation tool for various layout, like "RMA with
multiple release images" which needs 4 images (install, test, release A,
release B).

To make the creation of image more flexible, this CL changes
make_universal_factory_shim to using a "layout file" that can describe any disk
image format we want.

Image creation speed is also improved by aligning partition offsets and
restricting oflag=dsync applied only when being used for block devices so that
make_universal_factory_shim (outputs to a normal temporary file) becomes faster
by utilizing system cache.

For a system with every images already cached:
 - Time for building 3 in 1 factory instal shim:
   Before = 8 seconds, After = 5 seconds.
 - Time for full RMA shim creation:
   Before = 1m25s, After = 40-50 seconds.

BUG=chrome-os-partner:4108
TEST=./make_universal_factory_shim.sh image1 image2 image3 image4
     # boots correctly after being imaged to SD card.
     ./make_factory_package.sh --usbimg RMA ....
     # RMA image can install images and works correctly

Original Reviewed-on: http://gerrit.chromium.org/gerrit/6893
Original Tested-by: Hung-Te Lin <hungte@chromium.org>
Original Reviewed-by: Nick Sanders <nsanders@chromium.org>

Change-Id: I2bf8519d8fc48252aa3df8e3ffacb9feede69f51
Reviewed-on: http://gerrit.chromium.org/gerrit/7320
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
2 files changed
tree: 95bd2cc6a41d00f981160d5719fc418dc3fa19f6
  1. bin/
  2. build_library/
  3. chroot_version_hooks.d/
  4. lib/
  5. mod_for_factory_scripts/
  6. mod_for_test_scripts/
  7. .gitignore
  8. archive_build.sh
  9. archive_hwqual
  10. bash_completion
  11. build_image
  12. build_kernel_image.sh
  13. call_autoserv.py
  14. check_control_files.sh
  15. clean_loopback_devices
  16. common.sh
  17. cros_deps_diff
  18. cros_download_latest_image
  19. cros_generate_breakpad_symbols
  20. cros_generate_deps_graphs
  21. cros_show_stacks
  22. dot_helper.py
  23. enable_localaccount.sh
  24. enter_chroot.sh
  25. fixup_image_for_qemu.py
  26. get_latest_image.sh
  27. get_package_list
  28. image_to_usb.sh
  29. image_to_vm.sh
  30. make_developer_script_runner.sh
  31. make_factory_package.sh
  32. make_netboot.sh
  33. make_universal_factory_shim.sh
  34. mk_memento_images.sh
  35. mod_image_for_recovery.sh
  36. mod_image_for_test.sh
  37. mod_test_image_for_pyauto.sh
  38. mount_gpt_image.sh
  39. remote_access.sh
  40. run_chroot_version_hooks
  41. serve_factory_packages.py
  42. set_shared_user_password.sh
  43. ssh_test.sh
  44. start_devserver
  45. update_bootloaders.sh
  46. update_chroot
  47. update_kernel.sh
  48. upload_symbols
  49. verify_rootfs_chksum.sh