diff --git a/MBCPApp/common.sh b/MBCPApp/common.sh index 0f68c19..2a887ec 100644 --- a/MBCPApp/common.sh +++ b/MBCPApp/common.sh @@ -126,10 +126,11 @@ pblock() { } get_mb_ver() { + [ -z "$1" ] && return 42 a="$(grep -m1 'android:versionName' "$DIRPATH"/mbapk/mbapk_unpacked/AndroidManifest.xml | tr ' ' '\n' | grep -m1 'android:versionName')" a="$(bb_split "$a" '=' '1')" a="$(strip_all "$a" '"')" - bb_split "$a" '.' '2' + bb_split "$a" '.' "$1" } good() { diff --git a/MBCPApp/parse.sh b/MBCPApp/parse.sh index f91aa40..9a638b1 100644 --- a/MBCPApp/parse.sh +++ b/MBCPApp/parse.sh @@ -77,12 +77,38 @@ for f in patches/*.sh ; do continue } [ -n "$minver" ] && { - [ "$(get_mb_ver)" -gt "$minver" ] || { + chk="${minver//[^.]}" + [ "${#chk}" -ne 2 ] && { + warn "[parser] skipping [$pname] with malformed minver" + continue + } + + minmajor="$(bb_split "$minver" '.' '0')" + minminor="$(bb_split "$minver" '.' '1')" + minpatch="$(bb_split "$minver" '.' '2')" + + [ "$(( \ + $(get_mb_ver 0) * 10000 + $(get_mb_ver 1) * 100 + $(get_mb_ver 2) ))" -lt \ + "$(( minmajor * 10000 + minminor * 100 + minpatch ))" \ + ] && { info "[parser] skipping [$pname] as current version is lower than patch version clamp" continue ; } } || : [ -n "$maxver" ] && { - [ "$(get_mb_ver)" -lt "$maxver" ] || { + chk="${maxver//[^.]}" + [ "${#chk}" -ne 2 ] && { + warn "[parser] skipping [$pname] with malformed maxver" + continue + } + + maxmajor="$(bb_split "$maxver" '.' '0')" + maxminor="$(bb_split "$maxver" '.' '1')" + maxpatch="$(bb_split "$maxver" '.' '2')" + + [ "$(( \ + $(get_mb_ver 0) * 10000 + $(get_mb_ver 1) * 100 + $(get_mb_ver 2) ))" -gt \ + "$(( maxmajor * 10000 + maxminor * 100 + maxpatch ))" \ + ] && { info "[parser] skipping [$pname] as current version is higher than patch version clamp" continue ; } } || :