diff --git a/src/build/utils.sh b/src/build/utils.sh index 28e599b..014622a 100644 --- a/src/build/utils.sh +++ b/src/build/utils.sh @@ -166,7 +166,14 @@ get_apk() { esac fi if [ -z "$version" ] && [ "$version" != "latest" ]; then - version=$(jq -r '[.. | objects | select(.name == "'$1'" and .versions != null) | .versions[]] | reverse | .[0] // ""' *.json | uniq) + if [[ $(ls revanced-cli-*.jar) =~ revanced-cli-([0-9]+) ]]; then + num=${BASH_REMATCH[1]} + if [ $num -ge 5 ]; then + version=$(java -jar *cli*.jar list-patches --with-packages --with-versions *.rvp | awk -v pkg="$1" 'BEGIN { found = 0 } /^Index:/ { found = 0 } /Package name: / { if ($3 == pkg) { found = 1 } } /Compatible versions:/ { if (found) { getline; latest_version = $1; while (getline && $1 ~ /^[0-9]+\./) { latest_version = $1 } print latest_version; exit } }') + else + version=$(jq -r '[.. | objects | select(.name == "'$1'" and .versions != null) | .versions[]] | reverse | .[0] // ""' *.json | uniq) + fi + fi fi export version="$version" local attempt=0