Message ID | 20201110134558.7905-5-yszhou4tech@gmail.com |
---|---|
State | Accepted |
Delegated to: | Yousong Zhou |
Headers | show |
Series | sysupgrade: reword and organize log lines | expand |
Reviewed-By: Philip Prindeville <philipp@redfish-solutions.com> > On Nov 10, 2020, at 6:45 AM, Yousong Zhou <yszhou4tech@gmail.com> wrote: > > This is mainly to handle stderr message "Broken pipe", "F+P records > in/out" by common pattern "xcat | dd .." > > Ref: https://bugs.openwrt.org/index.php?do=details&task_id=3140 > Reported-by: Philip Prindeville <philipp@redfish-solutions.com> > Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> > --- > package/base-files/files/lib/upgrade/common.sh | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh > index 5eb7b23a83..a5c27dc2fb 100644 > --- a/package/base-files/files/lib/upgrade/common.sh > +++ b/package/base-files/files/lib/upgrade/common.sh > @@ -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 > }
diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index 5eb7b23a83..a5c27dc2fb 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -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 }
This is mainly to handle stderr message "Broken pipe", "F+P records in/out" by common pattern "xcat | dd .." Ref: https://bugs.openwrt.org/index.php?do=details&task_id=3140 Reported-by: Philip Prindeville <philipp@redfish-solutions.com> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> --- package/base-files/files/lib/upgrade/common.sh | 11 +++++++++++ 1 file changed, 11 insertions(+)