+HDDIMG_EXT=${HDDIMG##*.}
+case $HDDIMG_EXT in
+ hddimg)
+ IMG_TYPE="MOUNT"
+ IMG_COMPRESS="NO"
+ debug "Detected: uncompressed image type .hddimg"
+ ;;
+ wic)
+ IMG_TYPE="DISK"
+ IMG_COMPRESS="NO"
+ debug "Detected: uncompressed image type .wic"
+ ;;
+ xz)
+ IMG_TYPE="DISK"
+ IMG_COMPRESS="YES"
+ debug "Detected: xz compressed image type .wic"
+ command -v xz >/dev/null 2>&1 || { die "xz command is not available, pleaes install xz package"; }
+ TMP_SIZE=`df -k $TMP_DIR | awk '/[0-9]%/{print $(NF-2)}'`
+ if [ "$TMP_SIZE" -lt "$TMP_SIZE_MIN" ]; then
+ die "Available space on $TMP_DIR must be at least $TMP_SIZE_MIN kB"
+ fi
+ printf "Starting decompression of the image. It may take some time ..."
+ xz --decompress --keep --format=auto --force --threads=0 --stdout > $TMP_DIR/TMP-AGL-wic-image.wic $HDDIMG|| \
+ die "xz command failled: xz --decompress --keep --format=auto --force --threads=0 --stdout > $TMP_DIR/TMP-AGL-wic-image.wic"
+ HDDIMG="$TMP_DIR/TMP-AGL-wic-image.wic"
+ echo "Image uncompressed, starting doing real work ..."
+ ;;
+ *)
+ die "Unsupported image format: $HDDIMG_EXT Supported format are .hddimg .wic wic.xz"
+ ;;
+esac