From eb6a260a5a81cd1135acb42d4b4769ac9935347c Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Thu, 12 Feb 2015 13:04:16 -0800 Subject: [PATCH] Support building ACIs App containers are a format used by rocket and are specified at the following url: https://github.com/appc/spec/ Change-Id: I8ac24f0194c4bf53dffd6c47e0587bc413101698 --- bin/disk-image-create | 27 +++++++++++++++++++++------ tests/image_output_formats.bash | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/bin/disk-image-create b/bin/disk-image-create index 8ec7d0f7..0c341ae3 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -45,9 +45,10 @@ 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,raw -- set the image types of the output image files (default qcow2)" + echo " -t qcow2,tar,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." + echo " executable be in your PATH. ACI outputting requires the ACI_MANIFEST " + echo " environment variable be a path to a manifest file." echo " -x -- turn on tracing" echo " -u -- uncompressed; do not compress the image - larger but faster" echo " -c -- clear environment before starting work" @@ -103,6 +104,7 @@ COMPRESS_IMAGE="true" export DIB_ROOT_LABEL="" DIB_DEFAULT_INSTALLTYPE=${DIB_DEFAULT_INSTALLTYPE:-"source"} MKFS_OPTS="" +ACI_MANIFEST=${ACI_MANIFEST:-} DOCKER_TARGET="" TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize:,mkfs-options:,qemu-img-options:,ramdisk-element:,root-label:,install-type:,docker-target: -n $SCRIPTNAME -- "$@"` if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi @@ -279,10 +281,23 @@ run_d_in_target finalise finalise_base for X in ${!IMAGE_TYPES[@]} ; do - if [ "${IMAGE_TYPES[$X]}" == "tar" ]; then - sudo tar -C ${TMP_BUILD_DIR}/mnt -cf $IMAGE_NAME.tar --exclude ./sys \ - --exclude ./proc --xattrs --xattrs-include=\* . - sudo chown $USER: $IMAGE_NAME.tar + if [[ " tar aci " =~ "${IMAGE_TYPES[$X]}" ]]; then + if [ "${IMAGE_TYPES[$X]}" = "aci" ]; then + sudo tar -C ${TMP_BUILD_DIR}/mnt -cf $IMAGE_NAME.aci --exclude ./sys \ + --exclude ./proc --xattrs --xattrs-include=\* \ + --transform 's,^.,rootfs,S' . + if [ -n "$ACI_MANIFEST" ]; then + cp $ACI_MANIFEST ${TMP_BUILD_DIR}/manifest + sudo tar -C ${TMP_BUILD_DIR} --append -f $IMAGE_NAME.aci manifest + else + echo "No ACI_MANIFEST specified. An ACI_MANIFEST must be specified for" + echo " this image to be usable." + fi + else + sudo tar -C ${TMP_BUILD_DIR}/mnt -cf $IMAGE_NAME.tar --exclude ./sys \ + --exclude ./proc --xattrs --xattrs-include=\* . + fi + sudo chown $USER: $IMAGE_NAME.${IMAGE_TYPES[$X]} unset IMAGE_TYPES[$X] elif [ "${IMAGE_TYPES[$X]}" == "docker" ]; then sudo tar -C ${TMP_BUILD_DIR}/mnt -cf - --exclude ./sys \ diff --git a/tests/image_output_formats.bash b/tests/image_output_formats.bash index dd824801..92ef97f9 100755 --- a/tests/image_output_formats.bash +++ b/tests/image_output_formats.bash @@ -5,7 +5,7 @@ set -o pipefail source $(dirname $0)/test_functions.bash -test_formats="tar raw qcow2 docker" +test_formats="tar 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."