From 34284e68a9f4e23adbad435f497a980ad9f5493e Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Fri, 16 Apr 2021 10:38:49 -0700 Subject: Add support for tar.gz rootfses Signed-off-by: Stefano Stabellini Signed-off-by: VĂ­ctor Mayoral Vilches Reviewed-by: Brian Woods --- README.md | 11 +++++++---- scripts/disk_image | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index eaa7431..c9a9850 100644 --- a/README.md +++ b/README.md @@ -114,12 +114,15 @@ partition for each Dom0/DomU cpio archive to write to disk. disk\_image will write to disk as separate partition each file specified as follows: -- DOM0_ROOTFS specifies the Dom0 rootfs to use. Note that the file to - write should be a regular cpio.gz file, not a u-boot binary. +- DOM0_ROOTFS specifies the Dom0 rootfs to use. -- DOMU_ROOTFS[number] specifies the DomU rootfs to use. Note that it - should be a regular cpio.gz file, not a u-boot binary. +- DOMU_ROOTFS[number] specifies the DomU rootfs to use. +The provided rootfs should not be a u-boot binary. The supported +formats are: + +- cpio.gz +- tar.gz After you've generated the u-boot scripts using the uboot-script-gen script, disk_image is run as follows: diff --git a/scripts/disk_image b/scripts/disk_image index 6f5f3e2..800de99 100755 --- a/scripts/disk_image +++ b/scripts/disk_image @@ -38,7 +38,7 @@ function add_partition() _npart=$(( $_npart + 1 )) } -function write_cpio() +function write_rootfs() { local j=$1 local rootfs=$2 @@ -49,9 +49,18 @@ function write_cpio() # Extract rootfs cpio archive into `.../part/vos_$j` cd ${DESTDIR}/part/disk$j - cat "${UBOOT_OUT_ABS}/$rootfs" | gunzip | cpio -id + + if [[ $rootfs = *.cpio.gz ]] + then + cat "${UBOOT_OUT_ABS}/$rootfs" | gunzip | cpio -id + elif [[ $rootfs = *.tar.gz ]] + then + tar xvzf "${UBOOT_OUT_ABS}/$rootfs" + else + echo "Ignoring $rootfs: unsupported file format. Use cpio.gz or tar.gz." + fi + cd - - # umount sync umount $DESTDIR/part/disk$j @@ -263,7 +272,7 @@ umount $DESTDIR/part/disk1 j=2 if test "$DOM0_ROOTFS" then - write_cpio 2 "$DOM0_ROOTFS" + write_rootfs 2 "$DOM0_ROOTFS" j=$(( $j + 1 )) fi @@ -272,7 +281,7 @@ while test $i -lt $NUM_DOMUS do if test "${DOMU_ROOTFS[$i]}" then - write_cpio $j "${DOMU_ROOTFS[$i]}" + write_rootfs $j "${DOMU_ROOTFS[$i]}" j=$(( $j + 1 )) fi i=$(( $i + 1 )) -- cgit v1.2.3