From 1ce901bd94b04c9abd675e4b37ed0eb2acb7c6a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Stelmach?= Date: Fri, 18 Dec 2020 20:11:50 +0100 Subject: [PATCH] tizen: make version parsing insensitive to message tranlations MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Localised versions of version messages present version number at different positions. Matching numbers with grep(1) ensures that version number is extracted properly regardles of the message format. Change-Id: I6dd4bc476aaa43c1a736f269dc14910d8653b730 Signed-off-by: Łukasz Stelmach --- scripts/tizen/sd_fusing_amlogic.sh | 14 ++++++-------- scripts/tizen/sd_fusing_rpi3.sh | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/tizen/sd_fusing_amlogic.sh b/scripts/tizen/sd_fusing_amlogic.sh index 2e904fe..2961682 100755 --- a/scripts/tizen/sd_fusing_amlogic.sh +++ b/scripts/tizen/sd_fusing_amlogic.sh @@ -55,10 +55,9 @@ function check_ddversion () { # 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%%.*} + local version=(`dd --version | head -1 | grep -o '[0-9]\+'`) + local major=${version[0]} + local minor=${version[1]} if [ $major -lt 8 ]; then OLD_DD=1 @@ -147,10 +146,9 @@ function mkpart_3 () { # NOTE: sfdisk 2.26 doesn't support units other than sectors and marks --unit option as deprecated. # The input data needs to contain multipliers (MiB) instead. - local version=`sfdisk -v | awk '{print $4}'` - local major=${version%%.*} - local version=${version:`expr index $version .`} - local minor=${version%%.*} + local version=(`sfdisk -v | grep -o '[0-9]\+'`) + local major=${version[0]} + local minor=${version[1]} local sfdisk_new=0 if [ $major -gt 2 ]; then diff --git a/scripts/tizen/sd_fusing_rpi3.sh b/scripts/tizen/sd_fusing_rpi3.sh index 0b95257..bbf9741 100755 --- a/scripts/tizen/sd_fusing_rpi3.sh +++ b/scripts/tizen/sd_fusing_rpi3.sh @@ -55,10 +55,9 @@ function check_ddversion () { # 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%%.*} + local version=(`dd --version | head -1 | grep -o '[0-9]\+'`) + local major=${version[0]} + local minor=${version[1]} if [ $major -lt 8 ]; then OLD_DD=1 @@ -147,10 +146,9 @@ function mkpart_3 () { # NOTE: sfdisk 2.26 doesn't support units other than sectors and marks --unit option as deprecated. # The input data needs to contain multipliers (MiB) instead. - local version=`sfdisk -v | awk '{print $4}'` - local major=${version%%.*} - local version=${version:`expr index $version .`} - local minor=${version%%.*} + local version=(`sfdisk -v | grep -o '[0-9]\+'`) + local major=${version[0]} + local minor=${version[1]} local sfdisk_new=0 if [ $major -gt 2 ]; then -- 2.7.4