mirror of
https://github.com/j-hc/revanced-magisk-module.git
synced 2025-05-29 04:50:20 +02:00
better version selection
This commit is contained in:
parent
23b8020394
commit
e647f4f99f
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -22,11 +22,11 @@ jobs:
|
|||||||
|
|
||||||
is_youtube_latest() {
|
is_youtube_latest() {
|
||||||
t=$(toml_get_table YouTube)
|
t=$(toml_get_table YouTube)
|
||||||
v=$(toml_get "$t" "version") || v=
|
v=$(toml_get "$t" "version") || v=""
|
||||||
if [ "$v" = latest ]; then
|
if isoneof "$v" latest beta; then
|
||||||
cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs)
|
cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs)
|
||||||
[ -z "$cur_yt" ] && return 1 # empty, fail=>dont build
|
[ -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)
|
last_ver=$(get_apkmirror_vers youtube "$aav" | get_largest_ver)
|
||||||
[ -z "$last_ver" ] && return 1 # cant fetch, dont build
|
[ -z "$last_ver" ] && return 1 # cant fetch, dont build
|
||||||
echo "current yt version: '$cur_yt'"
|
echo "current yt version: '$cur_yt'"
|
||||||
|
@ -32,14 +32,16 @@ integrations-version = "v0.95.0" # locks the integrations version. default: late
|
|||||||
[Some-App]
|
[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.
|
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
|
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
|
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 some-other-path" # whitespace seperated list of patches to exclude. default: "" (empty)
|
||||||
excluded-patches = "some-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)
|
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
|
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.
|
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
|
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.
|
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
|
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
|
dpi = "360-480dpi" # used to select apk variant from apkmirror. default: nodpi
|
||||||
|
1
build.sh
1
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[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[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[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) && {
|
app_args[build_mode]=$(toml_get "$t" build-mode) && {
|
||||||
if ! isoneof "${app_args[build_mode]}" both apk module; then
|
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"
|
abort "ERROR: build-mode '${app_args[build_mode]}' is not a valid option for '${table_name}': only 'both', 'apk' or 'module' is allowed"
|
||||||
|
@ -10,8 +10,8 @@ build-mindetach-module = true
|
|||||||
[YouTube]
|
[YouTube]
|
||||||
enabled = true
|
enabled = true
|
||||||
build-mode = "both" # 'both', 'apk' or 'module'
|
build-mode = "both" # 'both', 'apk' or 'module'
|
||||||
excluded-patches = "debugging" # whitespace seperated list of patches to exclude (multiline strings are not supported)
|
excluded-patches = "debugging" # space-seperated patches to exclude (multiline strings are not supported)
|
||||||
included-patches = "" # whitespace seperated list of patches to include
|
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'
|
version = "auto" # 'auto', 'latest' or a custom one like '17.40.41'
|
||||||
exclusive-patches = false # excludes all patches by default
|
exclusive-patches = false # excludes all patches by default
|
||||||
apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube/"
|
apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube/"
|
||||||
@ -39,7 +39,7 @@ arch = "arm-v7a"
|
|||||||
|
|
||||||
[Twitter]
|
[Twitter]
|
||||||
build-mode = "apk"
|
build-mode = "apk"
|
||||||
excluded-patches = ""
|
excluded-patches = "hide-views-stats"
|
||||||
version = "auto"
|
version = "auto"
|
||||||
apkmirror-dlurl = "https://www.apkmirror.com/apk/twitter-inc/twitter/"
|
apkmirror-dlurl = "https://www.apkmirror.com/apk/twitter-inc/twitter/"
|
||||||
|
|
||||||
|
37
utils.sh
37
utils.sh
@ -17,11 +17,11 @@ UNINSTALL_SH=$(cat $MODULE_SCRIPTS_DIR/uninstall.sh)
|
|||||||
|
|
||||||
# -------------------- json/toml --------------------
|
# -------------------- json/toml --------------------
|
||||||
json_get() { grep -o "\"${1}\":[^\"]*\"[^\"]*\"" | sed -E 's/".*".*"(.*)"/\1/'; }
|
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() {
|
toml_get_table_names() {
|
||||||
local tn
|
local tn
|
||||||
tn=$(echo "$__TOML__" | grep -x '\[.*\]' | tr -d '[]') || return 1
|
tn=$(grep -x '\[.*\]' <<<"$__TOML__" | tr -d '[]') || return 1
|
||||||
if [ "$(echo "$tn" | sort | uniq -u | wc -l)" != "$(echo "$tn" | wc -l)" ]; then
|
if [ "$(sort <<<"$tn" | uniq -u | wc -l)" != "$(wc -l <<<"$tn")" ]; then
|
||||||
abort "ERROR: Duplicate tables in TOML"
|
abort "ERROR: Duplicate tables in TOML"
|
||||||
fi
|
fi
|
||||||
echo "$tn"
|
echo "$tn"
|
||||||
@ -29,7 +29,7 @@ toml_get_table_names() {
|
|||||||
toml_get_table() { sed -n "/\[${1}]/,/^\[.*]$/p" <<<"$__TOML__"; }
|
toml_get_table() { sed -n "/\[${1}]/,/^\[.*]$/p" <<<"$__TOML__"; }
|
||||||
toml_get() {
|
toml_get() {
|
||||||
local table=$1 key=$2 val
|
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##*/}"
|
log "Integrations: ${rv_integrations_url##*/}"
|
||||||
|
|
||||||
rv_patches=$(gh_req "$rv_patches_rel" -)
|
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_dl=$(json_get 'browser_download_url' <<<"$rv_patches")
|
||||||
RV_PATCHES_JSON="${PREBUILTS_DIR}/patches-$(json_get 'tag_name' <<<"$rv_patches").json"
|
RV_PATCHES_JSON="${PREBUILTS_DIR}/patches-$(json_get 'tag_name' <<<"$rv_patches").json"
|
||||||
rv_patches_url=$(grep 'jar' <<<"$rv_patches_dl")
|
rv_patches_url=$(grep 'jar' <<<"$rv_patches_dl")
|
||||||
@ -147,7 +147,14 @@ semver_validate() {
|
|||||||
[ ${#ac} = 0 ]
|
[ ${#ac} = 0 ]
|
||||||
}
|
}
|
||||||
get_patch_last_supported_ver() {
|
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
|
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">\(.*\)</span>$;\1;p' <<<"$1"; }
|
|||||||
dl_uptodown() {
|
dl_uptodown() {
|
||||||
local uptwod_resp=$1 version=$2 output=$3
|
local uptwod_resp=$1 version=$2 output=$3
|
||||||
local url
|
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
|
url=$(req "$url" - | sed -n 's;.*data-url="\(.*\)".*;\1;p') || return 1
|
||||||
req "$url" "$output"
|
req "$url" "$output"
|
||||||
}
|
}
|
||||||
@ -237,7 +244,7 @@ get_apkmonk_vers() { grep -oP 'download_ver.+?>\K([0-9,\.]*)' <<<"$1"; }
|
|||||||
dl_apkmonk() {
|
dl_apkmonk() {
|
||||||
local apkmonk_resp=$1 version=$2 output=$3
|
local apkmonk_resp=$1 version=$2 output=$3
|
||||||
local url
|
local url
|
||||||
url="https://www.apkmonk.com/down_file?pkg="$(echo "$apkmonk_resp" | grep "$version</a>" | grep -oP 'href=\"/download-app/\K.+?(?=/?\">)' | sed 's;/;\&key=;') || return 1
|
url="https://www.apkmonk.com/down_file?pkg="$(grep "$version</a>" <<<"$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.+?(?=\",)')
|
||||||
req "$url" "$output"
|
req "$url" "$output"
|
||||||
}
|
}
|
||||||
@ -284,8 +291,8 @@ build_rv() {
|
|||||||
|
|
||||||
local get_latest_ver=false
|
local get_latest_ver=false
|
||||||
if [ "$version_mode" = auto ]; then
|
if [ "$version_mode" = auto ]; then
|
||||||
version=$(get_patch_last_supported_ver "$pkg_name") || get_latest_ver=true
|
version=$(get_patch_last_supported_ver "$pkg_name" "${args[included_patches]}" "${args[excluded_patches]}") || get_latest_ver=true
|
||||||
elif [ "$version_mode" = latest ]; then
|
elif isoneof "$version_mode" latest beta; then
|
||||||
get_latest_ver=true
|
get_latest_ver=true
|
||||||
p_patcher_args+=("--experimental")
|
p_patcher_args+=("--experimental")
|
||||||
else
|
else
|
||||||
@ -293,9 +300,10 @@ build_rv() {
|
|||||||
p_patcher_args+=("--experimental")
|
p_patcher_args+=("--experimental")
|
||||||
fi
|
fi
|
||||||
if [ $get_latest_ver = true ]; then
|
if [ $get_latest_ver = true ]; then
|
||||||
local apkmvers uptwodvers
|
local apkmvers uptwodvers aav
|
||||||
if [ "$dl_from" = apkmirror ]; then
|
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")
|
version=$(get_largest_ver <<<"$apkmvers") || version=$(head -1 <<<"$apkmvers")
|
||||||
elif [ "$dl_from" = uptodown ]; then
|
elif [ "$dl_from" = uptodown ]; then
|
||||||
uptwodvers=$(get_uptodown_vers "$uptwod_resp")
|
uptwodvers=$(get_uptodown_vers "$uptwod_resp")
|
||||||
@ -461,9 +469,8 @@ build_rv() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
join_args() {
|
list_args() { tr -d '\t\r' <<<"$1" | tr ' ' '\n' | grep -v '^$' || :; }
|
||||||
echo "$1" | tr -d '\t\r' | tr ' ' '\n' | grep -v '^$' | sed "s/^/${2} /" | paste -sd " " - || :
|
join_args() { list_args "$1" | sed "s/^/${2} /" | paste -sd " " - || :; }
|
||||||
}
|
|
||||||
|
|
||||||
uninstall_sh() {
|
uninstall_sh() {
|
||||||
local s="${UNINSTALL_SH//__PKGNAME/$1}"
|
local s="${UNINSTALL_SH//__PKGNAME/$1}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user