Fix fedora element to work with qcow2 images.

The images from mattdm were updated and also changed to qcow2 format.

Change-Id: I6560f177baa9a0e2d303364a3ad4eb216f1f2136
This commit is contained in:
Clint Byrum 2013-05-25 06:24:08 -07:00
parent a4c42954d3
commit da02e05ff4

View File

@ -12,7 +12,7 @@ fi
IMG_PATH=~/.cache/image-create
DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://mattdm.fedorapeople.org/cloud-images/}
DIB_RELEASE=${DIB_RELEASE:-Fedora18}
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$DIB_RELEASE-Cloud-$ARCH-latest.raw.tar.xz}
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$DIB_RELEASE-Cloud-$ARCH-latest.qcow2}
BASE_IMAGE_TAR=$DIB_RELEASE-Cloud-$ARCH-latest.tgz
mkdir -p $IMG_PATH
@ -28,8 +28,10 @@ if [ ! -f $IMG_PATH/$BASE_IMAGE_TAR ] ; then
EACTION="rm -r $WORKING"
trap "$EACTION" EXIT
echo "Working in $WORKING"
tar -xJC $WORKING -f $IMG_PATH/$BASE_IMAGE_FILE
LOOPDEV=$(sudo losetup --show -r -f $WORKING/*.raw)
RAW_FILE=$(basename $BASE_IMAGE_FILE)
RAW_FILE=${RAW_FILE#.qcow2}.raw
qemu-img convert -f qcow2 -O raw $IMG_PATH/$BASE_IMAGE_FILE $WORKING/$RAW_FILE
LOOPDEV=$(sudo losetup --show -r -f $WORKING/$RAW_FILE)
EACTION="sudo losetup -d $LOOPDEV;$EACTION"
trap "$EACTION" EXIT
sudo partprobe $LOOPDEV