diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 697d0df..d606061 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,11 +22,11 @@ jobs: is_youtube_latest() { t=$(toml_get_table YouTube) - v=$(toml_get "$t" "version") || v= - if [ "$v" = latest ]; then + v=$(toml_get "$t" "version") || v="" + if isoneof "$v" latest beta; then cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs) [ -z "$cur_yt" ] && return 1 # empty, fail=>dont build - aav=$(toml_get "$t" "allow-alpha-version") || aav=false + if [ "$v" = beta ]; aav="true"; else aav="false"; fi last_ver=$(get_apkmirror_vers youtube "$aav" | get_largest_ver) [ -z "$last_ver" ] && return 1 # cant fetch, dont build echo "current yt version: '$cur_yt'" diff --git a/CONFIG.md b/CONFIG.md index 149b118..664401f 100755 --- a/CONFIG.md +++ b/CONFIG.md @@ -32,14 +32,16 @@ integrations-version = "v0.95.0" # locks the integrations version. default: late [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 +# '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 build-mode = "both" # 'both', 'apk' or 'module'. default: apk -allow-alpha-version = false # allow downloading alpha versions from apkmirror. default: false -excluded-patches = "some-patch" # whitespace seperated list of patches to exclude. default: "" (empty) +excluded-patches = "some-patch some-other-path" # 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) -version = "auto" # 'auto', 'latest' or a custom one e.g. '17.40.41'. 'auto' option gets the latest version that is supported by the patches. default: auto 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 dpi = "360-480dpi" # used to select apk variant from apkmirror. default: nodpi diff --git a/build.sh b/build.sh index 003f5dc..e96db88 100755 --- a/build.sh +++ b/build.sh @@ -64,7 +64,6 @@ for table_name in $(toml_get_table_names); do app_args[exclusive_patches]=$(toml_get "$t" exclusive-patches) && vtf "${app_args[exclusive_patches]}" "exclusive-patches" || app_args[exclusive_patches]=false app_args[version]=$(toml_get "$t" version) || app_args[version]="auto" app_args[app_name]=$(toml_get "$t" app-name) || app_args[app_name]=$table_name - app_args[allow_alpha_version]=$(toml_get "$t" allow-alpha-version) && vtf "${app_args[allow_alpha_version]}" "allow-alpha-version" || app_args[allow_alpha_version]=false app_args[build_mode]=$(toml_get "$t" build-mode) && { if ! isoneof "${app_args[build_mode]}" both apk module; then abort "ERROR: build-mode '${app_args[build_mode]}' is not a valid option for '${table_name}': only 'both', 'apk' or 'module' is allowed" diff --git a/config.toml b/config.toml index bb9911e..f1b8f86 100755 --- a/config.toml +++ b/config.toml @@ -10,8 +10,8 @@ build-mindetach-module = true [YouTube] enabled = true build-mode = "both" # 'both', 'apk' or 'module' -excluded-patches = "debugging" # whitespace seperated list of patches to exclude (multiline strings are not supported) -included-patches = "" # whitespace seperated list of patches to include +excluded-patches = "debugging" # space-seperated patches to exclude (multiline strings are not supported) +included-patches = "" # space-seperated patches to include (non-excluded patches are included by default) version = "auto" # 'auto', 'latest' or a custom one like '17.40.41' exclusive-patches = false # excludes all patches by default apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube/" @@ -39,7 +39,7 @@ arch = "arm-v7a" [Twitter] build-mode = "apk" -excluded-patches = "" +excluded-patches = "hide-views-stats" version = "auto" apkmirror-dlurl = "https://www.apkmirror.com/apk/twitter-inc/twitter/" diff --git a/utils.sh b/utils.sh index 70dd0ae..3a26a5a 100755 --- a/utils.sh +++ b/utils.sh @@ -17,11 +17,11 @@ UNINSTALL_SH=$(cat $MODULE_SCRIPTS_DIR/uninstall.sh) # -------------------- json/toml -------------------- json_get() { grep -o "\"${1}\":[^\"]*\"[^\"]*\"" | sed -E 's/".*".*"(.*)"/\1/'; } -toml_prep() { __TOML__=$(echo "$1" | tr -d '\t\r' | tr "'" '"' | grep -o '^[^#]*' | grep -v '^$' | sed -r 's/(\".*\")|\s*/\1/g; 1i []'); } +toml_prep() { __TOML__=$(tr -d '\t\r' <<<"$1" | tr "'" '"' | grep -o '^[^#]*' | grep -v '^$' | sed -r 's/(\".*\")|\s*/\1/g; 1i []'); } toml_get_table_names() { local tn - tn=$(echo "$__TOML__" | grep -x '\[.*\]' | tr -d '[]') || return 1 - if [ "$(echo "$tn" | sort | uniq -u | wc -l)" != "$(echo "$tn" | wc -l)" ]; then + tn=$(grep -x '\[.*\]' <<<"$__TOML__" | tr -d '[]') || return 1 + if [ "$(sort <<<"$tn" | uniq -u | wc -l)" != "$(wc -l <<<"$tn")" ]; then abort "ERROR: Duplicate tables in TOML" fi echo "$tn" @@ -29,7 +29,7 @@ toml_get_table_names() { toml_get_table() { sed -n "/\[${1}]/,/^\[.*]$/p" <<<"$__TOML__"; } toml_get() { local table=$1 key=$2 val - val=$(grep -m 1 "^${key}=" <<<"$table") && echo "${val#*=}" | sed -e "s/^\"//; s/\"$//" + val=$(grep -m 1 "^${key}=" <<<"$table") && sed -e "s/^\"//; s/\"$//" <<<"${val#*=}" } # --------------------------------------------------- @@ -63,7 +63,7 @@ get_prebuilts() { log "Integrations: ${rv_integrations_url##*/}" rv_patches=$(gh_req "$rv_patches_rel" -) - rv_patches_changelog=$(echo "$rv_patches" | json_get 'body' | 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="${PREBUILTS_DIR}/patches-$(json_get 'tag_name' <<<"$rv_patches").json" rv_patches_url=$(grep 'jar' <<<"$rv_patches_dl") @@ -147,7 +147,14 @@ semver_validate() { [ ${#ac} = 0 ] } get_patch_last_supported_ver() { - jq -r ".[] | select(.compatiblePackages[].name==\"${1}\" and .excluded==false) | .compatiblePackages[].versions" "$RV_PATCHES_JSON" | + local inc_sel exc_sel + inc_sel=$(list_args "$2" | sed 's/.*/\.name == "&"/; N;s/\n/ and /' || :) + exc_sel=$(list_args "$3" | sed 's/.*/\.name != "&"/; N;s/\n/ and /' || :) + jq -r ".[] + | select(.compatiblePackages[].name==\"${1}\" and .excluded==false) + | select(${inc_sel:-true}) + | select(${exc_sel:-true}) + | .compatiblePackages[].versions" "$RV_PATCHES_JSON" | tr -d ' ,\t[]"' | grep -v '^$' | sort | uniq -c | sort -nr | head -1 | xargs | cut -d' ' -f2 || return 1 } @@ -220,7 +227,7 @@ get_uptodown_vers() { sed -n 's;.*version">\(.*\)$;\1;p' <<<"$1"; } dl_uptodown() { local uptwod_resp=$1 version=$2 output=$3 local url - url=$(echo "$uptwod_resp" | grep "${version}<\/span>" -B 2 | head -1 | sed -n 's;.*data-url="\(.*\)".*;\1;p') || return 1 + url=$(grep "${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" } @@ -237,7 +244,7 @@ get_apkmonk_vers() { grep -oP 'download_ver.+?>\K([0-9,\.]*)' <<<"$1"; } dl_apkmonk() { local apkmonk_resp=$1 version=$2 output=$3 local url - url="https://www.apkmonk.com/down_file?pkg="$(echo "$apkmonk_resp" | grep "$version" | grep -oP 'href=\"/download-app/\K.+?(?=/?\">)' | sed 's;/;\&key=;') || return 1 + url="https://www.apkmonk.com/down_file?pkg="$(grep "$version" <<<"$apkmonk_resp" | grep -oP 'href=\"/download-app/\K.+?(?=/?\">)' | sed 's;/;\&key=;') || return 1 url=$(req "$url" - | grep -oP 'https.+?(?=\",)') req "$url" "$output" } @@ -284,8 +291,8 @@ build_rv() { local get_latest_ver=false if [ "$version_mode" = auto ]; then - version=$(get_patch_last_supported_ver "$pkg_name") || get_latest_ver=true - elif [ "$version_mode" = latest ]; then + version=$(get_patch_last_supported_ver "$pkg_name" "${args[included_patches]}" "${args[excluded_patches]}") || get_latest_ver=true + elif isoneof "$version_mode" latest beta; then get_latest_ver=true p_patcher_args+=("--experimental") else @@ -293,9 +300,10 @@ build_rv() { p_patcher_args+=("--experimental") fi if [ $get_latest_ver = true ]; then - local apkmvers uptwodvers + local apkmvers uptwodvers aav if [ "$dl_from" = apkmirror ]; then - apkmvers=$(get_apkmirror_vers "${args[apkmirror_dlurl]##*/}" "${args[allow_alpha_version]}") + 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") @@ -461,9 +469,8 @@ build_rv() { done } -join_args() { - echo "$1" | tr -d '\t\r' | tr ' ' '\n' | grep -v '^$' | sed "s/^/${2} /" | paste -sd " " - || : -} +list_args() { tr -d '\t\r' <<<"$1" | tr ' ' '\n' | grep -v '^$' || :; } +join_args() { list_args "$1" | sed "s/^/${2} /" | paste -sd " " - || :; } uninstall_sh() { local s="${UNINSTALL_SH//__PKGNAME/$1}"