Add squashfs output image format

The squashfs format brings a couple of advantages over the other
formats. Image is often an order of magnitude smaller and it can
be used natively, either as an initrd, either with loop mount.

Change-Id: If72940b0c4dafb2504c52dd0429a8eb3f8305751
This commit is contained in:
Tristan Cacqueray 2016-12-18 01:59:07 +00:00
parent da41ee6012
commit 9d13084c41
5 changed files with 19 additions and 4 deletions

View File

@ -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,tgz,vhd,docker,aci,raw -- set the image types of the output image files (default qcow2)"
echo " -t qcow2,tar,tgz,squashfs,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."
@ -268,6 +268,12 @@ for X in ${!IMAGE_TYPES[@]}; do
exit 1
fi
;;
squashfs)
if [ -z "$(which mksquashfs)" ]; then
echo "squashfs output format specified but no mksquashfs executable found."
exit 1
fi
;;
docker)
if [ -z "$(which docker)" ]; then
echo "docker output format specified but no docker executable found."
@ -452,6 +458,10 @@ for X in ${!IMAGE_TYPES[@]} ; do
fi
sudo chown $USER: $IMAGE_NAME.${IMAGE_TYPES[$X]}
unset IMAGE_TYPES[$X]
elif [ "${IMAGE_TYPES[$x]}" == "squashfs" ]; then
sudo mksquashfs ${TMP_BUILD_DIR}/mnt $IMAGE_NAME.squash -comp xz \
-noappend -root-becomes ${TMP_BUILD_DIR}/mnt \
-wildcards -e "proc/*" -e "sys/*" -no-recovery
elif [ "${IMAGE_TYPES[$X]}" == "docker" ]; then
sudo tar -C ${TMP_BUILD_DIR}/mnt -cf - --exclude ./sys \
--exclude ./proc --xattrs --xattrs-include=\* . \
@ -476,7 +486,7 @@ if [[ (! $IMAGE_ELEMENT =~ no-final-image) && "$IS_RAMDISK" == "0" ]]; then
# We have to do raw last because it is destructive
if [ "$IMAGE_TYPE" = "raw" ]; then
has_raw_type=1
else
elif [ "$IMAGE_TYPE" != "squashfs" ]; then
compress_and_save_image $IMAGE_NAME.$IMAGE_TYPE
fi
done

View File

@ -1,2 +1,3 @@
# This is a cross-platform list tracking distribution packages needed by tests;
# see http://docs.openstack.org/infra/bindep/ for additional information.
squashfs-tools

View File

@ -52,6 +52,7 @@ formats are:
* qcow2
* tar
* tgz
* squashfs
* vhd
* docker
* raw

View File

@ -0,0 +1,3 @@
---
features:
- New squashfs image output format.

View File

@ -59,8 +59,8 @@ function build_test_image() {
fi
}
test_formats="tar tgz raw qcow2 docker aci"
for binary in qemu-img docker ; do
test_formats="tar tgz squashfs raw qcow2 docker aci"
for binary in qemu-img docker mksquashfs; do
if [ -z "$(which $binary)" ]; then
echo "Warning: No $binary binary found, cowardly refusing to run tests."
exit 1