Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NoName-exe authored Sep 25, 2023
2 parents 119f71b + c4fa453 commit 4203d93
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 64 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ jobs:
${APKS}
"
echo "'$MSG'"
MSG=${MSG:0:9450}
POST="https://api.telegram.org/bot${TG_TOKEN}/sendMessage"
curl -X POST --data-urlencode "parse_mode=Markdown" --data-urlencode "disable_web_page_preview=true" --data-urlencode "text=${MSG}" --data-urlencode "chat_id=${TG_CHAT}" "$POST"
Expand Down
29 changes: 21 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,27 @@ jobs:
}
is_patches_latest() {
PATCHES_SRC=$(toml_get "$(toml_get_table "")" patches-source) || PATCHES_SRC="ReVanced/revanced-patches"
last_patches_url=$(gh_req https://api.github.com/repos/${PATCHES_SRC}/releases/latest - | json_get 'browser_download_url' | grep 'jar')
last_patches=${last_patches_url##*/}
cur_patches=$(sed -n "s/.*Patches: ${PATCHES_SRC%%/*}\/\(.*\)/\1/p" build.md | xargs)
echo "current patches version: $cur_patches"
echo "latest patches version: $last_patches"
if [ -z "$cur_patches" ] || [ -z "$last_patches" ]; then return 1; fi
[ "$cur_patches" != "$last_patches" ] # test success=>build, fail=>dont build
declare -A sources
sources["ReVanced/revanced-patches"]=1
for table_name in $(toml_get_table_names); do
if [ -z "$table_name" ]; then continue; fi
t=$(toml_get_table "$table_name")
enabled=$(toml_get "$t" enabled) || enabled=true
if [ "$enabled" = false ]; then continue; fi
PATCHES_SRC=$(toml_get "$t" patches-source)
if [ "$PATCHES_SRC" ]; then sources[$PATCHES_SRC]=1; fi
done
for PATCHES_SRC in "${!sources[@]}"; do
echo "chk: '$PATCHES_SRC'"
last_patches_url=$(gh_req "https://api.github.com/repos/${PATCHES_SRC}/releases/latest" - | json_get 'browser_download_url' | grep 'jar')
last_patches=${last_patches_url##*/}
cur_patches=$(sed -n "s/.*Patches: ${PATCHES_SRC%%/*}\/\(.*\)/\1/p" build.md | xargs)
echo "current patches version: $cur_patches"
echo "latest patches version: $last_patches"
if [ -z "$cur_patches" ] || [ -z "$last_patches" ]; then continue; fi
if [ "$cur_patches" != "$last_patches" ]; then return 0; fi
done
return 1
}
if ! git checkout update; then
Expand Down
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#### ⚠️ Do not download modules from 3rd party sources like random websites you found on Google. There are many that uses my modules and impersonates ReVanced.

# ReVanced eXtended
[![Build Modules](https://github.com/NoName-exe/revanced-extended/actions/workflows/build.yml/badge.svg)](https://github.com/NoName-exe/revanced-extended/actions/workflows/build.yml)
[![CI](https://github.com/NoName-exe/revanced-extended/actions/workflows/ci.yml/badge.svg?event=schedule)](https://github.com/NoName-exe/revanced-extended/actions/workflows/ci.yml)

Get the [latest CI release](https://github.com/NoName-exe/revanced-extended/releases/latest).
Expand Down
22 changes: 2 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ if [ "$ENABLE_MAGISK_UPDATE" = true ] && [ -z "${GITHUB_REPOSITORY:-}" ]; then
pr "You are building locally. Magisk updates will not be enabled."
ENABLE_MAGISK_UPDATE=false
fi
BUILD_MINDETACH_MODULE=$(toml_get "$main_config_t" build-mindetach-module) || BUILD_MINDETACH_MODULE=false
if [ "$BUILD_MINDETACH_MODULE" = true ] && [ ! -f "mindetach-magisk/mindetach/detach.txt" ]; then
pr "mindetach module was not found."
BUILD_MINDETACH_MODULE=false
fi
if ! PARALLEL_JOBS=$(toml_get "$main_config_t" parallel-jobs); then
if [ "$OS" = Android ]; then PARALLEL_JOBS=1; else PARALLEL_JOBS=$(nproc); fi
fi
Expand All @@ -42,7 +37,6 @@ DEF_RV_BRAND=$(toml_get "$main_config_t" rv-brand) || DEF_RV_BRAND="ReVanced"
mkdir -p $TEMP_DIR $BUILD_DIR

if ((COMPRESSION_LEVEL > 9)) || ((COMPRESSION_LEVEL < 0)); then abort "compression-level must be within 0-9"; fi
if [ "$BUILD_MINDETACH_MODULE" = true ]; then : >$PKGS_LIST; fi
if [ "$LOGGING_F" = true ]; then mkdir -p logs; fi

#check_deps
Expand Down Expand Up @@ -93,11 +87,7 @@ for table_name in $(toml_get_table_names); do
cli_src=$(toml_get "$t" cli-source) || cli_src=$DEF_CLI_SRC
cli_ver=$(toml_get "$t" cli-version) || cli_ver=$DEF_CLI_VER

if [ "${SETPRE:-}" ]; then
if ! set_prebuilts "$integrations_src" "$patches_src" "$cli_src" "$integrations_ver" "$patches_ver" "$cli_ver"; then
abort "couldnt set prebuilts"
fi
else
if ! set_prebuilts "$integrations_src" "$patches_src" "$cli_src" "$integrations_ver" "$patches_ver" "$cli_ver"; then
if ! RVP="$(get_rv_prebuilts "$integrations_src" "$patches_src" "$integrations_ver" "$patches_ver" "$cli_src" "$cli_ver")"; then
abort "could not download rv prebuilts"
fi
Expand Down Expand Up @@ -173,21 +163,13 @@ wait
rm -rf temp/tmp.*
if [ -z "$(ls -A1 ${BUILD_DIR})" ]; then abort "All builds failed."; fi

if [ "$BUILD_MINDETACH_MODULE" = true ]; then
pr "Building mindetach module"
cp -f $PKGS_LIST mindetach-magisk/mindetach/detach.txt
pushd mindetach-magisk/mindetach/
zip -qr ../../build/mindetach-"$(grep version= module.prop | cut -d= -f2)".zip .
popd
fi

if youtube_t=$(toml_get_table "YouTube"); then youtube_mode=$(toml_get "$youtube_t" "build-mode") || youtube_mode="apk"; else youtube_mode="module"; fi
if music_t=$(toml_get_table "Music"); then music_mode=$(toml_get "$music_t" "build-mode") || music_mode="apk"; else music_mode="module"; fi
if [ "$youtube_mode" != module ] || [ "$music_mode" != module ]; then
log "\nInstall [Vanced MicroG](https://github.com/inotia00/VancedMicroG/releases) or [mMicroG](https://github.com/inotia00/mMicroG/releases) to be able to use non-root YouTube or YouTube-Music"
fi
log "\n[Main Repo](https://github.com/NoName-exe/revanced-extended)"
log "\n---\nChangelog:"
log "\nChangelog:"
log "$(cat $TEMP_DIR/*-rv/changelog.md)"

pr "Done"
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parallel-jobs = 1
logging-to-file = true # enables logging of every patch process to a seperate file
enable-magisk-update = true # set this to false if you do not want to receive updates for the module in magisk app
build-mindetach-module = false
patches-source = "inotia00/revanced-patches"
integrations-source = "inotia00/revanced-integrations"
rv-brand = "ReVanced eXtended"
Expand Down
1 change: 0 additions & 1 deletion mindetach-magisk
Submodule mindetach-magisk deleted from 41adbd
7 changes: 3 additions & 4 deletions scripts/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ else
fi
set_perm_recursive $MODPATH/bin 0 0 0755 0777

su -M -c grep __PKGNAME /proc/mounts | while read -r line; do
nsenter -t1 -m -- grep __PKGNAME /proc/mounts | while read -r line; do
ui_print "- Un-mount"
mp=${line#* }
mp=${mp%% *}
su -M -c umount -l "${mp%%\\*}"
nsenter -t1 -m -- umount -l "${mp%%\\*}"
done
am force-stop __PKGNAME

Expand Down Expand Up @@ -97,7 +97,7 @@ mkdir -p $NVBASE/rvhc
RVPATH=$NVBASE/rvhc/${MODPATH##*/}.apk
mv -f $MODPATH/base.apk $RVPATH

if ! op=$(su -M -c mount -o bind $RVPATH $BASEPATH/base.apk 2>&1); then
if ! op=$(nsenter -t1 -m -- mount -o bind $RVPATH $BASEPATH/base.apk 2>&1); then
ui_print "ERROR: Mount failed!"
ui_print "$op"
fi
Expand All @@ -107,7 +107,6 @@ nohup cmd package compile --reset __PKGNAME >/dev/null 2>&1 &

ui_print "- Cleanup"
rm -rf $MODPATH/bin $MODPATH/__PKGNAME.apk
rm -rf $NVBASE/rvhc/__PKGNAME_rv.apk # rm this later

for s in "uninstall.sh" "service.sh"; do
sed -i "2 i\NVBASE=${NVBASE}" $MODPATH/$s
Expand Down
2 changes: 1 addition & 1 deletion scripts/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
MODDIR=${0%/*}
rm "$NVBASE/rvhc/${MODDIR##*/}".apk
rmdir --ignore-fail-on-non-empty "$NVBASE/rvhc"
rmdir "$NVBASE/rvhc"
# if __ISBNDL; then
# until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
# sleep 15
Expand Down
68 changes: 44 additions & 24 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
MODULE_TEMPLATE_DIR="revanced-magisk"
TEMP_DIR="temp"
BUILD_DIR="build"
PKGS_LIST="${TEMP_DIR}/module-pkgs"
# PKGS_LIST="${TEMP_DIR}/module-pkgs"

if [ "${GITHUB_TOKEN:-}" ]; then GH_HEADER="Authorization: token ${GITHUB_TOKEN}"; else GH_HEADER=; fi
NEXT_VER_CODE=${NEXT_VER_CODE:-$(date +'%Y%m%d')}
Expand Down Expand Up @@ -53,7 +53,7 @@ get_rv_prebuilts() {
mkdir -p "$patches_dir" "$integrations_dir" "$cli_dir"

pr "Getting prebuilts (${patches_src%/*})" >&2
local rv_cli_url rv_integrations_url rv_patches rv_patches_changelog rv_patches_dl rv_patches_url rv_patches_json
local rv_cli_url rv_integrations_url rv_patches rv_patches_dl rv_patches_url rv_patches_json

local rv_cli_rel="https://api.github.com/repos/${cli_src}/releases/"
if [ "$cli_ver" ]; then rv_cli_rel+="tags/${cli_ver}"; else rv_cli_rel+="latest"; fi
Expand All @@ -70,19 +70,22 @@ get_rv_prebuilts() {
echo "Integrations: $(cut -d/ -f4 <<<"$rv_integrations_url")/$(cut -d/ -f9 <<<"$rv_integrations_url") " >>"$patches_dir/changelog.md"

rv_patches=$(gh_req "$rv_patches_rel" -) || return 1
rv_patches_changelog=$(json_get 'body' <<<"$rv_patches" | sed 's/\(\\n\)\+/\\n/g')
# rv_patches_changelog=$(json_get 'body' <<<"$rv_patches" | sed 's/\(\\n\)\+/\\n/g')
rv_patches_dl=$(json_get 'browser_download_url' <<<"$rv_patches")
rv_patches_json="${patches_dir}/patches-$(json_get 'tag_name' <<<"$rv_patches").json"
rv_patches_url=$(grep 'jar' <<<"$rv_patches_dl")
local rv_patches_jar="${patches_dir}/${rv_patches_url##*/}"
[ -f "$rv_patches_jar" ] || REBUILD=true
echo "Patches: $(cut -d/ -f4 <<<"$rv_patches_url")/$(cut -d/ -f9 <<<"$rv_patches_url") " >>"$patches_dir/changelog.md"
echo -e "\n${rv_patches_changelog//# [/### [}\n---" >>"$patches_dir/changelog.md"
local nm
nm=$(cut -d/ -f9 <<<"$rv_patches_url")
echo "Patches: $(cut -d/ -f4 <<<"$rv_patches_url")/$nm " >>"$patches_dir/changelog.md"
echo -e "[Changelog](https://github.com/${patches_src}/releases/tag/v$(sed 's/.*-\(.*\)\..*/\1/' <<<$nm))\n" >>"$patches_dir/changelog.md"
# echo -e "\n${rv_patches_changelog//# [/### [}\n---" >>"$patches_dir/changelog.md"

dl_if_dne "$rv_cli_jar" "$rv_cli_url" >&2
dl_if_dne "$rv_integrations_apk" "$rv_integrations_url" >&2
dl_if_dne "$rv_patches_jar" "$rv_patches_url" >&2
dl_if_dne "$rv_patches_json" "$(grep 'json' <<<"$rv_patches_dl")" >&2
dl_if_dne "$rv_cli_jar" "$rv_cli_url" >&2 || return 1
dl_if_dne "$rv_integrations_apk" "$rv_integrations_url" >&2 || return 1
dl_if_dne "$rv_patches_jar" "$rv_patches_url" >&2 || return 1
dl_if_dne "$rv_patches_json" "$(grep 'json' <<<"$rv_patches_dl")" >&2 || return 1

echo "$rv_cli_jar" "$rv_integrations_apk" "$rv_patches_jar" "$rv_patches_json"
}
Expand Down Expand Up @@ -188,6 +191,10 @@ dl_apkmirror() {
local resp node app_table dlurl=""
if [ "$arch" = universal ]; then
apparch=(universal noarch 'arm64-v8a + armeabi-v7a')
elif [ "$arch" = "arm64-v8a" ]; then
apparch=(arm64-v8a universal)
elif [ "$arch" = "armeabi-v7a" ]; then
apparch=(armeabi-v7a universal)
else apparch=("$arch"); fi
url="${url}/${url##*/}-${version//./-}-release/"
resp=$(req "$url" -) || return 1
Expand All @@ -203,9 +210,9 @@ dl_apkmirror() {
fi
done
[ -z "$dlurl" ] && return 1
url=$(req "$dlurl" - | $HTMLQ --base https://www.apkmirror.com --attribute href "a.btn")
url=$(req "$dlurl" - | $HTMLQ --base https://www.apkmirror.com --attribute href "a.btn") || return 1
if [ "$apkorbundle" = BUNDLE ] && [[ "$url" != *"&forcebaseapk=true" ]]; then url="${url}&forcebaseapk=true"; fi
url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "span > a[rel = nofollow]")
url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "span > a[rel = nofollow]") || return 1
req "$url" "$output"
}
get_apkmirror_vers() {
Expand All @@ -231,15 +238,21 @@ get_apkmirror_pkg_name() { req "$1" - | sed -n 's;.*id=\(.*\)" class="accent_col

# -------------------- uptodown --------------------
get_uptodown_resp() { req "${1}/versions" -; }
get_uptodown_vers() { sed -n 's;.*version">\(.*\)</span>$;\1;p' <<<"$1"; }
get_uptodown_vers() { $HTMLQ --text ".version" <<<"$1"; }
dl_uptodown_last() {
local uptwod_resp=$1 output=$2
local url
url=$($HTMLQ -a data-url "#detail-download-button" <<<"$uptwod_resp") || return 1
req "$url" "$output"
}
dl_uptodown() {
local uptwod_resp=$1 version=$2 output=$3
local url
local url r
url=$(grep -F "${version}</span>" -B 2 <<<"$uptwod_resp" | head -1 | sed -n 's;.*data-url="\(.*\)".*;\1;p') || return 1
url=$(req "$url" - | sed -n 's;.*data-url="\(.*\)".*;\1;p') || return 1
req "$url" "$output"
r=$(req "$url" -) || return 1
dl_uptodown_last "$r" "$output"
}
get_uptodown_pkg_name() { req "${1}/download" - | $HTMLQ --text "tr.full:nth-child(1) > td:nth-child(3)"; }
get_uptodown_pkg_name() { $HTMLQ --text "tr.full:nth-child(1) > td:nth-child(3)" <<<"$1"; }
# --------------------------------------------------

# -------------------- apkmonk ---------------------
Expand Down Expand Up @@ -289,8 +302,9 @@ build_rv() {
if [ "$dl_from" = apkmirror ]; then
pkg_name=$(get_apkmirror_pkg_name "${args[apkmirror_dlurl]}")
elif [ "$dl_from" = uptodown ]; then
uptwod_resp_dl=$(req "${args[uptodown_dlurl]}/download" -)
uptwod_resp=$(get_uptodown_resp "${args[uptodown_dlurl]}")
pkg_name=$(get_uptodown_pkg_name "${args[uptodown_dlurl]}")
pkg_name=$(get_uptodown_pkg_name "$uptwod_resp_dl")
elif [ "$dl_from" = apkmonk ]; then
pkg_name=$(get_apkmonk_pkg_name "${args[apkmonk_dlurl]}")
apkmonk_resp=$(get_apkmonk_resp "${args[apkmonk_dlurl]}")
Expand All @@ -310,14 +324,14 @@ build_rv() {
p_patcher_args+=("-f")
fi
if [ $get_latest_ver = true ]; then
local apkmvers uptwodvers aav
if [ "$dl_from" = apkmirror ]; then
local apkmvers aav
if [ "$version_mode" = beta ]; then aav="true"; else aav="false"; fi
apkmvers=$(get_apkmirror_vers "${args[apkmirror_dlurl]##*/}" "$aav")
version=$(get_largest_ver <<<"$apkmvers") || version=$(head -1 <<<"$apkmvers")
elif [ "$dl_from" = uptodown ]; then
uptwodvers=$(get_uptodown_vers "$uptwod_resp")
version=$(get_largest_ver <<<"$uptwodvers") || version=$(head -1 <<<"$uptwodvers")
version=$(head -1 <<<"$uptwodvers")
elif [ "$dl_from" = apkmonk ]; then
apkmonkvers=$(get_apkmonk_vers "$apkmonk_resp")
version=$(get_largest_ver <<<"$apkmonkvers") || version=$(head -1 <<<"$apkmonkvers")
Expand Down Expand Up @@ -353,11 +367,18 @@ build_rv() {
break
elif [ "$dl_p" = uptodown ]; then
if [ -z "${args[uptodown_dlurl]}" ]; then continue; fi
if [ -z "${uptwod_resp:-}" ]; then uptwod_resp=$(get_uptodown_resp "${args[uptodown_dlurl]}"); fi
pr "Downloading '${table}' from Uptodown"
if ! dl_uptodown "$uptwod_resp" "$version" "$stock_apk"; then
epr "ERROR: Could not download ${table} from Uptodown"
continue
if [ $get_latest_ver = true ]; then
if ! dl_uptodown_last "$uptwod_resp_dl" "$stock_apk"; then
epr "ERROR: Could not download ${table} from Uptodown (last)"
continue
fi
else
if [ -z "${uptwod_resp:-}" ]; then uptwod_resp=$(get_uptodown_resp "${args[uptodown_dlurl]}"); fi
if ! dl_uptodown "$uptwod_resp" "$version" "$stock_apk"; then
epr "ERROR: Could not download ${table} from Uptodown"
continue
fi
fi
break
elif [ "$dl_p" = apkmonk ]; then
Expand Down Expand Up @@ -448,7 +469,6 @@ build_rv() {
local base_template
base_template=$(mktemp -d -p $TEMP_DIR)
cp -a $MODULE_TEMPLATE_DIR/. "$base_template"
if [ "$BUILD_MINDETACH_MODULE" = true ] && ! grep -q "$pkg_name" $PKGS_LIST; then echo "$pkg_name" >>$PKGS_LIST; fi
local upj="${table,,}-update.json"

local isbndl extrct stock_apk_module
Expand Down

0 comments on commit 4203d93

Please sign in to comment.