From 6e885f2e84880aef401bce15246d5858fddb1a4f Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Sun, 14 Aug 2011 08:53:51 +0800 Subject: [PATCH] make_factory_package: always require partition tools (cgpt or parted) When there're more and more advanced features landed into make_factory_package, supporting the "unpacked mode" (use unpack_partition.sh to extract all partitions) becomes a problem. cgpt is mandatory in chroot, and parted is installed by default for most Linux distributions, so I think it may be safe now to force using partition tools, which is also more robust than unpack_partition. BUG=chromium-os:15050 TEST=./make_factory_package --release RECOVERY --factory FACTORY Change-Id: I865aebdf3ce2cbd21b0fe22fdce8612810ee78f7 Reviewed-on: http://gerrit.chromium.org/gerrit/5963 Reviewed-by: Nick Sanders Tested-by: Hung-Te Lin --- make_factory_package.sh | 42 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/make_factory_package.sh b/make_factory_package.sh index 5f9b255168..5501b05075 100755 --- a/make_factory_package.sh +++ b/make_factory_package.sh @@ -159,15 +159,9 @@ setup_environment() { RELEASE_IMAGE="$(basename "${FLAGS_release}")" FACTORY_IMAGE="$(basename "${FLAGS_factory}")" - # Decide if we should unpack partition - if image_has_part_tools; then - IMAGE_IS_UNPACKED= - else - #TODO(hungte) Currently we run unpack_partitions.sh if part_tools are not - # found. If the format of unpack_partitions.sh is reliable, we can prevent - # creating temporary files. See image_part_offset for more information. - echo "WARNING: cannot find partition tools. Using unpack_partitions.sh." >&2 - IMAGE_IS_UNPACKED=1 + # Check required tools. + if ! image_has_part_tools; then + die "Missing partition tools. Please install cgpt/parted, or run in chroot." fi } @@ -225,15 +219,9 @@ prepare_dir() { compress_and_hash_memento_image() { local input_file="$1" - if [ -n "${IMAGE_IS_UNPACKED}" ]; then - sudo "${SCRIPTS_DIR}/mk_memento_images.sh" part_2 part_3 | - grep hash | - awk '{print $4}' - else - sudo "${SCRIPTS_DIR}/mk_memento_images.sh" "$input_file:2" "$input_file:3" | - grep hash | - awk '{print $4}' - fi + sudo "${SCRIPTS_DIR}/mk_memento_images.sh" "$input_file:2" "$input_file:3" | + grep hash | + awk '{print $4}' } compress_and_hash_file() { @@ -259,12 +247,8 @@ compress_and_hash_partition() { local part_num="$2" local output_file="$3" - if [ -n "${IMAGE_IS_UNPACKED}" ]; then - compress_and_hash_file "part_$part_num" "$output_file" - else - image_dump_partition "$input_file" "$part_num" | - compress_and_hash_file "" "$output_file" - fi + image_dump_partition "$input_file" "$part_num" | + compress_and_hash_file "" "$output_file" } # Applies HWID component list files updater into stateful partition @@ -403,11 +387,6 @@ generate_omaha() { prepare_dir - if [ -n "${IMAGE_IS_UNPACKED}" ]; then - echo "Unpacking image ${RELEASE_IMAGE} ..." >&2 - sudo ./unpack_partitions.sh "${RELEASE_IMAGE}" 2>/dev/null - fi - release_hash="$(compress_and_hash_memento_image "${RELEASE_IMAGE}")" sudo chmod a+rw update.gz mv update.gz rootfs-release.gz @@ -424,11 +403,6 @@ generate_omaha() { pushd "${FACTORY_DIR}" >/dev/null prepare_dir - if [ -n "${IMAGE_IS_UNPACKED}" ]; then - echo "Unpacking image ${FACTORY_IMAGE} ..." >&2 - sudo ./unpack_partitions.sh "${FACTORY_IMAGE}" 2>/dev/null - fi - test_hash="$(compress_and_hash_memento_image "${FACTORY_IMAGE}")" sudo chmod a+rw update.gz mv update.gz rootfs-test.gz