44#
55# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7- # Last Modified: 2025-Aug-02
7+ # Last Modified: 2025-Aug-05
88# ##################################################################
99set -u
1010
1111# # Set version for each Production Release ##
12- readonly SCRIPT_VERSION=1.5.1
12+ readonly SCRIPT_VERSION=1.5.2
1313readonly SCRIPT_NAME=" MerlinAU"
1414# # Set to "master" for Production Releases ##
15- SCRIPT_BRANCH=" master "
15+ SCRIPT_BRANCH=" dev "
1616
1717# #----------------------------------------##
1818# # Modified by Martinski W. [2024-Jul-03] ##
@@ -797,10 +797,10 @@ _FWVersionStrToNum_()
797797 USE_BETA_WEIGHT=" $( Get_Custom_Setting FW_Allow_Beta_Production_Up) "
798798
799799 local verNum verStr=" $1 "
800- local fwBasecodeVers=" " numOfFields buildDigits isBeta=0 prodFlag tagRank=2
801- local stableRank=2 betaRank=1 alphaRank=0
800+ local fwBasecodeVers=" " numOfFields prodFlag tagRank
801+ local stableRank=2 betaRank=1 alphaRank=0 buildDigits=0
802802
803- # If beta weight is NOT enabled, all tags get the same rank (0)
803+ # If beta weight is NOT enabled, all tags get the same rank (0) #
804804 if [ " $USE_BETA_WEIGHT " != " ENABLED" ]
805805 then
806806 stableRank=0 ; betaRank=0 ; alphaRank=0
@@ -813,8 +813,8 @@ _FWVersionStrToNum_()
813813 # --------------------------------------------------------------
814814 if echo " $verStr " | grep -qiE ' (alpha|beta)'
815815 then
816- if echo " $verStr " | grep -qi ' alpha' ; then tagRank=" $alphaRank " ; isBeta=1
817- elif echo " $verStr " | grep -qi ' beta' ; then tagRank=" $betaRank " ; isBeta=1
816+ if echo " $verStr " | grep -qi ' alpha' ; then tagRank=" $alphaRank "
817+ elif echo " $verStr " | grep -qi ' beta' ; then tagRank=" $betaRank "
818818 fi
819819
820820 # Replace '.alpha|.beta' and anything following it with ".0" #
@@ -839,18 +839,23 @@ _FWVersionStrToNum_()
839839 verStr=" $( echo " $verStr " | cut -d' .' -f2-) "
840840 fi
841841 # -----------------------------------------------------------
842- # NEW: capture any trailing build-suffix digits (e.g. "gnuton2" → 2)
842+ # FIX: capture trailing build-suffix digits ONLY if there is
843+ # a non-digit-and-non-dot char before them (e.g. "-gnuton2").
844+ # Plain "388.9.2" should NOT set buildDigits.
843845 # -----------------------------------------------------------
844- buildDigits=" $( echo " $verStr " | sed -n ' s/.*[^0-9]\([0-9]\+\)$/\1/p' ) "
845- buildDigits=$( printf " %02d" " ${buildDigits:- 0} " )
846+ if printf ' %s' " $verStr " | grep -q ' [^0-9.]'
847+ then
848+ buildDigits=" $( printf ' %s' " $verStr " | sed -n ' s/^[0-9.]*[^0-9.]\+\([0-9]\+\)$/\1/p' ) "
849+ fi
850+ buildDigits=" $( printf " %02d" " ${buildDigits:- 0} " ) "
846851
847- # Production/Beta/Alpha weight digit
852+ # Production/Beta/Alpha weight digit #
848853 prodFlag=" $tagRank "
849854
850- # Strip the non-numeric tail so we feed only dotted numbers to awk
855+ # Strip the non-numeric tail so we feed only dotted numbers #
851856 verStr=" $( echo " $verStr " | sed ' s/[^0-9.]*$//' ) "
852857
853- # Core numeric conversion (Major Minor Patch) + build suffix + tag weight
858+ # Core numeric conversion (Major Minor Patch) + build suffix + tag weight #
854859 verNum=" $( echo " $verStr " | awk -F' .' ' {printf ("%d%02d%02d\n", $1,$2,$3);}' ) ${buildDigits}${prodFlag} "
855860
856861 # Now prepend the F/W Basecode version #
@@ -8185,10 +8190,10 @@ _GetOfflineFirmwareVersion_()
81858190 # Numeric patch (Merlin) #
81868191 formatted_version=" $( echo " $firmware_version " | sed -E ' s/^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+)/\1.\2.\3.\4/' ) "
81878192
8188- elif echo " $firmware_version " | grep -qE ' ^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+) -gnuton[0-9]+$'
8193+ elif echo " $firmware_version " | grep -qE ' ^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+-gnuton[0-9]+) $'
81898194 then
8190- # Stable Gnuton build – drop the "-gnutonN" tail #
8191- formatted_version=" $( echo " $firmware_version " | sed -E ' s/^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+) -gnuton[0-9]+$ /\1.\2.\3.\4/' ) "
8195+ # Stable Gnuton build – keep the "-gnutonN" suffix #
8196+ formatted_version=" $( echo " $firmware_version " | sed -E ' s/^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+-gnuton[0-9]+) /\1.\2.\3.\4/' ) "
81928197
81938198 elif echo " $firmware_version " | grep -qE ' ^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+-gnuton[0-9]+_(alpha|beta)[0-9a-zA-Z]*)$'
81948199 then
0 commit comments