Enable logging

This commit is contained in:
Sayantan Santra 2022-10-11 19:42:28 -05:00
parent 1fb9502ef0
commit a352dcf964
2 changed files with 24 additions and 20 deletions

View file

@ -67,17 +67,20 @@ fi
# Set flag to determine if a build should happen or not # Set flag to determine if a build should happen or not
flag=false flag=false
# Get inside the working directory
cd "$WDIR"
echo "$(date) | Statring check..." | tee build.log
# Fetch all the dependencies # Fetch all the dependencies
for artifact in "${!artifacts[@]}"; do for artifact in "${!artifacts[@]}"; do
#Check for updates #Check for updates
cd "$WDIR"
name=$(echo "${artifacts[$artifact]}" | cut -d" " -f1) name=$(echo "${artifacts[$artifact]}" | cut -d" " -f1)
[[ "$name" == "EFForg/apkeep" && ! -f ./apkeep ]] && curl -sLo "$artifact" $(get_artifact_download_url ${artifacts[$artifact]}) && break [[ "$name" == "EFForg/apkeep" && ! -f ./apkeep ]] && curl -sLo "$artifact" $(get_artifact_download_url ${artifacts[$artifact]}) && break
version_present=$(jq -r ".\"$name\"" versions.json) 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/') 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 if [[ ${version_present//[!0-9]/} -lt ${version//[!0-9]/} ]]; then
echo "Downloading $artifact" echo "Downloading $artifact" | tee build.log
# 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 jq ".\"$name\" = \"$version\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
@ -87,12 +90,12 @@ done
# Exit if no updates happened # Exit if no updates happened
if [ ! $flag ]; then if [ ! $flag ]; then
echo `$date` "Nothing to update" | tee build.log echo "Nothing to update" | tee build.log
exit exit
fi fi
# Download required apk files # Download required apk files
./download_apkmirror.sh $ODIR/download_apkmirror.sh
# Fetch microG # Fetch microG
chmod +x apkeep chmod +x apkeep
@ -101,7 +104,7 @@ 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" echo "Downloading Vanced microG" | tee 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
@ -121,13 +124,13 @@ if [ -f "com.google.android.youtube.apk" ]; then
# -e microg-support ${patches[@]} \ # -e microg-support ${patches[@]} \
# $EXPERIMENTAL \ # $EXPERIMENTAL \
# -a com.google.android.youtube.apk -o build/revanced-root.apk # -a com.google.android.youtube.apk -o build/revanced-root.apk
echo "Building Non-root APK" echo "Building Non-root APK" | tee build.log
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 ReVanced-nonroot-$timestamp.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" | tee build.log
fi fi
echo "" echo ""
echo "************************************" echo "************************************"
@ -139,16 +142,17 @@ if [ -f "com.google.android.apps.youtube.music.apk" ]; then
# -e microg-support ${patches[@]} \ # -e microg-support ${patches[@]} \
# $EXPERIMENTAL \ # $EXPERIMENTAL \
# -a com.google.android.apps.youtube.music.apk -o build/revanced-music-root.apk # -a com.google.android.apps.youtube.music.apk -o build/revanced-music-root.apk
echo "Building Non-root APK" echo "Building Non-root APK" | tee build.log
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 ReVanced-Music-nonroot-$timestamp.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" | tee build.log
fi fi
# Send telegram message about the new build # Send telegram message about the new build
echo "Sending messages to telegram" | tee build.log
telegram-upload ReVanced-nonroot-$timestamp.apk ReVanced-Music-nonroot-$timestamp.apk --to "placeholder_for_channel_address" --caption "" telegram-upload ReVanced-nonroot-$timestamp.apk ReVanced-Music-nonroot-$timestamp.apk --to "placeholder_for_channel_address" --caption ""
echo "Build details:" > message.tmp echo "Build details:" > message.tmp
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/">> message.tmp 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/">> message.tmp

