From 6911636e0e47b87ccf9bce1c3df5508e884df475 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 22 Feb 2018 20:46:41 +0200 Subject: [PATCH] writeimage.sh: add support for decompressing xz images --- writeimage.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/writeimage.sh b/writeimage.sh index 12364dda7b5..36946f8370c 100755 --- a/writeimage.sh +++ b/writeimage.sh @@ -20,7 +20,7 @@ fi if [[ $(id -u) -ne 0 ]]; then echo "please run as root"; exit 1; fi function msg() { - echo ":: $1" + echo " * $1" } while getopts "a:d:f:h:i:lm:n:o:p:s:w" o; do @@ -76,12 +76,25 @@ if ! [ -f $DISK_IMG ]; then exit 1 fi -gunzip=$(which unpigz 2> /dev/null || which gunzip 2> /dev/null) +gunzip=$(which unpigz 2> /dev/null || which gunzip 2> /dev/null || true) +unxz=$(which unxz 2> /dev/null || true) if [[ $DISK_IMG == *.gz ]]; then - msg "decompressing the gzipped image" + if [ -z "$gunzip" ]; then + msg "make sure you have the gzip package installed" + exit 1 + fi + msg "decompressing the .gz compressed image" $gunzip -c $DISK_IMG > ${DISK_IMG%???} DISK_IMG=${DISK_IMG%???} +elif [[ $DISK_IMG == *.xz ]]; then + if [ -z "$unxz" ]; then + msg "make sure you have the xz package installed" + exit 1 + fi + msg "decompressing the .xz compressed image" + $unxz -T 0 -c $DISK_IMG > ${DISK_IMG%???} + DISK_IMG=${DISK_IMG%???} fi umount ${SDCARD_DEV}* 2>/dev/null || true