mirror of
https://github.com/j-hc/revanced-magisk-module.git
synced 2025-04-29 22:24:34 +02:00
switch toml parsers
This commit is contained in:
parent
828160801d
commit
9b696e8fbc
19
CONFIG.md
19
CONFIG.md
@ -13,7 +13,7 @@ There exists an example below with all defaults shown and all the keys explicitl
|
||||
**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
|
||||
parallel-jobs = 1 # amount of cores to use for parallel patching, if not set $(nproc) is used
|
||||
compression-level = 9 # module zip compression level
|
||||
remove-rv-integrations-checks = true # remove checks from the revanced integrations
|
||||
|
||||
@ -23,18 +23,29 @@ cli-source = "j-hc/revanced-cli" # where to fetch cli from. default: "j-hc/revan
|
||||
rv-brand = "ReVanced Extended" # rebrand from 'ReVanced' to something different. default: "ReVanced"
|
||||
|
||||
patches-version = "v2.160.0" # 'latest', 'dev', or a version number. default: "latest"
|
||||
cli-version = "v5.0.0" # 'latest', 'dev', or a version number. default: "latest"
|
||||
|
||||
[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
|
||||
patcher-args = "-Okey=value" # optional args to be passed to cli. can be used to set patch options
|
||||
|
||||
# optional args to be passed to cli. can be used to set patch options
|
||||
# multiline strings in the config is supported
|
||||
patcher-args = """\
|
||||
-OdarkThemeBackgroundColor=#FF0F0F0F \
|
||||
-Oanother-option=value \
|
||||
"""
|
||||
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
|
||||
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 something'" # whitespace seperated list of patches to include, all default patches are included by default. default: "" (empty)
|
||||
# whitespace seperated list of patches to exclude. default: ""
|
||||
excluded-patches = """\
|
||||
'Some Patch' \
|
||||
'Some Other Patch' \
|
||||
"""
|
||||
included-patches = "'Some Patch'" # whitespace seperated list of patches to include, all default patches are included by default. default: ""
|
||||
exclusive-patches = false # exclude all patches by default. default: false
|
||||
apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app"
|
||||
uptodown-dlurl = "https://spotify.en.uptodown.com/android"
|
||||
|
BIN
bin/toml/toml-arm
Executable file
BIN
bin/toml/toml-arm
Executable file
Binary file not shown.
BIN
bin/toml/toml-arm64
Executable file
BIN
bin/toml/toml-arm64
Executable file
Binary file not shown.
BIN
bin/toml/toml-x86_64
Executable file
BIN
bin/toml/toml-x86_64
Executable file
Binary file not shown.
10
build.sh
10
build.sh
@ -10,12 +10,13 @@ if [ "${1-}" = "clean" ]; then
|
||||
fi
|
||||
|
||||
source utils.sh
|
||||
get_prebuilts
|
||||
|
||||
vtf() { if ! isoneof "${1}" "true" "false"; then abort "ERROR: '${1}' is not a valid option for '${2}': only true or false is allowed"; fi; }
|
||||
|
||||
toml_prep "$(cat 2>/dev/null "${1:-config.toml}")" || abort "could not find config file '${1:-config.toml}'\n\tUsage: $0 <config.toml>"
|
||||
# -- Main config --
|
||||
main_config_t=$(toml_get_table "")
|
||||
toml_prep "${1:-config.toml}" || abort "could not find config file '${1:-config.toml}'\n\tUsage: $0 <config.toml>"
|
||||
main_config_t=$(toml_get_table_main)
|
||||
COMPRESSION_LEVEL=$(toml_get "$main_config_t" compression-level) || COMPRESSION_LEVEL="9"
|
||||
if ! PARALLEL_JOBS=$(toml_get "$main_config_t" parallel-jobs); then
|
||||
if [ "$OS" = Android ]; then PARALLEL_JOBS=1; else PARALLEL_JOBS=$(nproc); fi
|
||||
@ -54,14 +55,13 @@ if [ "$(echo "$TEMP_DIR"/*-rv/changelog.md)" ]; then
|
||||
: >"$TEMP_DIR"/*-rv/changelog.md || :
|
||||
fi
|
||||
|
||||
get_prebuilts
|
||||
|
||||
declare -A cliriplib
|
||||
idx=0
|
||||
for table_name in $(toml_get_table_names); do
|
||||
if [ -z "$table_name" ]; then continue; fi
|
||||
t=$(toml_get_table "$table_name")
|
||||
enabled=$(toml_get "$t" enabled) && vtf "$enabled" "enabled" || enabled=true
|
||||
enabled=$(toml_get "$t" enabled) || enabled=true
|
||||
vtf "$enabled" "enabled"
|
||||
if [ "$enabled" = false ]; then continue; fi
|
||||
if ((idx >= PARALLEL_JOBS)); then
|
||||
wait -n
|
||||
|
27
utils.sh
27
utils.sh
@ -10,19 +10,19 @@ if [ "${GITHUB_TOKEN-}" ]; then GH_HEADER="Authorization: token ${GITHUB_TOKEN}"
|
||||
NEXT_VER_CODE=${NEXT_VER_CODE:-$(date +'%Y%m%d')}
|
||||
OS=$(uname -o)
|
||||
|
||||
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=$(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"
|
||||
}
|
||||
toml_get_table() { sed -n "/\[${1}]/,/^\[.*]$/p" <<<"$__TOML__" | sed '${/^\[/d;}'; }
|
||||
toml_prep() { __TOML__=$($TOML get "$1" .); }
|
||||
toml_get_table_names() { jq -r -e 'to_entries[] | select(.value | type == "object") | .key' <<<"$__TOML__"; }
|
||||
toml_get_table_main() { jq -r -e 'to_entries | map(select(.value | type != "object")) | from_entries' <<<"$__TOML__"; }
|
||||
toml_get_table() { jq -r -e ".\"${1}\"" <<<"$__TOML__"; }
|
||||
toml_get() {
|
||||
local table=$1 key=$2 val
|
||||
val=$(grep -m 1 "^${key}=" <<<"$table") && sed -e "s/^\"//; s/\"$//" <<<"${val#*=}"
|
||||
local op
|
||||
op=$(jq -r ".\"${2}\" | values" <<<"$1")
|
||||
if [ "$op" ]; then
|
||||
op="${op#"${op%%[![:space:]]*}"}"
|
||||
op="${op%"${op##*[![:space:]]}"}"
|
||||
op=${op//"'"/'"'}
|
||||
echo "$op"
|
||||
else return 1; fi
|
||||
}
|
||||
|
||||
pr() { echo -e "\033[0;32m[+] ${1}\033[0m"; }
|
||||
@ -117,8 +117,10 @@ get_prebuilts() {
|
||||
if [ "$(uname -m)" = aarch64 ]; then arch=arm64; else arch=arm; fi
|
||||
HTMLQ="${BIN_DIR}/htmlq/htmlq-${arch}"
|
||||
AAPT2="${BIN_DIR}/aapt2/aapt2-${arch}"
|
||||
TOML="${BIN_DIR}/toml/toml-${arch}"
|
||||
else
|
||||
HTMLQ="${BIN_DIR}/htmlq/htmlq-x86_64"
|
||||
TOML="${BIN_DIR}/toml/toml-x86_64"
|
||||
fi
|
||||
mkdir -p ${MODULE_TEMPLATE_DIR}/bin/arm64 ${MODULE_TEMPLATE_DIR}/bin/arm ${MODULE_TEMPLATE_DIR}/bin/x86 ${MODULE_TEMPLATE_DIR}/bin/x64
|
||||
gh_dl "${MODULE_TEMPLATE_DIR}/bin/arm64/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-arm64-v8a"
|
||||
@ -404,7 +406,6 @@ get_archive_pkg_name() { echo "$__ARCHIVE_PKG_NAME__"; }
|
||||
|
||||
patch_apk() {
|
||||
local stock_input=$1 patched_apk=$2 patcher_args=$3 rv_cli_jar=$4 rv_patches_jar=$5
|
||||
# TODO: --options
|
||||
local cmd="java -jar $rv_cli_jar patch $stock_input --purge -o $patched_apk -p $rv_patches_jar --keystore=ks.keystore \
|
||||
--keystore-entry-password=123456789 --keystore-password=123456789 --signer=jhc --keystore-entry-alias=jhc $patcher_args"
|
||||
if [ "$OS" = Android ]; then cmd+=" --custom-aapt2-binary=${AAPT2}"; fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user