View file

@ -29,7 +29,7 @@ get_largest_ver() {
dl_apk() { dl_apk() {
local url=$1 regexp=$2 output=$3 local url=$1 regexp=$2 output=$3
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n "s/href=\"/@/g; s;.*${regexp}.*;\1;p")" url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n "s/href=\"/@/g; s;.*${regexp}.*;\1;p")"
echo "$url" echo "$url" | tee build.log
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')" url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')"
url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')" url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')"
req "$url" "$output" req "$url" "$output"
@ -37,18 +37,18 @@ dl_apk() {
# Downloading youtube # Downloading youtube
dl_yt() { dl_yt() {
echo "Downloading YouTube" echo "Downloading YouTube" | tee 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}'" echo "Choosing version '${last_ver}'" | tee build.log
local base_apk="com.google.android.youtube.apk" local base_apk="com.google.android.youtube.apk"
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}" | tee build.log
echo "downloaded from: [APKMirror - YouTube]($dl_url)" echo "downloaded from: [APKMirror - YouTube]($dl_url)" | tee build.log
jq ".\"$apk\" = \"$last_ver\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json jq ".\"$apk\" = \"$last_ver\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
} }
@ -59,12 +59,12 @@ ARM_V7A="arm-v7a"
# Downloading youtube music # Downloading youtube music
dl_ytm() { dl_ytm() {
local arch=$ARM64_V8A local arch=$ARM64_V8A
echo "Downloading YouTube Music (${arch})" echo "Downloading YouTube Music (${arch})" | tee 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}'" echo "Choosing version '${last_ver}'" | tee build.log
local base_apk="com.google.android.apps.youtube.music.apk" local base_apk="com.google.android.apps.youtube.music.apk"
if [ "$arch" = "$ARM64_V8A" ]; then if [ "$arch" = "$ARM64_V8A" ]; then
local regexp_arch='arm64-v8a</div>[^@]*@\([^"]*\)' local regexp_arch='arm64-v8a</div>[^@]*@\([^"]*\)'
@ -74,8 +74,8 @@ dl_ytm() {
declare -r dl_url=$(dl_apk "https://www.apkmirror.com/apk/google-inc/youtube-music/youtube-music-${last_ver//./-}-release/" \ declare -r dl_url=$(dl_apk "https://www.apkmirror.com/apk/google-inc/youtube-music/youtube-music-${last_ver//./-}-release/" \
"$regexp_arch" \ "$regexp_arch" \
"$base_apk") "$base_apk")
echo "\nYouTube Music (${arch}) version: ${last_ver}" echo "\nYouTube Music (${arch}) version: ${last_ver}" | tee build.log
echo "downloaded from: [APKMirror - YouTube Music ${arch}]($dl_url)" echo "downloaded from: [APKMirror - YouTube Music ${arch}]($dl_url)" | tee build.log
jq ".\"$apk\" = \"$last_ver\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json jq ".\"$apk\" = \"$last_ver\"" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
} }
@ -87,7 +87,7 @@ cd "/home/sintan/Downloads/Random/ReVanced/build/"
for apk in "${!apks[@]}"; do for apk in "${!apks[@]}"; do
if [ ! -f $apk ]; then if [ ! -f $apk ]; then
echo "Downloading $apk" echo "Downloading $apk" | tee build.log
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
@ -99,6 +99,6 @@ for apk in "${!apks[@]}"; do
fi fi
done done
version_present=$(jq -r ".\"$apk\"" versions.json) version_present=$(jq -r ".\"$apk\"" versions.json)
[[ ${version_present//[!0-9]/} -lt ${version//[!0-9]/} ]] && ${apks[$apk]} || echo "Recommended version of "$apk" already present" [[ ${version_present//[!0-9]/} -lt ${version//[!0-9]/} ]] && ${apks[$apk]} || echo "Recommended version of "$apk" already present" | tee build.log
fi fi
done done