tizen: make version parsing insensitive to message tranlations
authorŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 18 Dec 2020 19:11:50 +0000 (20:11 +0100)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 17 Oct 2023 04:19:28 +0000 (13:19 +0900)
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 <l.stelmach@samsung.com>
scripts/tizen/sd_fusing_amlogic.sh
scripts/tizen/sd_fusing_rpi3.sh

index 2e904fe..2961682 100755 (executable)
@@ -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
index 0b95257..bbf9741 100755 (executable)
@@ -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