Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NoName-exe authored Aug 30, 2023
2 parents 74ba7b2 + 170ef4d commit 8912f08
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
28 changes: 17 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fi
LOGGING_F=$(toml_get "$main_config_t" logging-to-file) && vtf "$LOGGING_F" "logging-to-file" || LOGGING_F=false
DEF_PATCHES_VER=$(toml_get "$main_config_t" patches-version) || DEF_PATCHES_VER=""
DEF_INTEGRATIONS_VER=$(toml_get "$main_config_t" integrations-version) || DEF_INTEGRATIONS_VER=""
DEF_CLI_VER=$(toml_get "$main_config_t" cli-version) || DEF_CLI_VER=""
DEF_PATCHES_SRC=$(toml_get "$main_config_t" patches-source) || DEF_PATCHES_SRC="ReVanced/revanced-patches"
DEF_INTEGRATIONS_SRC=$(toml_get "$main_config_t" integrations-source) || DEF_INTEGRATIONS_SRC="ReVanced/revanced-integrations"
DEF_CLI_SRC=$(toml_get "$main_config_t" cli-source) || DEF_CLI_SRC="j-hc/revanced-cli"
Expand All @@ -52,15 +53,17 @@ zip --version >/dev/null || abort "\`zip\` is not installed. install it with 'ap
get_prebuilts

