From dc93feee699bc42bd41b973300065b0304663e8a Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Tue, 25 Mar 2014 14:16:06 +1300 Subject: [PATCH] Remove an excess cp of disk images. save_image is used to copy kernel and ramdisks out of the image, which we will sometimes want to keep the source, and sometimes not. However for the main image itself, the temp copy is never kept, so use mv rather than cp and avoid the excess IO. Change-Id: I5a9f0d69ffee3e6b872a8927537ac17f02f5aa4d --- bin/disk-image-create | 4 +++- lib/common-functions | 8 ++++++++ lib/img-functions | 8 +------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/bin/disk-image-create b/bin/disk-image-create index a20f085b..e2cf9b21 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -187,5 +187,7 @@ unmount_image if [ "$IS_RAMDISK" == "0" ]; then compress_and_save_image $IMAGE_NAME.$IMAGE_TYPE else - remove_image + # This is a ramdisk build, we have already extracted the kernel and ramdisk + # by this point. + rm $TMP_IMAGE_PATH fi diff --git a/lib/common-functions b/lib/common-functions index 4873d781..16e1994e 100644 --- a/lib/common-functions +++ b/lib/common-functions @@ -40,6 +40,14 @@ function mk_build_dir () { export TMP_HOOKS_PATH=$TMP_BUILD_DIR/hooks } +function finish_image () { + mv $TMP_IMAGE_PATH $1 + cleanup_dirs + # All done! + trap EXIT + echo "Image file $1 created..." +} + function save_image () { # TODO: this really should rename the old file if [ -f $1 ] ; then diff --git a/lib/img-functions b/lib/img-functions index c1cf17a3..09ae0040 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -106,13 +106,7 @@ function compress_and_save_image () { rm $TMP_IMAGE_PATH TMP_IMAGE_PATH=$1-new - save_image $1 - remove_image -} - -function remove_image () { - echo "Removing $TMP_IMAGE_PATH" - rm $TMP_IMAGE_PATH + finish_image $1 } function do_extra_package_install () {