Combine compress and save image into one function
When compressing an image, this is done in the same dir where the raw image resides, doubling the amount of space needed (scarce when using tmpfs), and then it's moved to the .cache folder in disk. Combining these two functions, we reduce the amount of space needed in the tmpfs partition (when in use), and the compressed image is created directly on the .cache folder disk, so there is no need to move the compressed image after the process into disk. Change-Id: I451d24bdd6fa0983414244135dff5e96c0549833
This commit is contained in:
parent
6687bdd267
commit
dbfca7a816
@ -148,8 +148,7 @@ finalise_base
|
|||||||
unmount_image
|
unmount_image
|
||||||
|
|
||||||
if [ "$IS_RAMDISK" == "0" ]; then
|
if [ "$IS_RAMDISK" == "0" ]; then
|
||||||
compress_image
|
compress_and_save_image $IMAGE_NAME.$IMAGE_TYPE
|
||||||
save_image $IMAGE_NAME.$IMAGE_TYPE
|
|
||||||
else
|
else
|
||||||
remove_image
|
remove_image
|
||||||
fi
|
fi
|
||||||
|
@ -106,12 +106,13 @@ function finalise_base () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function compress_image () {
|
function compress_and_save_image () {
|
||||||
# Recreate our image to throw away unnecessary data
|
# Recreate our image to throw away unnecessary data
|
||||||
test $IMAGE_TYPE != qcow2 && COMPRESS_IMAGE=""
|
test $IMAGE_TYPE != qcow2 && COMPRESS_IMAGE=""
|
||||||
qemu-img convert ${COMPRESS_IMAGE:+-c} -f raw $TMP_IMAGE_PATH -O $IMAGE_TYPE $TMP_IMAGE_PATH-new
|
qemu-img convert ${COMPRESS_IMAGE:+-c} -f raw $TMP_IMAGE_PATH -O $IMAGE_TYPE $1-new
|
||||||
rm $TMP_IMAGE_PATH
|
rm $TMP_IMAGE_PATH
|
||||||
mv $TMP_IMAGE_PATH-new $TMP_IMAGE_PATH
|
|
||||||
|
TMP_IMAGE_PATH=$1-new save_image $1
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_image () {
|
function remove_image () {
|
||||||
|
Loading…
Reference in New Issue
Block a user