From b05c20500a8a3eb78468592f2885a32967dcf657 Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Wed, 22 Mar 2023 15:22:30 +0200 Subject: [PATCH] Initial commit Signed-off-by: Nikolaos Karaolidis --- .gitignore | 2 + Dockerfile | 18 +++++ README.md | 25 +++++++ revanced.sh | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 232 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 revanced.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c0160d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +out/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b07dc6d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu + +RUN apt-get update +RUN apt-get install -y bsdmainutils curl wget jq openjdk-17-jre aapt + +WORKDIR /app + +COPY revanced.sh . +RUN chmod +x revanced.sh + +RUN groupadd -g 1000 revanced +RUN useradd -u 1000 -g revanced revanced +RUN chown -R revanced:revanced /app +USER revanced + +ENV GITHUB_TOKEN=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 + +CMD ["./revanced.sh", "-A"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..8877c93 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# docker-revanced-builder + +A bash script that will help you in building Revanced and Revanced-Extended apps. Based on [revanced-automatic-builder](https://github.com/gnuhead-chieb/revanced-automatic-builder). + +```shell +docker run -v +``` + +## Environment Variables + +| Environment Variable | Description | +| -------------------- | -------------------------------------------- | +| `GITHUB_TOKEN` | Github token to use for downloading patches. | + +## Volumes + +| Volume | Description | +| ------------- | --------------------- | +| `/app` | The app directory. | +| `/app/build` | The build directory. | +| `/app/output` | The output directory. | + +## Notes + +Remember to download [VancedMicroG](<[VancedMicroG](https://github.com/TeamVanced/VancedMicroG/releases)>) in order to be able to sign in to your Google account. diff --git a/revanced.sh b/revanced.sh new file mode 100755 index 0000000..88841b3 --- /dev/null +++ b/revanced.sh @@ -0,0 +1,187 @@ +#!/bin/bash + +cli_api="https://api.github.com/repos/revanced/revanced-cli/releases/latest" +patches_api="https://api.github.com/repos/revanced/revanced-patches/releases/latest" +integrations_api="https://api.github.com/repos/revanced/revanced-integrations/releases/latest" + +vc=4 + +apps=("youtube" "music" "twitter" "reddit" "tiktoka" "tiktokg" "spotify" "windyapp" "nyx" "backdrops" "expensemgr" "hexedit" "ticktick" "warnapp" "iconpack" "citra" "myexpenses" "twitch") + +youtube=( + "Youtube" + "https://apkcombo.com/youtube/com.google.android.youtube" +) +music=( + "Youtube Music" + "https://apkcombo.com/youtube-music/com.google.android.apps.youtube.music" +) +twitter=( + "Twitter" + "https://apkcombo.com/twitter/com.twitter.android" +) +reddit=( + "Reddit" + "https://apkcombo.com/reddit/com.reddit.frontpage" +) +tiktoka=( + "TikTok(Asia)" + "https://apkcombo.com/tiktok-asia/com.ss.android.ugc.trill" +) +tiktokg=( + "Tiktok(Global)" + "https://apkcombo.com/tiktok/com.zhiliaoapp.musically" +) +spotify=( + "Spotify" + "https://apkcombo.com/spotify/com.spotify.music" +) +windyapp=( + "Windy.app" + "https://apkcombo.com/windy-app/co.windyapp.android" +) +nyx=( + "Nyx Music Player" + "https://apkcombo.com/nyx-music-player/com.awedea.nyx" +) +backdrops=( + "Backdrops - Wallpapers" + "https://apkcombo.com/backdrops-wallpapers/com.backdrops.wallpapers" +) +expensemgr=( + "Money Manager" + "https://apkcombo.com/money-manager-expense-budget/com.ithebk.expensemanager" +) +hexedit=( + "HEX Editor" + "https://apkcombo.com/hex-editor/com.myprog.hexedit" +) +ticktick=( + "TickTick" + "https://apkcombo.com/ticktick/com.ticktick.task" +) +warnapp=( + "WarnWetter" + "https://apkcombo.com/warnwetter/de.dwd.warnapp" +) +iconpack=( + "Icon Pack Studio" + "https://apkcombo.com/icon-pack-studio/ginlemon.iconpackstudio" +) +citra=( + "Citra Emulator" + "https://apkcombo.com/citra-emulator/org.citra.citra_emu" +) +myexpenses=( + "My Expenses" + "https://apkcombo.com/my-expenses/org.totschnig.myexpenses" +) +twitch=( + "Twitch" + "https://apkcombo.com/twitch/tv.twitch.android.app" +) + +mkdir /app/build &>/dev/null +mkdir /app/out &>/dev/null +cd /app/build + +function getappver() { + ver=$(jq -r ".[].compatiblePackages[]|select(.name==\"$(eval echo \${$1[1]} | awk -F/ '{print $NF}')\")|.versions[]" ./patches.json | awk '{if(m<$NF) m=$NF} END{print m}') + [[ -n "$ver" ]] || ver="all" + echo $ver +} + +# Check version and download revanced packages +for pkg in cli patches integrations; do + ver=$(eval curl -sH \"Authorization: token $GITHUB_TOKEN\" '$'${pkg}_api | jq -r ".name") + download=$(eval curl -sH \"Authorization: token $GITHUB_TOKEN\" '$'${pkg}_api | jq -r ".assets[-1].browser_download_url") + [[ $ver == "null" ]] && { + echo "${pkg^}:API Error" + continue + } + ls $pkg-$ver &>/dev/null && echo ${pkg^}:updated! || { + rm -f $pkg-* + wget "$download" -c -t 15 -O $pkg-$ver + } +done + +# Fetch Patches database +wget https://github.com/revanced/revanced-patches/raw/main/patches.json &>/dev/null + +exclude="" +if [ $# -eq 2 ]; then + if [ "$1" == "--exclude" ] || [ "$1" == "-e" ]; then + excludes=$2 + exclude=" -e ${excludes//,/ -e }" + fi +fi + +# List patch available app versions +echo -e "Loading apps... \n" +{ + opt=0 + for pkg in ${apps[@]}; do + eval echo "$opt:\${$pkg[0]},$(getappver $pkg)" + ((opt++)) + done +} | column -t -s, + +# If the script was run with no arguments, prompt the user to select apps +if [ $# -eq 0 ]; then + read -p "Enter the app numbers you want to download, leave blank for all (e.g. 1,3,5-7): " menuinput + if [[ -z $menuinput ]]; then + menuinput=$(seq 0 $((${#apps[@]} - 1))) + fi +# If the script was run with -a or --apps, use the second argument as the app numbers +elif [ $# -eq 2 ]; then + if [ "$1" == "--apps" ] || [ "$1" == "-a" ]; then + menuinput=$2 + fi +fi +# If the script was run with -A or --all, download all apps +if [ $# -eq 1 ]; then + if [ "$1" == "--all" ] || [ "$1" == "-A" ]; then + menuinput=$(seq 0 $((${#apps[@]} - 1))) + fi +fi + +IFS=',' read -ra app_nums <<<"$menuinput" +invalid_input=false +selected_apps=() +for num in "${app_nums[@]}"; do + if [[ $num =~ ^[0-9]+$ ]]; then + if ((num >= 0 && num < ${#apps[@]})); then + selected_apps+=($num) + else + invalid_input=true + break + fi + elif [[ $num =~ ^([0-9]+)-([0-9]+)$ ]]; then + start=${BASH_REMATCH[1]} + end=${BASH_REMATCH[2]} + if ((start < end && start >= 0 && end < ${#apps[@]})); then + for ((i = start; i <= end; i++)); do + selected_apps+=($i) + done + else + invalid_input=true + break + fi + else + invalid_input=true + break + fi +done +if $invalid_input; then + echo "Invalid input. Please enter a comma-separated list of integers or ranges." +fi + +# Download required apk from APKCombo and patch +for i in ${selected_apps[@]}; do + rm -f ${apps[$i]}-orig.apk &>/dev/null + ver=$(getappver ${apps[$i]}) + [[ "$ver" = "all" ]] && req="apk" || req="phone-${ver}-apk" + wget $(eval curl -s "\${${apps[$i]}[1]}/download/${req}" | grep -oPm1 "(?<=href=\")https://download.apkcombo.com/.*?(?=\")")\&$(curl -s "https://apkcombo.com/checkin") -O ${apps[$i]}-orig.apk + java -jar cli-* -b patches-* -m integrations-*$exclude -a ${apps[$i]}-orig.apk -c -o ${apps[$i]}-patched.apk --experimental --keystore revanced.keystore + mv ${apps[$i]}-patched.apk /app/out +done