44#
55# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7- # Last Modified: 2025-Jun-17
7+ # Last Modified: 2025-Jun-28
88# ##################################################################
99set -u
1010
1111# # Set version for each Production Release ##
12- readonly SCRIPT_VERSION=1.4.9
12+ readonly SCRIPT_VERSION=1.5.0
1313readonly SCRIPT_NAME=" MerlinAU"
1414# # Set to "master" for Production Releases ##
1515SCRIPT_BRANCH=" dev"
@@ -4918,13 +4918,14 @@ _GetLatestFWUpdateVersionFromWebsite_()
49184918}
49194919
49204920# #------------------------------------------##
4921- # # Modified by ExtremeFiretop [2024-May-05 ] ##
4921+ # # Modified by ExtremeFiretop [2025-Jun-28 ] ##
49224922# #------------------------------------------##
49234923_GetLatestFWUpdateVersionFromGitHub_ ()
49244924{
4925- local routerVersion
4925+ local routerVersion search_type
49264926 local gitURL=" $1 " # GitHub URL for the latest release #
49274927 local firmware_type=" $2 " # "tuf", "rog" or "pure" #
4928+ local grep_pattern downloadURLs theURL urlVersion
49284929
49294930 local search_type=" $firmware_type " # Default to the input firmware_type #
49304931
@@ -4934,6 +4935,12 @@ _GetLatestFWUpdateVersionFromGitHub_()
49344935 search_type=" pure\|squashfs\|ubi"
49354936 fi
49364937
4938+ case " $gitURL " in
4939+ * /releases/latest) gitURL=" ${gitURL%/ latest} ?per_page=5" ;;
4940+ * /releases) gitURL=" ${gitURL} ?per_page=5" ;;
4941+ esac
4942+
4943+ # Get current router version & product ID #
49374944 if ! " $offlineUpdateTrigger "
49384945 then
49394946 routerVersion=" $( _GetLatestFWUpdateVersionFromRouter_) "
@@ -4946,38 +4953,40 @@ _GetLatestFWUpdateVersionFromGitHub_()
49464953 return 1
49474954 fi
49484955
4949- # Fetch the latest release data from GitHub #
4950- local release_data=" $( curl -s " $gitURL " ) "
4951-
49524956 # Construct the grep pattern based on search_type #
4953- local grep_pattern=" \" browser_download_url\" : \" .*${PRODUCT_ID} .*\(${search_type} \).*\.\(w\|pkgtb\)\" "
4957+ grep_pattern=" \" browser_download_url\" : \" .*${PRODUCT_ID} .*\\ (${search_type} \\ ).*\\ .\(w\ \ |pkgtb\)\" "
49544958
49554959 # Extract all matched download URLs #
4956- local downloadURLs=" $( echo " $release_data " | \
4957- grep -o " $grep_pattern " | \
4958- grep -o " https://[^ ]*\ .\(w\|pkgtb\)" ) "
4960+ downloadURLs=" $( curl -s " $gitURL " \
4961+ | grep -o " $grep_pattern " \
4962+ | grep -o ' https://[^"]* .\(w\|pkgtb\)' ) "
49594963
49604964 if [ -z " $downloadURLs " ]
49614965 then
49624966 echo " **ERROR** **NO_GITHUB_URL**"
49634967 return 1
49644968 else
4965- local theURL urlVersion
49664969 for theURL in $downloadURLs
49674970 do
49684971 # Extract the version portion from the URL #
49694972 urlVersion=" $( echo " $theURL " \
4970- | grep -oE " ${PRODUCT_ID} _[^ ]*\.(w|pkgtb)" \
4971- | sed " s/${PRODUCT_ID} _//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g;s/-gnuton[0-9][0-9]*\$ //" | head -n1) "
4972-
4973- if [ " $urlVersion " = " $routerVersion " ]
4974- then
4975- echo " $urlVersion "
4976- echo " $theURL "
4977- return 0
4978- fi
4973+ | grep -oE " ${PRODUCT_ID} _[^/]*\.(w|pkgtb)" \
4974+ | sed -e " s/${PRODUCT_ID} _//" \
4975+ -e " s/\.w$//" -e " s/\.pkgtb$//" \
4976+ -e " s/_ubi$//" -e " s/_puresqubi$//" -e " s/_nand_squashfs$//" \
4977+ -e ' s/_/./' -e ' s/_/./' \
4978+ -e " s/-gnuton[0-9][0-9]*\$ //" | head -n1) "
4979+
4980+ case " $urlVersion " in
4981+ * " $routerVersion " * )
4982+ echo " $urlVersion "
4983+ echo " $theURL "
4984+ return 0
4985+ ;;
4986+ esac
49794987 done
49804988 fi
4989+ return 1
49814990}
49824991
49834992# #------------------------------------------##
@@ -8224,27 +8233,39 @@ _EntwareServicesHandler_()
82248233}
82258234
82268235# #------------------------------------------##
8227- # # Modified by ExtremeFiretop [2024-Nov-15 ] ##
8236+ # # Modified by ExtremeFiretop [2025-Jun-28 ] ##
82288237# #------------------------------------------##
82298238_GetOfflineFirmwareVersion_ ()
82308239{
82318240 local zip_file=" $1 "
8232- local extract_version_regex=' [0-9]+_[0-9]+\.[0-9]+_[0-9a-zA-Z]+'
8233- local validate_version_regex=' [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(_ [0-9a-zA-Z ]+)?'
8241+ local extract_version_regex=' [0-9]+_[0-9]+\.[0-9]+_[0-9a-zA-Z]+(-gnuton[0-9a-zA-Z_]+)? '
8242+ local validate_version_regex=' [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+([_-] [0-9a-zA-Z_ ]+)?'
82348243 local fwVersionFormat firmware_version formatted_version
82358244
82368245 # Extract the version number using regex #
82378246 firmware_version=" $( echo " $zip_file " | grep -oE " $extract_version_regex " ) "
8247+ firmware_version=" ${firmware_version% _ubi* } "
82388248
82398249 if [ -n " $firmware_version " ]
82408250 then
82418251 if echo " $firmware_version " | grep -qE ' ^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+)$'
82428252 then
8243- # Numeric patch version
8253+ # Numeric patch (Merlin)
82448254 formatted_version=" $( echo " $firmware_version " | sed -E ' s/^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+)/\1.\2.\3.\4/' ) "
8255+
8256+ elif echo " $firmware_version " | grep -qE ' ^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+)-gnuton[0-9]+$'
8257+ then
8258+ # Stable Gnuton build – drop the “-gnutonN” tail
8259+ formatted_version=" $( echo " $firmware_version " | sed -E ' s/^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+)-gnuton[0-9]+$/\1.\2.\3.\4/' ) "
8260+
8261+ elif echo " $firmware_version " | grep -qE ' ^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+-gnuton[0-9]+_(alpha|beta)[0-9a-zA-Z]*)$'
8262+ then
8263+ # Gnuton beta/alpha – keep the “-gnuton…_beta/alpha” suffix
8264+ formatted_version=" $( echo " $firmware_version " | sed -E ' s/^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9]+-gnuton[0-9]+_[a-zA-Z]+[0-9a-zA-Z]*)/\1.\2.\3.\4/' ) "
8265+
82458266 elif echo " $firmware_version " | grep -qE ' ^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9a-zA-Z]+)$'
82468267 then
8247- # Alphanumeric suffix
8268+ # Alphanumeric suffix (Merlin “_beta3”, “_alpha1”, etc.)
82488269 formatted_version=" $( echo " $firmware_version " | sed -E ' s/^([0-9]+)_([0-9]+)\.([0-9]+)_([0-9a-zA-Z]+)/\1.\2.\3.0_\4/' ) "
82498270 else
82508271 printf " \nFailed to parse firmware version from the ZIP file name.\n"
@@ -8274,7 +8295,12 @@ _GetOfflineFirmwareVersion_()
82748295 printf " \nFailed to identify firmware version from the ZIP file name."
82758296 fi
82768297 printf " \nPlease enter the firmware version number in the format ${fwVersionFormat} \n"
8277- printf " \n(Examples: 3004.388.8.0 or 3004.388.8.0_beta1). Enter 'e' to exit: "
8298+ if " $isGNUtonFW "
8299+ then
8300+ printf " \n(Examples: 3004.388.8.0 or 3004.388.8.0-gnuton0_beta3). Enter 'e' to exit: "
8301+ else
8302+ printf " \n(Examples: 3004.388.8.0 or 3004.388.8.0_beta1). Enter 'e' to exit: "
8303+ fi
82788304 read -r formatted_version
82798305
82808306 # Validate user input #
@@ -8285,7 +8311,12 @@ _GetOfflineFirmwareVersion_()
82858311 fi
82868312 printf " \n${REDct} **WARNING**${NOct} Invalid format detected!\n"
82878313 printf " \nPlease enter the firmware version number in the format ${fwVersionFormat} \n"
8288- printf " \n(i.e 3004.388.8.0 or 3004.388.8.0_beta1). Enter 'e' to exit: "
8314+ if " $isGNUtonFW "
8315+ then
8316+ printf " \n(Examples: 3004.388.8.0 or 3004.388.8.0-gnuton0_beta3). Enter 'e' to exit: "
8317+ else
8318+ printf " \n(Examples: 3004.388.8.0 or 3004.388.8.0_beta1). Enter 'e' to exit: "
8319+ fi
82898320 read -r formatted_version
82908321 done
82918322 printf " \nThe user-provided firmware version: ${GRNct} $formatted_version ${NOct} \n"
0 commit comments