base-files: upgrade: add get_image_dd()
[openwrt/staging/noltari.git] / package / base-files / files / lib / upgrade / common.sh
index 5eb7b23a830791136b7899145b16a6cd2be49cd5..a5c27dc2fbb63d9d5be8202f4ddc147a083b62dd 100644 (file)
@@ -106,6 +106,17 @@ get_image() { # <source> [ <command> ]
        $cmd <"$from"
 }
 
+get_image_dd() {
+       local from="$1"; shift
+
+       (
+               exec 3>&2
+               ( exec 3>&2; get_image "$from" 2>&1 1>&3 | grep -v -F ' Broken pipe'     ) 2>&1 1>&3 \
+                       | ( exec 3>&2; dd "$@" 2>&1 1>&3 | grep -v -E ' records (in|out)') 2>&1 1>&3
+               exec 3>&-
+       )
+}
+
 get_magic_word() {
        (get_image "$@" | dd bs=2 count=1 | hexdump -v -n 2 -e '1/1 "%02x"') 2>/dev/null
 }