mirror of
https://github.com/SinTan1729/ReVancedBuilder.git
synced 2024-12-26 20:58:37 -06:00
Fixed version comparison logic
This commit is contained in:
parent
5b20f11739
commit
42039f26ab
2 changed files with 21 additions and 7 deletions
|
@ -17,6 +17,13 @@ else
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Returns if $1 is less than $2
|
||||||
|
ver_less_than() {
|
||||||
|
[ ${1:0:1} == "v" ] && var1=${1:1} || var1=$1
|
||||||
|
[ ${2:0:1} == "v" ] && var2=${2:1} || var2=$2
|
||||||
|
[ $(echo $var1$'\n'$var2 | sort -V | tail -n1) != $var1 ] && echo true || echo false
|
||||||
|
}
|
||||||
|
|
||||||
# Make sure to work in the script directory
|
# Make sure to work in the script directory
|
||||||
SDIR="$(dirname -- "$( readlink -f -- "$0"; )";)"
|
SDIR="$(dirname -- "$( readlink -f -- "$0"; )";)"
|
||||||
cd "$SDIR"
|
cd "$SDIR"
|
||||||
|
@ -95,9 +102,9 @@ for artifact in $artifacts; do
|
||||||
version_present=$(jq -r ".\"$basename\"" versions.json)
|
version_present=$(jq -r ".\"$basename\"" versions.json)
|
||||||
data=$(jq -r ".tools[] | select((.repository == \"$repo\") and (.content_type | contains(\"archive\")))" latest_versions.json)
|
data=$(jq -r ".tools[] | select((.repository == \"$repo\") and (.content_type | contains(\"archive\")))" latest_versions.json)
|
||||||
version=$(echo "$data" | jq -r '.version')
|
version=$(echo "$data" | jq -r '.version')
|
||||||
if [[ ${version_present//[!0-9]/} -lt ${version//[!0-9]/} || ! -f $name ]]; then
|
if [[ $(ver_less_than $version_present $version) == true || ! -f $name || $2 == force ]]; then
|
||||||
echo "Downloading $name" | tee -a build.log
|
echo "Downloading $name" | tee -a build.log
|
||||||
[[ $name == microg.apk && -f $name ]] && microg_updated=true
|
[[ $name == microg.apk && -f $name && $2 != force ]] && microg_updated=true
|
||||||
# shellcheck disable=SC2086,SC2046
|
# shellcheck disable=SC2086,SC2046
|
||||||
curl -sLo "$name" "$(echo "$data" | jq -r '.browser_download_url')"
|
curl -sLo "$name" "$(echo "$data" | jq -r '.browser_download_url')"
|
||||||
jq ".\"$basename\" = \"$version\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
|
jq ".\"$basename\" = \"$version\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
|
||||||
|
@ -112,7 +119,7 @@ if [[ $flag == false && "$2" != "force" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download required apk files
|
# Download required apk files
|
||||||
"$SDIR/download_apkmirror.sh" "$WDIR"
|
"$SDIR/download_apkmirror.sh" "$WDIR" $2
|
||||||
|
|
||||||
# # Fetch microG
|
# # Fetch microG
|
||||||
# chmod +x apkeep
|
# chmod +x apkeep
|
||||||
|
@ -155,12 +162,12 @@ echo "Building YouTube Music APK"
|
||||||
echo "************************************"
|
echo "************************************"
|
||||||
if [ -f "com.google.android.apps.youtube.music.apk" ]; then
|
if [ -f "com.google.android.apps.youtube.music.apk" ]; then
|
||||||
# echo "Building Root APK"
|
# echo "Building Root APK"
|
||||||
# java -jar revanced-cli.jar -b revanced-patches.jar --mount \
|
# java -jar revanced-cli.jar -m revanced-integrations.apk -b revanced-patches.jar --mount \
|
||||||
# -e microg-support ${patches[@]} \
|
# -e microg-support ${patches[@]} \
|
||||||
# $EXPERIMENTAL \
|
# $EXPERIMENTAL \
|
||||||
# -a com.google.android.apps.youtube.music.apk -o build/revanced-ytm-root.apk
|
# -a com.google.android.apps.youtube.music.apk -o build/revanced-ytm-root.apk
|
||||||
echo "Building Non-root APK" | tee -a build.log
|
echo "Building Non-root APK" | tee -a build.log
|
||||||
java -jar revanced-cli.jar -b revanced-patches.jar \
|
java -jar revanced-cli.jar -m revanced-integrations.apk -b revanced-patches.jar \
|
||||||
${patches[@]} \
|
${patches[@]} \
|
||||||
$EXPERIMENTAL \
|
$EXPERIMENTAL \
|
||||||
-a com.google.android.apps.youtube.music.apk -o revanced-ytm-nonroot.apk
|
-a com.google.android.apps.youtube.music.apk -o revanced-ytm-nonroot.apk
|
||||||
|
|
|
@ -25,6 +25,13 @@ req() { wget -nv -O "$2" --header="$WGET_HEADER" "$1"; }
|
||||||
# if [[ $max = 0 ]]; then echo ""; else echo "$max"; fi
|
# if [[ $max = 0 ]]; then echo ""; else echo "$max"; fi
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
# Returns if $1 is less than $2
|
||||||
|
ver_less_than() {
|
||||||
|
[ ${1:0:1} == "v" ] && var1=${1:1} || var1=$1
|
||||||
|
[ ${2:0:1} == "v" ] && var2=${2:1} || var2=$2
|
||||||
|
[ $(echo $var1$'\n'$var2 | sort -V | tail -n1) != $var1 ] && echo true || echo false
|
||||||
|
}
|
||||||
|
|
||||||
# Wget download apk
|
# Wget download apk
|
||||||
dl_apk() {
|
dl_apk() {
|
||||||
local url=$1 regexp=$2 output=$3
|
local url=$1 regexp=$2 output=$3
|
||||||
|
@ -95,8 +102,8 @@ for apk in "${!apks[@]}"; do
|
||||||
supported_vers="$(jq -r '.[].compatiblePackages[] | select(.name == "'$apk'") | .versions | last' patches.json)"
|
supported_vers="$(jq -r '.[].compatiblePackages[] | select(.name == "'$apk'") | .versions | last' patches.json)"
|
||||||
version=0
|
version=0
|
||||||
for vers in $supported_vers; do
|
for vers in $supported_vers; do
|
||||||
[ $vers != "null" ] && [[ $version==0 || ${vers//[!0-9]/} -lt ${version//[!0-9]/} ]] && version=$vers
|
[ $vers != "null" ] && [[ $(ver_less_than $vers $version) == true || $version == 0 ]] && version=$vers
|
||||||
done
|
done
|
||||||
version_present=$(jq -r ".\"$apk\"" versions.json)
|
version_present=$(jq -r ".\"$apk\"" versions.json)
|
||||||
[[ ${version_present//[!0-9]/} -lt ${version//[!0-9]/} || ! -f $apk.apk ]] && ${apks[$apk]} || echo "Recommended version of "$apk" is already present" | tee -a build.log
|
[[ $(ver_less_than $version_present $version) == true || ! -f $apk.apk || $2 == force ]] && ${apks[$apk]} || echo "Recommended version of "$apk" is already present" | tee -a build.log
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue