Switch to the ReVanced API for versions info

This commit is contained in:
Sayantan Santra 2022-10-12 23:29:22 -05:00
parent 272edd83b5
commit 350bf25805
3 changed files with 57 additions and 49 deletions

View file

@ -12,7 +12,7 @@ Just run `./build_revanced <working-directory> (force/clean/experimental)`. Migh
- Under **NO CIRCUMSTANCES** any APKs will be uploaded to this repository to avoid DMCA. - Under **NO CIRCUMSTANCES** any APKs will be uploaded to this repository to avoid DMCA.
- The script assumes that the working directory has the `telegram.sh` script along with a working config file, and `telegram-upload` installed and working with the channel link saved in a file called `channel_address`. For their config, look at the links provided on top. - The script assumes that the working directory has the `telegram.sh` script along with a working config file, and `telegram-upload` installed and working with the channel link saved in a file called `channel_address`. For their config, look at the links provided on top.
- In the current configuration, the script only builds YouTube ReVanced and YouTube Music ReVanced (both nonroot), but it's easy to add support for any other ReVanced app. The code for root builds is included but commented out. - In the current configuration, the script only builds YouTube ReVanced and YouTube Music ReVanced (both nonroot), but it's easy to add support for any other ReVanced app. The code for root builds is included but commented out.
- All the packages are pulled from [APKMirror](https://apkmirror.com) and GitHub (`revanced` and `EFForg` repos). - All the packages are pulled from [APKMirror](https://apkmirror.com) and GitHub (the `revanced/*` repos).
## Customize your build ## Customize your build
If you wish to continue with the default settings, you may skip this step. If you wish to continue with the default settings, you may skip this step.

View file

@ -36,24 +36,27 @@ included_patches="$(tail -n +$included_start $patch_file | grep '^[^#[:blank:]]'
# Array for storing patches # Array for storing patches
declare -a patches declare -a patches
# Artifacts associative array aka dictionary # # Artifacts associative array aka dictionary
declare -A artifacts # declare -A artifacts
artifacts["revanced-cli.jar"]="revanced/revanced-cli revanced-cli .jar" # artifacts["revanced-cli.jar"]="revanced/revanced-cli revanced-cli .jar"
artifacts["revanced-integrations.apk"]="revanced/revanced-integrations app-release-unsigned .apk" # artifacts["revanced-integrations.apk"]="revanced/revanced-integrations app-release-unsigned .apk"
artifacts["revanced-patches.jar"]="revanced/revanced-patches revanced-patches .jar" # artifacts["revanced-patches.jar"]="revanced/revanced-patches revanced-patches .jar"
artifacts["apkeep"]="EFForg/apkeep apkeep-x86_64-unknown-linux-gnu" # artifacts["apkeep"]="EFForg/apkeep apkeep-x86_64-unknown-linux-gnu"
# Required artifacts in the format repository-name_filename
artifacts="revanced/revanced-cli_revanced-cli.jar revanced/revanced-integrations_revanced-integrations.apk revanced/revanced-patches_revanced-patches.jar TeamVanced/VancedMicroG_microg.apk"
## Functions ## Functions
get_artifact_download_url() { # get_artifact_download_url() {
# Usage: get_download_url <repo_name> <artifact_name> <file_type> # # Usage: get_download_url <repo_name> <artifact_name> <file_type>
local api_url result # local api_url result
api_url="https://api.github.com/repos/$1/releases/latest" # api_url="https://api.github.com/repos/$1/releases/latest"
# shellcheck disable=SC2086 # # shellcheck disable=SC2086
result=$(curl -s $api_url | jq ".assets[] | select(.name | contains(\"$2\") and contains(\"$3\") and (contains(\".sig\") | not)) | .browser_download_url") # result=$(curl -s $api_url | jq ".assets[] | select(.name | contains(\"$2\") and contains(\"$3\") and (contains(\".sig\") | not)) | .browser_download_url")
echo "${result:1:-1}" # echo "${result:1:-1}"
} # }
# Function for populating patches array, using a function here reduces redundancy & satisfies DRY principals # Function for populating patches array, using a function here reduces redundancy & satisfies DRY principals
populate_patches() { populate_patches() {
@ -83,18 +86,21 @@ cd "$WDIR"
echo "$(date) | Statring check..." | tee -a build.log echo "$(date) | Statring check..." | tee -a build.log
# Fetch all the dependencies # Fetch all the dependencies
for artifact in "${!artifacts[@]}"; do curl -X 'GET' 'https://releases.rvcd.win/tools' -H 'accept: application/json' | sed 's:\\\/:\/:g' > latest_versions.json
for artifact in $artifacts; do
#Check for updates #Check for updates
name=$(echo "${artifacts[$artifact]}" | cut -d" " -f1) repo=$(echo $artifact | cut -d '_' -f1)
[[ "$name" == "EFForg/apkeep" && ! -f ./apkeep ]] && curl -sLo "$artifact" $(get_artifact_download_url ${artifacts[$artifact]}) && break name=$(echo $artifact | cut -d '_' -f2)
version_present=$(jq -r ".\"$name\"" versions.json) basename=$(echo $name | cut -d '.' -f1)
version=$(curl -s "https://api.github.com/repos/$name/releases/latest" | grep -Eo '"tag_name": "v(.*)"' | sed -E 's/.*"v([^"]+)".*/\1/') version_present=$(jq -r ".\"$basename\"" versions.json)
data=$(jq -r ".tools[] | select(.repository == \"$repo\") | select(.content_type | contains(\"archive\"))" latest_versions.json)
if [[ ${version_present//[!0-9]/} -lt ${version//[!0-9]/} ]]; then version=$(echo "$data" | jq -r '.version')
echo "Downloading $artifact" | tee -a build.log if [[ ${version_present//[!0-9]/} -lt ${version//[!0-9]/} || ! -f $name ]]; then
echo "Downloading $name" | tee -a build.log
[[ $name == microg.apk && -f $name ]] && microg_updated=true
# shellcheck disable=SC2086,SC2046 # shellcheck disable=SC2086,SC2046
curl -sLo "$artifact" $(get_artifact_download_url ${artifacts[$artifact]}) curl -sLo "$name" "$(echo "$data" | jq -r '.browser_download_url')"
jq ".\"$name\" = \"$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
flag=true flag=true
fi fi
done done
@ -108,18 +114,18 @@ fi
# Download required apk files # Download required apk files
"$SDIR/download_apkmirror.sh" "$WDIR" "$SDIR/download_apkmirror.sh" "$WDIR"
# Fetch microG # # Fetch microG
chmod +x apkeep # chmod +x apkeep
if [ ! -f "vanced-microG.apk" ]; then # if [ ! -f "vanced-microG.apk" ]; then
# Vanced microG 0.2.24.220220 # # Vanced microG 0.2.24.220220
VMG_VERSION="0.2.24.220220" # VMG_VERSION="0.2.24.220220"
echo "Downloading Vanced microG" | tee -a build.log # echo "Downloading Vanced microG" | tee -a build.log
./apkeep -a com.mgoogle.android.gms@$VMG_VERSION . # ./apkeep -a com.mgoogle.android.gms@$VMG_VERSION .
mv com.mgoogle.android.gms@$VMG_VERSION.apk vanced-microG.apk # mv com.mgoogle.android.gms@$VMG_VERSION.apk vanced-microG.apk
jq ".\"vanced-microG\" = \"$VMG_VERSION\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json # jq ".\"vanced-microG\" = \"$VMG_VERSION\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
fi # fi
# If the variables are NOT empty, call populate_patches with proper arguments # If the variables are NOT empty, call populate_patches with proper arguments
[[ ! -z "$excluded_patches" ]] && populate_patches "-e" "$excluded_patches" [[ ! -z "$excluded_patches" ]] && populate_patches "-e" "$excluded_patches"
@ -177,8 +183,10 @@ telegram-upload YouTube_ReVanced_nonroot_$timestamp.apk YouTube_Music_ReVanced_n
# telegram.sh uses bot account, but it supports formatted messages # telegram.sh uses bot account, but it supports formatted messages
msg=$(cat versions.json | tail -n+2 | head -n-1 | cut -c3- | sed "s/\"//g" | sed "s/,//g" | sed "s/com.google.android.apps.youtube.music/YouTube Music/" \ msg=$(cat versions.json | tail -n+2 | head -n-1 | cut -c3- | sed "s/\"//g" | sed "s/,//g" | sed "s/com.google.android.apps.youtube.music/YouTube Music/" \
| sed "s/com.google.android.youtube/YouTube/" | sed "s/vanced-microG/Vanced microG/" | sed "s/revanced\///g" | awk 1 ORS=$'\n') | sed "s/com.google.android.youtube/YouTube/" | sed "s/microg/Vanced microG/" | sed "s/revanced-/ReVanced /g" | sed "s/patches/Patches/" \
| sed "s/cli/CLI/" | sed "s/integrations/Integrations/" | awk 1 ORS=$'\n') # I know, it's a hacky solution
./telegram.sh -T "⚙⚙⚙ Build Details ⚙⚙⚙" -M "$msg"$'\n'"⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯" ./telegram.sh -T "⚙⚙⚙ Build Details ⚙⚙⚙" -M "$msg"$'\n'"⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
[ $microg_updated ] && ./telegram.sh -M "_An update of microg was published. Please download it from the link in the pinned message._"
# Do some cleanup, keep only the last 3 build's worth of files # Do some cleanup, keep only the last 3 build's worth of files
mkdir -p archive mkdir -p archive

View file

@ -13,17 +13,17 @@ WGET_HEADER="User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/2010010
# Wget function # Wget function
req() { wget -nv -O "$2" --header="$WGET_HEADER" "$1"; } req() { wget -nv -O "$2" --header="$WGET_HEADER" "$1"; }
# Wget apk verions # # Wget apk verions
get_apk_vers() { req "$1" - | sed -n 's;.*Version:</span><span class="infoSlide-value">\(.*\) </span>.*;\1;p'; } # get_apk_vers() { req "$1" - | sed -n 's;.*Version:</span><span class="infoSlide-value">\(.*\) </span>.*;\1;p'; }
# Wget apk verions(largest) # # Wget apk verions(largest)
get_largest_ver() { # get_largest_ver() {
local max=0 # local max=0
while read -r v || [ -n "$v" ]; do # while read -r v || [ -n "$v" ]; do
if [[ ${v//[!0-9]/} -gt ${max//[!0-9]/} ]]; then max=$v; fi # if [[ ${v//[!0-9]/} -gt ${max//[!0-9]/} ]]; then max=$v; fi
done # done
if [[ $max = 0 ]]; then echo ""; else echo "$max"; fi # if [[ $max = 0 ]]; then echo ""; else echo "$max"; fi
} # }
# Wget download apk # Wget download apk
dl_apk() { dl_apk() {
@ -40,7 +40,7 @@ dl_yt() {
echo "Downloading YouTube" | tee -a build.log echo "Downloading YouTube" | tee -a build.log
local last_ver local last_ver
last_ver="$version" last_ver="$version"
last_ver="${last_ver:-$(get_apk_vers "https://www.apkmirror.com/uploads/?appcategory=youtube" | get_largest_ver)}" # last_ver="${last_ver:-$(get_apk_vers "https://www.apkmirror.com/uploads/?appcategory=youtube" | get_largest_ver)}"
echo "Choosing version '${last_ver}'" | tee -a build.log echo "Choosing version '${last_ver}'" | tee -a build.log
local base_apk="com.google.android.youtube.apk" local base_apk="com.google.android.youtube.apk"
@ -62,7 +62,7 @@ dl_ytm() {
echo "Downloading YouTube Music (${arch})" | tee -a build.log echo "Downloading YouTube Music (${arch})" | tee -a build.log
local last_ver local last_ver
last_ver="$version" last_ver="$version"
last_ver="${last_ver:-$(get_apk_vers "https://www.apkmirror.com/uploads/?appcategory=youtube-music" | get_largest_ver)}" # last_ver="${last_ver:-$(get_apk_vers "https://www.apkmirror.com/uploads/?appcategory=youtube-music" | get_largest_ver)}"
echo "Choosing version '${last_ver}'" | tee -a build.log echo "Choosing version '${last_ver}'" | tee -a build.log
local base_apk="com.google.android.apps.youtube.music.apk" local base_apk="com.google.android.apps.youtube.music.apk"
@ -89,7 +89,7 @@ else
fi fi
## Main ## Main
req "https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json" patches.json curl -X 'GET' 'https://releases.rvcd.win/patches' -H 'accept: application/json' -o patches.json
for apk in "${!apks[@]}"; do for apk in "${!apks[@]}"; do
if [ ! -f $apk ]; then if [ ! -f $apk ]; then
echo "Downloading $apk" | tee -a build.log echo "Downloading $apk" | tee -a build.log