Fix cli v5

New v5 patches no longer include a .json file, so I'm using the CLI to get the correct version.
This commit is contained in:
Fioren
2024-11-06 10:54:40 +07:00
committed by GitHub
parent 1be4cd9f86
commit 1104dbd65b

View File

@@ -166,8 +166,15 @@ get_apk() {
esac esac
fi fi
if [ -z "$version" ] && [ "$version" != "latest" ]; then if [ -z "$version" ] && [ "$version" != "latest" ]; then
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) version=$(jq -r '[.. | objects | select(.name == "'$1'" and .versions != null) | .versions[]] | reverse | .[0] // ""' *.json | uniq)
fi fi
fi
fi
export version="$version" export version="$version"
local attempt=0 local attempt=0
while [ $attempt -lt 10 ]; do while [ $attempt -lt 10 ]; do