declare FORMAT=""
declare DEVICE=""
+declare -i OLD_DD=0
# Binaires array for fusing
declare -a FUSING_BINARY_ARRAY
tput sgr 0
}
+function check_ddversion () {
+ # NOTE
+ # before coreutils dd 8.24, dd doesn't support "status=progress"
+ # and the option causes fusing failure. For backward compatibility,
+ # do not use the option for old dd
+ local version=`dd --version | head -1 | awk '{print $3}'`
+ local major=${version%%.*}
+ local version=${version:`expr index $version .`}
+ local minor=${version%%.*}
+
+ if [ $major -lt 8 ]; then
+ OLD_DD=1
+ elif [ $major -eq 8 -a $minor -lt 24 ]; then
+ OLD_DD=1
+ fi
+}
+
function fusing_image () {
local -r fusing_img=$1
return
fi
- local input_size=`du -b $fusing_img | awk '{print $1}'`
- input_size=`expr $input_size / 1024 / 1024`
+ local -r input_size=`du -b $fusing_img | awk '{print $1}'`
+ local -r input_size_mb=`expr $input_size / 1024 / 1024`
- print_message 2 "[Fusing $1 ($input_size MiB)]"
+ print_message 2 "[Fusing $1 ($input_size_mb MiB)]"
umount $device
- dd if=$fusing_img of=$device bs=$bs status=progress oflag=direct
+ if [ $OLD_DD == 1 ]; then
+ dd if=$fusing_img | pv -s $input_size | dd of=$device bs=$bs
+ else
+ dd if=$fusing_img of=$device bs=$bs status=progress oflag=direct
+ fi
local -r fstype=`blkid -o value -s TYPE $device`
if [[ "$fstype" =~ "ext" ]]; then
check_args
check_device
check_partition_format
+check_ddversion
fuse_image