diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4e95b7..ce8cdd4 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,9 +44,9 @@ jobs: 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 } diff --git a/CONFIG.md b/CONFIG.md index 9428db8..0aed294 100755 --- a/CONFIG.md +++ b/CONFIG.md @@ -1,27 +1,20 @@ # Config -Three APK download websites are supported and adding a new app is as easy as this: +Adding another revanced app is as easy as this: ```toml [Some-App] apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" -``` -or: -```toml -[Some-App] -uptodown-dlurl = "https://app.en.uptodown.com/android" -``` -or: -```toml -[Some-App] -apkmonk-dlurl = "https://www.apkmonk.com/app/com.app.app/" +# or uptodown-dlurl = "https://app.en.uptodown.com/android" +# or apkmonk-dlurl = "https://www.apkmonk.com/app/com.app.app/" ``` -## If you'd like to get to know more about other options: +## More about other options: There exists an example below with all defaults shown and all the keys explicitly set. **All keys are optional** (except download urls) and are assigned to their default values if not set explicitly. ```toml +parallel-jobs = 1 # amount of cores to use for parallel patching, if not set nproc is used patches-source = "revanced/revanced-patches" # where to fetch patches bundle from. default: "revanced/revanced-patches" integrations-source = "revanced/revanced-integrations" # where to fetch integrations from. default: "revanced/revanced-integrations" rv-brand = "ReVanced Extended" # rebrand from 'ReVanced' to something different. default: "ReVanced" @@ -35,18 +28,18 @@ 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 # '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 -build-mode = "both" # 'both', 'apk' or 'module'. default: apk -excluded-patches = "some-patch some-other-path" # whitespace seperated list of patches to exclude. default: "" (empty) +include-stock = true # includes stock apk in the module. default: true +build-mode = "apk" # 'both', 'apk' or 'module'. default: apk +excluded-patches = "some-patch some-other-patch" # whitespace seperated list of patches to exclude. default: "" (empty) included-patches = "patch-name" # whitespace seperated list of patches to include, all default patches are included by default. default: "" (empty) exclusive-patches = false # exclude all patches by default. default: false -apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" # download url. if not set, uptodown dl url is used. -uptodown-dlurl = "https://spotify.en.uptodown.com/android" # uptodown url. if not set, apkmirror dl url is used. apkmirror is prioritized -apkmonk-dlurl = "https://www.apkmonk.com/app/com.app.app/" # apkmonk url. -module-prop-name = "some-app-magisk" # magisk module prop name. not required. -merge-integrations = false # set false to never merge even when needed default: true +apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" +uptodown-dlurl = "https://spotify.en.uptodown.com/android" +apkmonk-dlurl = "https://www.apkmonk.com/app/com.app.app/" +module-prop-name = "some-app-magisk" # magisk module prop name. +merge-integrations = false # set false to never merge even when needed. default: true dpi = "360-480dpi" # used to select apk variant from apkmirror. default: nodpi -arch = "arm64-v8a" # 'arm64-v8a', 'arm-v7a' or 'all'. default: all -# arch option is sometimes needed to be able to download the apks from apkmirror. +arch = "arm64-v8a" # 'arm64-v8a', 'arm-v7a', 'universal', 'both'. default: universal +# arch option is only for downloading from apkmirror. both downloads both arm64-v8a and arm-v7a. # and does not affect anything else ``` diff --git a/build.sh b/build.sh index 19f87f5..c99d4a2 100755 --- a/build.sh +++ b/build.sh @@ -51,11 +51,20 @@ zip --version >/dev/null || abort "\`zip\` is not installed. install it with 'ap get_prebuilts set_prebuilts() { - local -n aa=$1 - aa[cli]=$(find "$2" -name "revanced-cli*.jar" -type f -print -quit 2>/dev/null) && [ "${aa[cli]}" ] || return 1 - aa[integ]=$(find "$2" -name "revanced-integrations-*.apk" -type f -print -quit) && [ "${aa[integ]}" ] || return 1 - aa[ptjar]=$(find "$2" -name "revanced-patches-*.jar" -type f -print -quit) && [ "${aa[ptjar]}" ] || return 1 - aa[ptjs]=$(find "$2" -name "patches-*.json" -type f -print -quit) && [ "${aa[ptjs]}" ] || return 1 + app_args[cli]=$(find "$1" -name "revanced-cli*.jar" -type f -print -quit 2>/dev/null) && [ "${app_args[cli]}" ] || return 1 + app_args[integ]=$(find "$1" -name "revanced-integrations-*.apk" -type f -print -quit) && [ "${app_args[integ]}" ] || return 1 + app_args[ptjar]=$(find "$1" -name "revanced-patches-*.jar" -type f -print -quit) && [ "${app_args[ptjar]}" ] || return 1 + app_args[ptjs]=$(find "$1" -name "patches-*.json" -type f -print -quit) && [ "${app_args[ptjs]}" ] || return 1 +} + +build_rv_w() { + if [ "$LOGGING_F" = true ]; then + logf=logs/"${table_name,,}.log" + : >"$logf" + build_rv 2>&1 "$(declare -p app_args)" | tee "$logf" + else + build_rv "$(declare -p app_args)" + fi } idx=0 @@ -71,16 +80,12 @@ for table_name in $(toml_get_table_names); do integrations_src=$(toml_get "$t" integrations-source) || integrations_src=$DEF_INTEGRATIONS_SRC prebuilts_dir=${patches_src%/*} prebuilts_dir=${TEMP_DIR}/${prebuilts_dir//[^[:alnum:]]/}-rv - if ! set_prebuilts app_args "$prebuilts_dir"; then + if ! set_prebuilts "$prebuilts_dir"; then mkdir -p "$BUILD_DIR" "$prebuilts_dir" get_rv_prebuilts "$integrations_src" "$patches_src" "$prebuilts_dir" - set_prebuilts app_args "$prebuilts_dir" + set_prebuilts "$prebuilts_dir" fi - app_args[cli]=$(find "$prebuilts_dir" -name "revanced-cli*.jar" -type f -print -quit) - app_args[integ]=$(find "$prebuilts_dir" -name "revanced-integrations-*.apk" -type f -print -quit) - app_args[ptjar]=$(find "$prebuilts_dir" -name "revanced-patches-*.jar" -type f -print -quit) - app_args[ptjs]=$(find "$prebuilts_dir" -name "patches-*.json" -type f -print -quit) - 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]="" app_args[included_patches]=$(toml_get "$t" included-patches) || app_args[included_patches]="" @@ -109,22 +114,28 @@ for table_name in $(toml_get_table_names); do } || app_args[apkmirror_dlurl]="" if [ -z "${app_args[dl_from]:-}" ]; then abort "ERROR: no 'apkmirror_dlurl', 'uptodown_dlurl' or 'apkmonk_dlurl' option was set for '$table_name'."; fi app_args[arch]=$(toml_get "$t" arch) && { - if ! isoneof "${app_args[arch]}" all arm64-v8a arm-v7a; then - abort "ERROR: arch '${app_args[arch]}' is not a valid option for '${table_name}': only 'all', 'arm64-v8a', 'arm-v7a' is allowed" + if ! isoneof "${app_args[arch]}" universal both arm64-v8a arm-v7a; then + abort "ERROR: arch '${app_args[arch]}' is not a valid option for '${table_name}': only 'universal', 'arm64-v8a', 'arm-v7a', 'both' is allowed" fi - } || app_args[arch]="all" + } || app_args[arch]="universal" app_args[include_stock]=$(toml_get "$t" include-stock) || app_args[include_stock]=true && vtf "${app_args[include_stock]}" "include-stock" app_args[merge_integrations]=$(toml_get "$t" merge-integrations) || app_args[merge_integrations]=true && vtf "${app_args[merge_integrations]}" "merge-integrations" app_args[dpi]=$(toml_get "$t" dpi) || app_args[dpi]="nodpi" table_name_f=${table_name,,} table_name_f=${table_name_f// /-} app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || app_args[module_prop_name]="${table_name_f}-jhc" - if [ "$LOGGING_F" = true ]; then - logf=logs/"${table_name,,}.log" - : >"$logf" - { build_rv 2>&1 app_args | tee "$logf"; } & + + if [ "${app_args[arch]}" = both ]; then + app_args[table]="$table_name (arm64-v8a)" + app_args[module_prop_name]="${app_args[module_prop_name]}-arm64" + app_args[arch]="arm64-v8a" + build_rv_w + app_args[table]="$table_name (arm-v7a)" + app_args[module_prop_name]="${app_args[module_prop_name]}-arm" + app_args[arch]="arm-v7a" + build_rv_w & else - build_rv app_args & + build_rv_w & fi done wait diff --git a/utils.sh b/utils.sh index 20509c7..000c676 100755 --- a/utils.sh +++ b/utils.sh @@ -50,7 +50,7 @@ get_rv_prebuilts() { rv_cli_url=$(gh_req "https://api.github.com/repos/j-hc/revanced-cli/releases/latest" - | json_get 'browser_download_url') || return 1 local rv_cli_jar="${prebuilts_dir}/${rv_cli_url##*/}" - log "CLI: $(cut -d/ -f4 <<<"$rv_cli_url")/$(cut -d/ -f9 <<<"$rv_cli_url")" "$prebuilts_dir/changelog.md" + echo "CLI: $(cut -d/ -f4 <<<"$rv_cli_url")/$(cut -d/ -f9 <<<"$rv_cli_url") " >"$prebuilts_dir/changelog.md" local rv_integrations_rel="https://api.github.com/repos/${integrations_src}/releases/" if [ "$CONF_INTEGRATIONS_VER" ]; then rv_integrations_rel+="tags/${CONF_INTEGRATIONS_VER}"; else rv_integrations_rel+="latest"; fi @@ -59,7 +59,7 @@ get_rv_prebuilts() { rv_integrations_url=$(gh_req "$rv_integrations_rel" - | json_get 'browser_download_url') local rv_integrations_apk="${prebuilts_dir}/${rv_integrations_url##*/}" - log "Integrations: $(cut -d/ -f4 <<<"$rv_integrations_url")/$(cut -d/ -f9 <<<"$rv_integrations_url")" "$prebuilts_dir/changelog.md" + echo "Integrations: $(cut -d/ -f4 <<<"$rv_integrations_url")/$(cut -d/ -f9 <<<"$rv_integrations_url") " >"$prebuilts_dir/changelog.md" rv_patches=$(gh_req "$rv_patches_rel" -) rv_patches_changelog=$(json_get 'body' <<<"$rv_patches" | sed 's/\(\\n\)\+/\\n/g') @@ -68,8 +68,8 @@ get_rv_prebuilts() { rv_patches_url=$(grep 'jar' <<<"$rv_patches_dl") local rv_patches_jar="${prebuilts_dir}/${rv_patches_url##*/}" [ -f "$rv_patches_jar" ] || REBUILD=true - log "Patches: $(cut -d/ -f4 <<<"$rv_patches_url")/$(cut -d/ -f9 <<<"$rv_patches_url")" "$prebuilts_dir/changelog.md" - log "\n${rv_patches_changelog//# [/### [}\n---\n" "$prebuilts_dir/changelog.md" + echo "Patches: $(cut -d/ -f4 <<<"$rv_patches_url")/$(cut -d/ -f9 <<<"$rv_patches_url") " >"$prebuilts_dir/changelog.md" + echo -e "\n${rv_patches_changelog//# [/### [}\n---" >"$prebuilts_dir/changelog.md" dl_if_dne "$rv_cli_jar" "$rv_cli_url" dl_if_dne "$rv_integrations_apk" "$rv_integrations_url" @@ -115,7 +115,7 @@ _req() { req() { _req "$1" "$2" "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0"; } gh_req() { _req "$1" "$2" "$GH_HEADER"; } -log() { echo -e "$1 " >>"${2:-build.md}"; } +log() { echo -e "$1 " >>"build.md"; } get_largest_ver() { local vers m vers=$(tee) @@ -228,7 +228,7 @@ dl_apkmonk() { local apkmonk_resp=$1 version=$2 output=$3 local url url="https://www.apkmonk.com/down_file?pkg="$(grep -F "$version" <<<"$apkmonk_resp" | grep -oP 'href=\"/download-app/\K.+?(?=/?\">)' | sed 's;/;\&key=;') || return 1 - url=$(req "$url" - | grep -oP 'https.+?(?=\",)') + url=$(req "$url" - | grep -oP 'https.+?(?=\",)') || return 1 req "$url" "$output" } get_apkmonk_pkg_name() { grep -oP '.*apkmonk\.com\/app\/\K([,\w,\.]*)' <<<"$1"; } @@ -249,7 +249,7 @@ patch_apk() { } build_rv() { - local -n args=$1 + eval "declare -A args=${1#*=}" local version build_mode_arr pkg_name uptwod_resp local mode_arg=${args[build_mode]} version_mode=${args[version]} local app_name=${args[app_name]} @@ -258,6 +258,8 @@ 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 + local p_patcher_args=() p_patcher_args+=("$(join_args "${args[excluded_patches]}" -e) $(join_args "${args[included_patches]}" -i)") [ "${args[exclusive_patches]}" = true ] && p_patcher_args+=("--exclusive") @@ -303,20 +305,22 @@ build_rv() { epr "empty version, not building ${table}." return 0 fi - pr "Choosing version '${version}' (${table})" + pr "Choosing version '${version}' for ${table}" local version_f=${version// /} - local stock_apk="${TEMP_DIR}/${pkg_name}-${version_f}-${arch}.apk" + local stock_apk="${TEMP_DIR}/${pkg_name}-${version_f}-${arch_f}.apk" if [ ! -f "$stock_apk" ]; then for dl_p in apkmirror uptodown apkmonk; do if [ "$dl_p" = apkmirror ]; then if [ -z "${args[apkmirror_dlurl]}" ]; then continue; fi pr "Downloading '${table}' from APKMirror" local apkm_arch - if [ "$arch" = "all" ]; then + if [ "$arch" = "universal" ]; then apkm_arch="universal" elif [ "$arch" = "arm64-v8a" ]; then apkm_arch="arm64-v8a" - elif [ "$arch" = "arm-v7a" ]; then apkm_arch="armeabi-v7a"; fi + elif [ "$arch" = "arm-v7a" ]; then + apkm_arch="armeabi-v7a" + fi if ! dl_apkmirror "${args[apkmirror_dlurl]}" "$version" "$stock_apk" APK "$apkm_arch" "${args[dpi]}"; then epr "ERROR: Could not find any release of '${table}' with version '${version}', arch '${apkm_arch}' and dpi '${args[dpi]}' from APKMirror" continue @@ -356,13 +360,13 @@ build_rv() { p_patcher_args=("${p_patcher_args[@]//-[ei] ${microg_patch}/}") fi - local stock_bundle_apk="${TEMP_DIR}/${pkg_name}-${version_f}-${arch}-bundle.apk" + local stock_bundle_apk="${TEMP_DIR}/${pkg_name}-${version_f}-${arch_f}-bundle.apk" local is_bundle=false if [ "$mode_arg" = module ] || [ "$mode_arg" = both ]; then if [ -f "$stock_bundle_apk" ]; then is_bundle=true elif [ "$dl_from" = apkmirror ]; then - pr "Downloading '${app_name}' bundle from APKMirror" + pr "Downloading '${table}' bundle from APKMirror" if dl_apkmirror "${args[apkmirror_dlurl]}" "$version" "$stock_bundle_apk" BUNDLE "" ""; then if (($(stat -c%s "$stock_apk") - $(stat -c%s "$stock_bundle_apk") > 10000000)); then pr "'${table}' bundle was downloaded successfully and will be used for the module" @@ -390,14 +394,14 @@ build_rv() { patcher_args=("${p_patcher_args[@]}") pr "Building '${table}' in '$build_mode' mode" if [ "$microg_patch" ]; then - patched_apk="${TEMP_DIR}/${app_name_l}-${rv_brand_f}-${version_f}-${arch}-${build_mode}.apk" + patched_apk="${TEMP_DIR}/${app_name_l}-${rv_brand_f}-${version_f}-${arch_f}-${build_mode}.apk" if [ "$build_mode" = apk ]; then patcher_args+=("-i ${microg_patch}") elif [ "$build_mode" = module ]; then patcher_args+=("-e ${microg_patch}") fi else - patched_apk="${TEMP_DIR}/${app_name_l}-${rv_brand_f}-${version_f}-${arch}.apk" + patched_apk="${TEMP_DIR}/${app_name_l}-${rv_brand_f}-${version_f}-${arch_f}.apk" fi if [ "$build_mode" = module ]; then if [ $is_bundle = false ] || [ "${args[include_stock]}" = false ]; then @@ -413,7 +417,7 @@ build_rv() { fi fi if [ "$build_mode" = apk ]; then - local apk_output="${BUILD_DIR}/${app_name_l}-${rv_brand_f}-v${version_f}-${arch}.apk" + local apk_output="${BUILD_DIR}/${app_name_l}-${rv_brand_f}-v${version_f}-${arch_f}.apk" cp -f "$patched_apk" "$apk_output" pr "Built ${table} (non-root): '${apk_output}'" continue @@ -446,9 +450,9 @@ build_rv() { "https://raw.githubusercontent.com/${GITHUB_REPOSITORY:-}/update/${upj}" \ "$base_template" - local module_output="${app_name_l}-${rv_brand_f}-magisk-v${version}-${arch}.zip" + local module_output="${app_name_l}-${rv_brand_f}-magisk-v${version}-${arch_f}.zip" if [ ! -f "$module_output" ] || [ "$REBUILD" = true ]; then - pr "Packing module $table" + pr "Packing module ${table}" cp -f "$patched_apk" "${base_template}/base.apk" if [ "${args[include_stock]}" = true ]; then cp -f "$stock_apk_module" "${base_template}/${pkg_name}.apk"; fi pushd >/dev/null "$base_template" || abort "Module template dir not found"