Skip to content

Commit 0c3198c

Browse files
Fixing More Comparison Errors
Fixing More Comparison Errors
1 parent ba1925c commit 0c3198c

1 file changed

Lines changed: 25 additions & 15 deletions

File tree

MerlinAU.sh

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66
# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7-
# Last Modified: 2025-Jul-18
7+
# Last Modified: 2025-Jul-23
88
###################################################################
99
set -u
1010

@@ -786,9 +786,9 @@ _GetFirmwareVariantFromRouter_()
786786
echo "$hasGNUtonFW" ; return 0
787787
}
788788

789-
##----------------------------------------##
790-
## Modified by Martinski W. [2024-May-31] ##
791-
##----------------------------------------##
789+
##------------------------------------------##
790+
## Modified by ExtremeFiretop [2025-July-23] ##
791+
##------------------------------------------##
792792
_FWVersionStrToNum_()
793793
{
794794
if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ]
@@ -797,7 +797,7 @@ _FWVersionStrToNum_()
797797
USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)"
798798

799799
local verNum verStr="$1" nonProductionVersionWeight=0
800-
local fwBasecodeVers="" numOfFields
800+
local fwBasecodeVers="" numOfFields buildDigits
801801

802802
#--------------------------------------------------------------
803803
# Handle any 'alpha/beta' in the version string to be sure
@@ -829,7 +829,17 @@ _FWVersionStrToNum_()
829829
fwBasecodeVers="$(echo "$verStr" | cut -d'.' -f1)"
830830
verStr="$(echo "$verStr" | cut -d'.' -f2-)"
831831
fi
832-
verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%02d%02d\n", $1,$2,$3);}')"
832+
#-----------------------------------------------------------
833+
# NEW: capture any trailing build‑suffix digits (e.g. "gnuton2" → 2)
834+
#-----------------------------------------------------------
835+
buildDigits="$(echo "$verStr" | sed -n 's/.*[^0-9]\([0-9]\+\)$/\1/p')"
836+
buildDigits=$(printf "%02d" "${buildDigits:-0}")
837+
838+
# Strip the non‑numeric tail so we feed only dotted numbers to awk
839+
verStr="$(echo "$verStr" | sed 's/[^0-9.]*$//')"
840+
841+
# Core numeric conversion (Major Minor Patch) + two‑digit build suffix
842+
verNum="$(echo "$verStr" | awk -F'.' '{printf ("%d%02d%02d\n", $1,$2,$3);}')${buildDigits}"
833843

834844
# Subtract non-production weight from the version number #
835845
verNum="$((verNum + nonProductionVersionWeight))"
@@ -2935,13 +2945,13 @@ _CreateEMailContent_()
29352945
fwInstalledVersion="$(_GetCurrentFWInstalledLongVersion_)"
29362946
if ! "$offlineUpdateTrigger"
29372947
then
2938-
fwNewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_)"
2948+
fwNewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)"
29392949
else
29402950
fwNewUpdateVersion="$(Get_Custom_Setting "FW_New_Update_Notification_Vers")"
29412951
fi
29422952

2943-
# Remove "_rog" or "_tuf" or -gHASHVALUES or -Gnuton* suffix to avoid version comparison failure, can't remove all for proper beta and alpha comparison #
2944-
fwInstalledVersion="$(echo "$fwInstalledVersion" | sed -E 's/(_(rog|tuf)|-g[0-9a-f]{10}|-gnuton[0-9]+)$//')"
2953+
# Remove "_rog" or "_tuf" or -gHASHVALUES suffix to avoid version comparison failure, can't remove all for proper beta and alpha comparison #
2954+
fwInstalledVersion="$(echo "$fwInstalledVersion" | sed -E 's/(_(rog|tuf)|-g[0-9a-f]{10})$//')"
29452955

29462956
case "$1" in
29472957
FW_UPDATE_TEST_EMAIL)
@@ -4843,7 +4853,7 @@ _GetLatestFWUpdateVersionFromGitHub_()
48434853

48444854
if ! "$offlineUpdateTrigger"
48454855
then
4846-
routerVersion="$(_GetLatestFWUpdateVersionFromRouter_)"
4856+
routerVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)"
48474857
else
48484858
routerVersion="$(Get_Custom_Setting "FW_New_Update_Notification_Vers")"
48494859
fi
@@ -4874,7 +4884,7 @@ _GetLatestFWUpdateVersionFromGitHub_()
48744884
# Extract the version portion from the URL #
48754885
urlVersion="$(echo "$theURL" \
48764886
| grep -oE "${PRODUCT_ID}_[^ ]*\.(w|pkgtb)" \
4877-
| sed "s/${PRODUCT_ID}_//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g;s/-gnuton[0-9][0-9]*\$//" | head -n1)"
4887+
| sed "s/${PRODUCT_ID}_//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g" | head -n1)"
48784888

48794889
if [ "$urlVersion" = "$routerVersion" ]
48804890
then
@@ -4905,7 +4915,7 @@ GetLatestFirmwareMD5URL()
49054915

49064916
if ! "$offlineUpdateTrigger"
49074917
then
4908-
routerVersion="$(_GetLatestFWUpdateVersionFromRouter_)"
4918+
routerVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)"
49094919
else
49104920
routerVersion="$(Get_Custom_Setting "FW_New_Update_Notification_Vers")"
49114921
fi
@@ -4937,7 +4947,7 @@ GetLatestFirmwareMD5URL()
49374947
# Extract the version portion from the URL #
49384948
md5Version="$(echo "$theURL" \
49394949
| grep -oE "${PRODUCT_ID}_[^ ]*\.(md5)" \
4940-
| sed "s/${PRODUCT_ID}_//;s/.md5$//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g;s/-gnuton[0-9][0-9]*\$//" | head -n1)"
4950+
| sed "s/${PRODUCT_ID}_//;s/.md5$//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g" | head -n1)"
49414951

49424952
if [ "$md5Version" = "$routerVersion" ]
49434953
then
@@ -8750,7 +8760,7 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or
87508760
# "New F/W Release Version" from the router itself.
87518761
# If no new F/W version update is available return.
87528762
#------------------------------------------------------
8753-
if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \
8763+
if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_ 1)" || \
87548764
! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version"
87558765
then
87568766
Say "No new firmware version update is found for [$MODEL_ID] router model."
@@ -8792,7 +8802,7 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or
87928802

87938803
if ! "$offlineUpdateTrigger"
87948804
then
8795-
NewUpdate_VersionVerify="$(_GetLatestFWUpdateVersionFromRouter_)"
8805+
NewUpdate_VersionVerify="$(_GetLatestFWUpdateVersionFromRouter_ 1)"
87968806
if [ "$NewUpdate_VersionVerify" != "$release_version" ]
87978807
then
87988808
Say "WARNING: The release version found by MerlinAU [$release_version] does not match the F/W update version from the router [$NewUpdate_VersionVerify]."

0 commit comments

Comments
 (0)