Setup for automatic local builds

This commit is contained in:
Sayantan Santra 2022-10-11 18:29:50 -05:00
parent 1e03470734
commit 40547a9b3f
2 changed files with 67 additions and 28 deletions

View file

@ -1,7 +1,14 @@
#!/bin/bash #!/bin/bash
# Get timestamp
timestamp=$(date '+%s')
# File containing all patches # File containing all patches
patch_file=./patches.txt patch_file="./patches.txt"
# Set working directory and current directory
WDIR="/home/sintan/Downloads/Random/ReVanced/build/"
ODIR="$PWD"
# Get line numbers where included & excluded patches start from. # Get line numbers where included & excluded patches start from.
# We rely on the hardcoded messages to get the line numbers using grep # We rely on the hardcoded messages to get the line numbers using grep
@ -57,15 +64,36 @@ if [[ "$1" == "experimental" ]]; then
EXPERIMENTAL="--experimental" EXPERIMENTAL="--experimental"
fi fi
# Set flag to determine if a build should happen or not
flag=false
# Fetch all the dependencies # Fetch all the dependencies
for artifact in "${!artifacts[@]}"; do for artifact in "${!artifacts[@]}"; do
if [ ! -f "$artifact" ]; then #Check for updates
cd "$WDIR"
name=$(echo "${artifacts[$artifact]}" | cut -d" " -f1)
[[ "$name" == "EFForg/apkeep" && ! -f ./apkeep ]] && curl -sLo "$artifact" $(get_artifact_download_url ${artifacts[$artifact]}) && break
version_present=$(jq -r ".\"$name\"" versions.json)
version=$(curl -s "https://api.github.com/repos/$name/releases/latest" | grep -Eo '"tag_name": "v(.*)"' | sed -E 's/.*"v([^"]+)".*/\1/')
if [[ ${version_present//[!0-9]/} -lt ${version//[!0-9]/} ]]; then
echo "Downloading $artifact" echo "Downloading $artifact"
# shellcheck disable=SC2086,SC2046 # shellcheck disable=SC2086,SC2046
curl -sLo "$artifact" $(get_artifact_download_url ${artifacts[$artifact]}) curl -sLo "$artifact" $(get_artifact_download_url ${artifacts[$artifact]})
jq ".\"$name\" = \"$version\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
flag=true
fi fi
done done
# Exit if no updates happened
if [ ! $flag ]; then
echo `$date` "Nothing to update" | tee build.log
exit
fi
# Download required apk files
./download_apkmirror.sh
# Fetch microG # Fetch microG
chmod +x apkeep chmod +x apkeep
@ -76,6 +104,7 @@ if [ ! -f "vanced-microG.apk" ]; then
echo "Downloading Vanced microG" echo "Downloading Vanced microG"
./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
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
@ -86,8 +115,6 @@ echo "************************************"
echo "Building YouTube APK" echo "Building YouTube APK"
echo "************************************" echo "************************************"
mkdir -p build
if [ -f "com.google.android.youtube.apk" ]; then if [ -f "com.google.android.youtube.apk" ]; then
# echo "Building Root APK" # echo "Building Root APK"
# java -jar revanced-cli.jar -m revanced-integrations.apk -b revanced-patches.jar --mount \ # java -jar revanced-cli.jar -m revanced-integrations.apk -b revanced-patches.jar --mount \
@ -98,7 +125,7 @@ if [ -f "com.google.android.youtube.apk" ]; then
java -jar revanced-cli.jar -m revanced-integrations.apk -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.youtube.apk -o build/revanced-nonroot.apk -a com.google.android.youtube.apk -o ReVanced-nonroot-$timestamp.apk
else else
echo "Cannot find YouTube APK, skipping build" echo "Cannot find YouTube APK, skipping build"
fi fi
@ -116,7 +143,17 @@ if [ -f "com.google.android.apps.youtube.music.apk" ]; then
java -jar revanced-cli.jar -b revanced-patches.jar \ java -jar revanced-cli.jar -b revanced-patches.jar \
${patches[@]} \ ${patches[@]} \
$EXPERIMENTAL \ $EXPERIMENTAL \
-a com.google.android.apps.youtube.music.apk -o build/revanced-music-nonroot.apk -a com.google.android.apps.youtube.music.apk -o ReVanced-Music-nonroot-$timestamp.apk
else else
echo "Cannot find YouTube Music APK, skipping build" echo "Cannot find YouTube Music APK, skipping build"
fi fi
# Send telegram message about the new build
../telegram.sh -f ReVanced-nonroot-$timestamp.apk
../telegram.sh -f ReVanced-Music-nonroot-$timestamp.apk
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/" | ../telegram.sh -
# Do some cleanup
mkdir -p archive
mv ReVanced*.apk archive/
find archive/ -mtime +3 -exec rm {} \;

View file

@ -44,13 +44,12 @@ dl_yt() {
echo "Choosing version '${last_ver}'" echo "Choosing version '${last_ver}'"
local base_apk="com.google.android.youtube.apk" local base_apk="com.google.android.youtube.apk"
if [ ! -f "$base_apk" ]; then
declare -r dl_url=$(dl_apk "https://www.apkmirror.com/apk/google-inc/youtube/youtube-${last_ver//./-}-release/" \ declare -r dl_url=$(dl_apk "https://www.apkmirror.com/apk/google-inc/youtube/youtube-${last_ver//./-}-release/" \
"APK</span>[^@]*@\([^#]*\)" \ "APK</span>[^@]*@\([^#]*\)" \
"$base_apk") "$base_apk")
echo "YouTube version: ${last_ver}" echo "YouTube version: ${last_ver}"
echo "downloaded from: [APKMirror - YouTube]($dl_url)" echo "downloaded from: [APKMirror - YouTube]($dl_url)"
fi jq ".\"$apk\" = \"$last_ver\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
} }
# Architectures # Architectures
@ -67,7 +66,6 @@ dl_ytm() {
echo "Choosing version '${last_ver}'" echo "Choosing version '${last_ver}'"
local base_apk="com.google.android.apps.youtube.music.apk" local base_apk="com.google.android.apps.youtube.music.apk"
if [ ! -f "$base_apk" ]; then
if [ "$arch" = "$ARM64_V8A" ]; then if [ "$arch" = "$ARM64_V8A" ]; then
local regexp_arch='arm64-v8a</div>[^@]*@\([^"]*\)' local regexp_arch='arm64-v8a</div>[^@]*@\([^"]*\)'
elif [ "$arch" = "$ARM_V7A" ]; then elif [ "$arch" = "$ARM_V7A" ]; then
@ -78,25 +76,29 @@ dl_ytm() {
"$base_apk") "$base_apk")
echo "\nYouTube Music (${arch}) version: ${last_ver}" echo "\nYouTube Music (${arch}) version: ${last_ver}"
echo "downloaded from: [APKMirror - YouTube Music ${arch}]($dl_url)" echo "downloaded from: [APKMirror - YouTube Music ${arch}]($dl_url)"
fi jq ".\"$apk\" = \"$last_ver\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
} }
# Get into the build directory
cd "/home/sintan/Downloads/Random/ReVanced/build/"
## Main ## Main
for apk in "${!apks[@]}"; do for apk in "${!apks[@]}"; do
if [ ! -f $apk ]; then if [ ! -f $apk ]; then
echo "Downloading $apk" echo "Downloading $apk"
[ ! -f patches.json ] && req "https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json" patches.json req "https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json" patches.json
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
if [ $vers != "null" ]; then if [ $vers != "null" ]; then
if [[ $vers==0 || ${vers//[!0-9]/} -lt ${version//[!0-9]/} ]]; then if [[ $version==0 || ${vers//[!0-9]/} -lt ${version//[!0-9]/} ]]; then
version=$vers version=$vers
fi fi
fi fi
done done
# version=$(jq -r ".\"$apk\"" <versions.json) version_present=$(jq -r ".\"$apk\"" versions.json)
${apks[$apk]} [[ ${version_present//[!0-9]/} -lt ${version//[!0-9]/} ]] && ${apks[$apk]} || echo "Recommended version of "$apk" already present"
fi fi
done done