From 4447316896e4d4c1c832dca7aa5fde82e448690c Mon Sep 17 00:00:00 2001 From: Kamil Dziezyk Date: Mon, 11 May 2020 14:29:26 +0100 Subject: [PATCH] arm-autonomy: xenguest-mgr: Add support for compressed partition images xenguest-manager now can create guest partition using compressed images like *.img.gz or *.img.bz2. Change-Id: Ifaec0b7c301b2b316ebccdd0ca85083262f2714c Signed-off-by: Kamil Dziezyk Reviewed-by: Bertrand Marquis Signed-off-by: Jon Mason --- .../documentation/xenguest-mkimage.md | 2 +- .../xenguest/files/xenguest-manager | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/meta-arm-autonomy/documentation/xenguest-mkimage.md b/meta-arm-autonomy/documentation/xenguest-mkimage.md index d77fd48b..3dcc28b4 100644 --- a/meta-arm-autonomy/documentation/xenguest-mkimage.md +++ b/meta-arm-autonomy/documentation/xenguest-mkimage.md @@ -62,7 +62,7 @@ The file contains the following entries: - `DISK_PARTX=SIZE:FS:CONTENT`: create a partition number X (1 to 4) with a size of SIZE GB, format it with filesystem FS (can be ext2, ext3, ext4, vfat or swap) and extract CONTENT as initial partition content - (.tar[.gz|.xz|.bz2] file or img file to be dumped in the partition). FS and + (.tar[.gz|.xz|.bz2] file or img[.gz|.bz2] file to be dumped in the partition). FS and CONTENT can be empty. The disk-files contain files to be used for initializing the disk partitions diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager index 4777054f..99975a24 100755 --- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager @@ -262,12 +262,30 @@ function xenguest_disk_init() fi case ${content} in - *.img) + *.img*) + decompress="" + case ${content} in + *.img.gz) + decompress='zcat' + ;; + *.img.bz2) + decompress='bzcat' + ;; + *.img) + decompress='cat' + ;; + *) + # invalid/unknown compression type + echo "${PREF} Invalid file format in disk ${content}" + xenguest_detach_disk + exit 1 + ;; + esac # dd into partition echo "xenguest-mkimage extract-disk-file ${guestfile} " \ - "${content} | dd of=/dev/xvda${part} " >> ${LOGFILE} 2>&1 + "${content} | ${decompress} | dd of=/dev/xvda${part} " >> ${LOGFILE} 2>&1 xenguest-mkimage extract-disk-file ${guestfile} ${content} \ - | dd of=/dev/xvda${part} >> ${LOGFILE} 2>&1 + | ${decompress} | dd of=/dev/xvda${part} >> ${LOGFILE} 2>&1 if [ $? -ne 0 ]; then echo "${PREF} Cannot populate partition ${part}" xenguest_detach_disk