diff --git a/CONFIG.md b/CONFIG.md index 678960a..e7eb70a 100755 --- a/CONFIG.md +++ b/CONFIG.md @@ -20,13 +20,13 @@ cli-source = "j-hc/revanced-cli" # where to fetch cli from. default: "j-hc/revan # options like cli-source can also set per app rv-brand = "ReVanced Extended" # rebrand from 'ReVanced' to something different. default: "ReVanced" -patches-version = "v2.160.0" # locks the patches version. default: latest available -integrations-version = "v0.95.0" # locks the integrations version. default: latest available +patches-version = "v2.160.0" # 'latest', 'dev', or a version number. default: "latest" +# integrations-version and cli-version can be also configured [Some-App] app-name = "SomeApp" # if set, release name becomes SomeApp instead of Some-App. default is same as table name, which is 'Some-App' here. enabled = true # whether to build the app. default: true -version = "auto" # 'auto', 'latest', 'beta' or a custom one e.g. '17.40.41'. default: auto +version = "auto" # 'auto', 'latest', 'beta' or a version number (e.g. '17.40.41'). default: auto # 'auto' option gets the latest possible version supported by all the included patches # 'latest' gets the latest stable without checking patches support. 'beta' gets the latest beta/alpha include-stock = true # includes stock apk in the module. default: true diff --git a/build.sh b/build.sh index e763884..70b36e2 100755 --- a/build.sh +++ b/build.sh @@ -20,9 +20,9 @@ COMPRESSION_LEVEL=$(toml_get "$main_config_t" compression-level) || COMPRESSION_ if ! PARALLEL_JOBS=$(toml_get "$main_config_t" parallel-jobs); then if [ "$OS" = Android ]; then PARALLEL_JOBS=1; else PARALLEL_JOBS=$(nproc); fi fi -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_VER=$(toml_get "$main_config_t" patches-version) || DEF_PATCHES_VER="latest" +DEF_INTEGRATIONS_VER=$(toml_get "$main_config_t" integrations-version) || DEF_INTEGRATIONS_VER="latest" +DEF_CLI_VER=$(toml_get "$main_config_t" cli-version) || DEF_CLI_VER="latest" 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" @@ -52,20 +52,6 @@ zip --version >/dev/null || abort "\`zip\` is not installed. install it with 'ap rm -rf revanced-magisk/bin/*/tmp.* get_prebuilts -set_prebuilts() { - 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%/*} - 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 -} - declare -A cliriplib idx=0 for table_name in $(toml_get_table_names); do @@ -86,16 +72,14 @@ 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 ! set_prebuilts "$integrations_src" "$patches_src" "$cli_src" "$integrations_ver" "$patches_ver" "$cli_ver"; then - if ! RVP="$(get_rv_prebuilts "$cli_src" "$cli_ver" "$integrations_src" "$integrations_ver" "$patches_src" "$patches_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 + if ! RVP="$(get_rv_prebuilts "$cli_src" "$cli_ver" "$integrations_src" "$integrations_ver" "$patches_src" "$patches_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 if [[ -v cliriplib[${app_args[cli]}] ]]; then app_args[riplib]=${cliriplib[${app_args[cli]}]}; else if [[ $(java -jar "${app_args[cli]}" patch 2>&1) == *rip-lib* ]]; then cliriplib[${app_args[cli]}]=true @@ -106,7 +90,7 @@ for table_name in $(toml_get_table_names); do fi fi if [ "${app_args[riplib]}" = "true" ] && [ "$(toml_get "$t" riplib)" = "false" ]; then app_args[riplib]=false; fi - app_args[rv_brand]=$(toml_get "$t" rv-brand) || app_args[rv_brand]="$DEF_RV_BRAND" + 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]="" if [ -n "${app_args[excluded_patches]}" ] && [[ ${app_args[excluded_patches]} != *'"'* ]]; then abort "patch names inside excluded-patches must be quoted"; fi diff --git a/utils.sh b/utils.sh index f2e83d5..0351542 100755 --- a/utils.sh +++ b/utils.sh @@ -54,27 +54,51 @@ get_rv_prebuilts() { dir=${TEMP_DIR}/${dir,,}-rv [ -d "$dir" ] || mkdir "$dir" - local rv_rel="https://api.github.com/repos/${src}/releases/" - if [ "$ver" ]; then rv_rel+="tags/${ver}"; else rv_rel+="latest"; fi + local rv_rel="https://api.github.com/repos/${src}/releases" name_ver + if [ "$ver" = "dev" ]; then + rv_rel+="/tags/$(gh_req "$rv_rel" - | jq -r '.[0] | .tag_name')" + name_ver="*-dev*" + elif [ "$ver" = "latest" ]; then + rv_rel+="/latest" + name_ver="*" + else + rv_rel+="/tags/${ver}" + name_ver="$ver" + fi - local resp asset url name file - resp=$(gh_req "$rv_rel" -) || return 1 - asset=$(jq -e -r ".assets[] | select(.name | endswith(\"$ext\"))" <<<"$resp") || return 1 - url=$(jq -r .url <<<"$asset") - name=$(jq -r .name <<<"$asset") - file="${dir}/${name}" + local url file tag_name name + file=$(find "$dir" -name "revanced-${tag,,}-${name_ver#v}.${ext}" -type f 2>/dev/null) + if [ "$ver" = "latest" ]; then + file=$(grep -v dev <<<"$file" | head -1) + else file=$(grep "$ver" <<<"$file" | head -1); fi + + if [ -z "$file" ]; then + local resp asset name + resp=$(gh_req "$rv_rel" -) || return 1 + tag_name=$(jq -r '.tag_name' <<<"$resp") + asset=$(jq -e -r ".assets[] | select(.name | endswith(\"$ext\"))" <<<"$resp") || return 1 + url=$(jq -r .url <<<"$asset") + name=$(jq -r .name <<<"$asset") + file="${dir}/${name}" + gh_dl "$file" "$url" >&2 || return 1 + else + name=$(basename "$file") + tag_name=$(cut -d'-' -f3- <<<"$name") + tag_name=v${tag_name%.*} + if [ "$tag_name" = "v" ]; then abort; fi + fi if [ "$tag" = "Integrations" ] && [ ! -f "$file" ]; then integs_file=$file; fi - echo "$tag: $(cut -d/ -f5 <<<"$url")/${name} " >>"${cl_dir}/changelog.md" - gh_dl "$file" "$url" >&2 || return 1 + echo "$tag: $(cut -d/ -f1 <<<"$src")/${name} " >>"${cl_dir}/changelog.md" echo -n "$file " if [ "$tag" = "Patches" ]; then - local tag_name - tag_name=$(jq -r '.tag_name' <<<"$resp") name="patches-${tag_name}.json" file="${dir}/${name}" - url=$(jq -e -r '.assets[] | select(.name | endswith("json")) | .url' <<<"$resp") || return 1 - gh_dl "$file" "$url" >&2 || return 1 + if [ ! -f "$file" ]; then + resp=$(gh_req "$rv_rel" -) || return 1 + url=$(jq -e -r '.assets[] | select(.name | endswith("json")) | .url' <<<"$resp") || return 1 + gh_dl "$file" "$url" >&2 || return 1 + fi echo -n "$file " echo -e "[Changelog](https://github.com/${src}/releases/tag/${tag_name})\n" >>"${cl_dir}/changelog.md" fi @@ -406,13 +430,15 @@ build_rv() { p_patcher_args+=("$(join_args "${args[excluded_patches]}" -e) $(join_args "${args[included_patches]}" -i)") [ "${args[exclusive_patches]}" = true ] && p_patcher_args+=("--exclusive") + local tried_dl=() for dl_p in archive apkmirror uptodown; do if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi - if ! get_"${dl_p}"_resp "${args[${dl_p}_dlurl]}" || ! pkg_name=$(get_"${dl_p}"_pkg_name); then + if ! get_${dl_p}_resp "${args[${dl_p}_dlurl]}" || ! pkg_name=$(get_"${dl_p}"_pkg_name); then args[${dl_p}_dlurl]="" epr "ERROR: Could not find ${table} in ${dl_p}" continue fi + tried_dl+=("$dl_p") dl_from=$dl_p break done @@ -459,6 +485,7 @@ build_rv() { for dl_p in archive apkmirror uptodown; do if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi pr "Downloading '${table}' from ${dl_p}" + if ! isoneof $dl_p "${tried_dl[@]}"; then get_${dl_p}_resp "${args[${dl_p}_dlurl]}"; fi if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$version" "$stock_apk" "$arch" "${args[dpi]}" "$get_latest_ver"; then epr "ERROR: Could not download '${table}' from ${dl_p} with version '${version}', arch '${arch}', dpi '${args[dpi]}'" continue