@@ -102,7 +102,7 @@ action_data=()
102
102
} || {
103
103
OS=$( lsb_release -si 2>& -)
104
104
[[ " $OS " == " Ubuntu" ]] || [[ " $OS " == " LinuxMint" ]] || [[ " $OS " == " neon" ]] || {
105
- echo " Abort, this script is only intended for Ubuntu-like distro's "
105
+ echo " Abort, this script is only intended for Ubuntu-like distros "
106
106
exit 2
107
107
}
108
108
}
@@ -342,7 +342,7 @@ load_local_versions() {
342
342
local version
343
343
if [ ${# LOCAL_VERSIONS[@]} -eq 0 ]; then
344
344
IFS=$' \n '
345
- for pckg in $( dpkg -l linux-image-* | cut -d " " -f 3 | sort) ; do
345
+ for pckg in $( dpkg -l linux-image-* | cut -d " " -f 3 | sort -V ) ; do
346
346
# only match kernels from ppa
347
347
if [[ " $pckg " =~ linux-image-[0-9]+\. [0-9]+\. [0-9]+-[0-9]{6} ]]; then
348
348
version=" v" $( echo " $pckg " | cut -d" -" -f 3,4)
@@ -369,6 +369,23 @@ latest_local_version() {
369
369
}
370
370
371
371
remote_html_cache=" "
372
+ parse_remote_versions () {
373
+ local line
374
+ while read -r line; do
375
+ if [[ $line =~ DIR.* href= \" (v[[:digit:]]+\. [[:digit:]]+ (\. [[:digit:]]+)? )(-(rc[[:digit:]]+))? /\" ]]; then
376
+ line=" ${BASH_REMATCH[1]} "
377
+ if [[ -z " ${BASH_REMATCH[2]} " ]]; then
378
+ line=" $line .0"
379
+ fi
380
+ # temporarily substitute rc suffix join character for correct version sort
381
+ if [[ -n " ${BASH_REMATCH[3]} " ]]; then
382
+ line=" $line ~${BASH_REMATCH[4]} "
383
+ fi
384
+ echo " $line "
385
+ fi
386
+ done <<< " $remote_html_cache"
387
+ }
388
+
372
389
load_remote_versions () {
373
390
local line
374
391
@@ -384,28 +401,22 @@ load_remote_versions () {
384
401
fi
385
402
386
403
IFS=$' \n '
387
- for line in $remote_html_cache ; do
388
- [[ " $line " =~ " folder" ]] || continue
389
- [[ $use_rc -eq 0 ]] && [[ " $line " =~ -r c ]] && continue
390
- [[ " $line " =~ v[0-9]+\. [0-9]+ (\. [0-9]+)? (-rc[0-9]+)? / ]] || continue
404
+ while read -r line; do
405
+ # reinstate original rc suffix join character
406
+ if [[ $line =~ ^([^~]+)~([^~]+)$ ]]; then
407
+ [[ $use_rc -eq 0 ]] && continue
408
+ line=" ${BASH_REMATCH[1]} -${BASH_REMATCH[2]} "
409
+ fi
391
410
[[ -n " $2 " ]] && [[ ! " $line " =~ $2 ]] && continue
392
-
393
- line=${line##* href=\" }
394
- line=${line%% \/\" >* }
395
- [[ ! " $line " =~ (v[0-9]+\. [0-9]+)\. [0-9]+ ]] && [[ " $line " =~ (v[0-9]+\. [0-9]+)(-rc[0-9]+)? ]] && line=${BASH_REMATCH[1]} " .0" ${BASH_REMATCH[2]}
396
-
397
411
REMOTE_VERSIONS+=(" $line " )
398
- done
412
+ done < <( parse_remote_versions | sort -V )
399
413
unset IFS
400
414
fi
401
415
}
402
416
403
417
latest_remote_version () {
404
418
load_remote_versions 1 " $1 "
405
- local sorted
406
-
407
- mapfile -t sorted < <( echo " ${REMOTE_VERSIONS[*]} " | tr ' ' ' \n' | sort -V)
408
- echo " ${sorted[${#sorted[@]} -1]}"
419
+ echo " ${REMOTE_VERSIONS[${#REMOTE_VERSIONS[@]} -1]}"
409
420
}
410
421
411
422
check_environment () {
0 commit comments