set_prebuilts() {
local integrations_src=$1 patches_src=$2 integrations_ver=$3 patches_ver=$4
local integrations_src=$1 patches_src=$2 cli_src=$3 integrations_ver=$4 patches_ver=$5 cli_ver=$6
local patches_dir=${patches_src%/*}
local integrations_dir=${integrations_src%/*}
local cli_dir=${cli_src%/*}

app_args[cli]=$(find "${TEMP_DIR}/${cli_dir//[^[:alnum:]]/}-rv" -name "revanced-cli-*.jar" -type f -print -quit 2>/dev/null) && [ "${app_args[cli]}" ] || return 1
app_args[integ]=$(find "${TEMP_DIR}/${integrations_dir//[^[:alnum:]]/}-rv" -name "revanced-integrations-${integrations_ver:-*}.apk" -type f -print -quit 2>/dev/null) && [ "${app_args[integ]}" ] || return 1
app_args[ptjar]=$(find "${TEMP_DIR}/${patches_dir//[^[:alnum:]]/}-rv" -name "revanced-patches-${patches_ver:-*}.jar" -type f -print -quit 2>/dev/null) && [ "${app_args[ptjar]}" ] || return 1
app_args[ptjs]=$(find "${TEMP_DIR}/${patches_dir//[^[:alnum:]]/}-rv" -name "patches-${patches_ver:-*}.json" -type f -print -quit 2>/dev/null) && [ "${app_args[ptjs]}" ] || return 1
cli_ver=${cli_ver#v}
integrations_ver="${integrations_ver#v}"
patches_ver="${patches_ver#v}"
app_args[cli]=$(find "${TEMP_DIR}/${cli_dir,,}-rv" -name "revanced-cli-${cli_ver:-*}-all.jar" -type f -print -quit 2>/dev/null) && [ "${app_args[cli]}" ] || return 1
app_args[integ]=$(find "${TEMP_DIR}/${integrations_dir,,}-rv" -name "revanced-integrations-${integrations_ver:-*}.apk" -type f -print -quit 2>/dev/null) && [ "${app_args[integ]}" ] || return 1
app_args[ptjar]=$(find "${TEMP_DIR}/${patches_dir,,}-rv" -name "revanced-patches-${patches_ver:-*}.jar" -type f -print -quit 2>/dev/null) && [ "${app_args[ptjar]}" ] || return 1
app_args[ptjs]=$(find "${TEMP_DIR}/${patches_dir,,}-rv" -name "patches-${patches_ver:-*}.json" -type f -print -quit 2>/dev/null) && [ "${app_args[ptjs]}" ] || return 1
}

build_rv_w() {
Expand All @@ -86,15 +89,18 @@ for table_name in $(toml_get_table_names); do
integrations_src=$(toml_get "$t" integrations-source) || integrations_src=$DEF_INTEGRATIONS_SRC
integrations_ver=$(toml_get "$t" integrations-version) || integrations_ver=$DEF_INTEGRATIONS_VER
cli_src=$(toml_get "$t" cli-source) || cli_src=$DEF_CLI_SRC
if ! set_prebuilts "$integrations_src" "$patches_src" "$integrations_ver" "$patches_ver"; then
read -r rv_cli_jar rv_integrations_apk rv_patches_jar rv_patches_json \
<<<"$(get_rv_prebuilts "$integrations_src" "$patches_src" "$integrations_ver" "$patches_ver" "$cli_src")"
cli_ver=$(toml_get "$t" cli-version) || cli_ver=$DEF_CLI_VER
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
read -r rv_cli_jar rv_integrations_apk rv_patches_jar rv_patches_json <<<"$RVP"
app_args[cli]=$rv_cli_jar
app_args[integ]=$rv_integrations_apk
app_args[ptjar]=$rv_patches_jar
app_args[ptjs]=$rv_patches_json
fi
if [[ $(java -jar "${app_args[cli]}" --help) == *rip-lib* ]]; then app_args[riplib]=true; else app_args[riplib]=false; fi
if [[ $(java -jar "${app_args[cli]}" patch 2>&1) == *rip-lib* ]]; then app_args[riplib]=true; else app_args[riplib]=false; fi
app_args[rv_brand]=$(toml_get "$t" rv-brand) || app_args[rv_brand]="$DEF_RV_BRAND"

app_args[excluded_patches]=$(toml_get "$t" excluded-patches) || app_args[excluded_patches]=""
Expand Down Expand Up @@ -165,7 +171,7 @@ 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 "---\nChangelog:"
log "\n---\nChangelog:"
log "$(cat $TEMP_DIR/*-rv/changelog.md)"

pr "Done"
1 change: 0 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ enable-magisk-update = true # set this to false if you do not want to receive
build-mindetach-module = false
patches-source = "YT-Advanced/ReX-patches"
integrations-source = "YT-Advanced/ReX-integrations"
cli-source = "inotia00/revanced-cli"
rv-brand = "ReVanced eXtended"

# add 'enabled = false' for not patching a specific app or remove it from the config
Expand Down
31 changes: 16 additions & 15 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,33 @@ abort() {
}

get_rv_prebuilts() {
local integrations_src=$1 patches_src=$2 integrations_ver=$3 patches_ver=$4 cli_src=$5
local integrations_src=$1 patches_src=$2 integrations_ver=$3 patches_ver=$4 cli_src=$5 cli_ver=$6
local patches_dir=${patches_src%/*}
patches_dir=${TEMP_DIR}/${patches_dir//[^[:alnum:]]/}-rv
patches_dir=${TEMP_DIR}/${patches_dir,,}-rv
local integrations_dir=${integrations_src%/*}
integrations_dir=${TEMP_DIR}/${integrations_dir//[^[:alnum:]]/}-rv
integrations_dir=${TEMP_DIR}/${integrations_dir,,}-rv
local cli_dir=${cli_src%/*}
cli_dir=${TEMP_DIR}/${cli_dir//[^[:alnum:]]/}-rv
cli_dir=${TEMP_DIR}/${cli_dir,,}-rv
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

rv_cli_url=$(gh_req "https://api.github.com/repos/${cli_src}/releases/latest" - | json_get 'browser_download_url') || return 1
local rv_cli_jar="${cli_dir}/${rv_cli_url##*/}"
echo "CLI: $(cut -d/ -f4 <<<"$rv_cli_url")/$(cut -d/ -f9 <<<"$rv_cli_url") " >"$patches_dir/changelog.md"

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
local rv_integrations_rel="https://api.github.com/repos/${integrations_src}/releases/"
if [ "$integrations_ver" ]; then rv_integrations_rel+="tags/${integrations_ver}"; else rv_integrations_rel+="latest"; fi
local rv_patches_rel="https://api.github.com/repos/${patches_src}/releases/"
if [ "$patches_ver" ]; then rv_patches_rel+="tags/${patches_ver}"; else rv_patches_rel+="latest"; fi
rv_cli_url=$(gh_req "$rv_cli_rel" - | json_get 'browser_download_url') || return 1
local rv_cli_jar="${cli_dir}/${rv_cli_url##*/}"
echo "CLI: $(cut -d/ -f4 <<<"$rv_cli_url")/$(cut -d/ -f9 <<<"$rv_cli_url") " >"$patches_dir/changelog.md"

rv_integrations_url=$(gh_req "$rv_integrations_rel" - | json_get 'browser_download_url')
rv_integrations_url=$(gh_req "$rv_integrations_rel" - | json_get 'browser_download_url') || return 1
local rv_integrations_apk="${integrations_dir}/${rv_integrations_url##*/}"
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" -)
rv_patches=$(gh_req "$rv_patches_rel" -) || return 1
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"
Expand Down Expand Up @@ -257,7 +258,7 @@ get_apkmonk_pkg_name() { grep -oP '.*apkmonk\.com\/app\/\K([,\w,\.]*)' <<<"$1";
patch_apk() {
local stock_input=$1 patched_apk=$2 patcher_args=$3 rv_cli_jar=$4 rv_patches_jar=$5 riplib=$6
declare -r tdir=$(mktemp -d -p $TEMP_DIR)
local cmd="java -jar $rv_cli_jar --temp-dir=$tdir -c -a $stock_input -o $patched_apk -b $rv_patches_jar --keystore=ks.keystore $patcher_args"
local cmd="java -jar $rv_cli_jar patch $stock_input -r $tdir -p -o $patched_apk -b $rv_patches_jar --keystore=ks.keystore $patcher_args"
if [ "$riplib" = true ]; then cmd+=" --rip-lib x86_64 --rip-lib x86"; fi
if [ "$OS" = Android ]; then cmd+=" --custom-aapt2-binary=${TEMP_DIR}/aapt2"; fi
pr "$cmd"
Expand All @@ -279,7 +280,7 @@ build_rv() {
local table=${args[table]}
local dl_from=${args[dl_from]}
local arch=${args[arch]}
if [ "$arch" = 'universal' ]; then local arch_f="all"; else local arch_f="$arch"; fi
if [ "$arch" = 'universal' ]; then local arch_f="all"; else local arch_f="${arch// /}"; fi

local p_patcher_args=()
p_patcher_args+=("$(join_args "${args[excluded_patches]}" -e) $(join_args "${args[included_patches]}" -i)")
Expand All @@ -303,10 +304,10 @@ build_rv() {
) || get_latest_ver=true
elif isoneof "$version_mode" latest beta; then
get_latest_ver=true
p_patcher_args+=("--experimental")
p_patcher_args+=("-f")
else
version=$version_mode
p_patcher_args+=("--experimental")
p_patcher_args+=("-f")
fi
if [ $get_latest_ver = true ]; then
local apkmvers uptwodvers aav
Expand Down Expand Up @@ -427,7 +428,7 @@ build_rv() {
patched_apk="${TEMP_DIR}/${app_name_l}-${rv_brand_f}-${version_f}-${arch_f}.apk"
fi
if [ "$build_mode" = module ]; then
patcher_args+=("--unsigned")
if [ "${args[riplib]}" = true ]; then patcher_args+=("--unsigned"); fi
if [ "${args[riplib]}" = true ] && { [ $is_bundle = false ] || [ "${args[include_stock]}" = false ]; }; then
patcher_args+=("--rip-lib arm64-v8a --rip-lib armeabi-v7a")
fi
Expand Down

0 comments on commit 8912f08

Please sign in to comment.