From da41ee6012b064aa6901c871a1104a3a3933117e Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Sat, 17 Dec 2016 16:41:14 -0500 Subject: [PATCH] Add output image format tgz support We now support tgz (tar.gz) as an output format. Change-Id: Iadec92f2f96c3f904f28bd49f87ffc7d48ef7bd7 Signed-off-by: Paul Belanger --- bin/disk-image-create | 6 +++++- doc/source/user_guide/building_an_image.rst | 1 + lib/img-functions | 3 +++ tests/run_output_format_test.sh | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/disk-image-create b/bin/disk-image-create index 943cf6c6..eee85c01 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -102,7 +102,7 @@ function show_options () { echo "Options:" echo " -a i386|amd64|armhf -- set the architecture of the image(default amd64)" echo " -o imagename -- set the imagename of the output image file(default image)" - echo " -t qcow2,tar,vhd,docker,aci,raw -- set the image types of the output image files (default qcow2)" + echo " -t qcow2,tar,tgz,vhd,docker,aci,raw -- set the image types of the output image files (default qcow2)" echo " File types should be comma separated. VHD outputting requires the vhd-util" echo " executable be in your PATH. ACI outputting requires the ACI_MANIFEST " echo " environment variable be a path to a manifest file." @@ -258,6 +258,10 @@ for X in ${!IMAGE_TYPES[@]}; do exit 1 fi ;; + tgz) + # Force tar to be created. + IMAGE_TYPES+=('tar') + ;; vhd) if [ -z "$(which vhd-util)" ]; then echo "vhd output format specified but no vhd-util executable found." diff --git a/doc/source/user_guide/building_an_image.rst b/doc/source/user_guide/building_an_image.rst index 16dccc11..a401a96f 100644 --- a/doc/source/user_guide/building_an_image.rst +++ b/doc/source/user_guide/building_an_image.rst @@ -51,6 +51,7 @@ formats are: * qcow2 * tar + * tgz * vhd * docker * raw diff --git a/lib/img-functions b/lib/img-functions index f64a95a5..6ba0dfe4 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -122,6 +122,9 @@ function compress_and_save_image () { fi if [ "$IMAGE_TYPE" = "raw" ]; then mv $TMP_IMAGE_PATH $1-new + elif [ "$IMAGE_TYPE" == "tgz" ]; then + gzip -9 < $IMAGE_NAME.tar > $1-new + rm $IMAGE_NAME.tar elif [ "$IMAGE_TYPE" == "vhd" ]; then cp $TMP_IMAGE_PATH $1-intermediate vhd-util convert -s 0 -t 1 -i $1-intermediate -o $1-intermediate diff --git a/tests/run_output_format_test.sh b/tests/run_output_format_test.sh index b2f435ad..6d0f21c7 100755 --- a/tests/run_output_format_test.sh +++ b/tests/run_output_format_test.sh @@ -59,7 +59,7 @@ function build_test_image() { fi } -test_formats="tar raw qcow2 docker aci" +test_formats="tar tgz raw qcow2 docker aci" for binary in qemu-img docker ; do if [ -z "$(which $binary)" ]; then echo "Warning: No $binary binary found, cowardly refusing to run tests."