add option include-stock

This commit is contained in:
j-hc 2023-04-27 17:29:55 +03:00
parent 4f3aa1f628
commit d2d838d1c3
No known key found for this signature in database
GPG Key ID: FCBF5E9C57092AD9
7 changed files with 38 additions and 17 deletions

View File

@ -35,6 +35,7 @@ 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)
included-patches = "patch-name" # whitespace seperated list of patches to include, all default patches are included by default. default: "" (empty)

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
trap "rm -rf temp/tmp.*; exit 1" INT
trap "rm -rf temp/tmp.*; exit 130" INT
if [ "${1:-}" = "clean" ]; then
rm -rf temp build logs
@ -18,17 +18,16 @@ vtf() {
fi
}
toml_prep "$(cat 2>/dev/null "${1:-config.toml}")" || abort "could not find config file '${1}'"
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 "")
COMPRESSION_LEVEL=$(toml_get "$main_config_t" compression-level) || abort "ERROR: compression-level is missing"
ENABLE_MAGISK_UPDATE=$(toml_get "$main_config_t" enable-magisk-update) || abort "ERROR: enable-magisk-update is missing"
COMPRESSION_LEVEL=$(toml_get "$main_config_t" compression-level) || COMPRESSION_LEVEL="9"
ENABLE_MAGISK_UPDATE=$(toml_get "$main_config_t" enable-magisk-update) || ENABLE_MAGISK_UPDATE=true
if [ "$ENABLE_MAGISK_UPDATE" = true ] && [ -z "${GITHUB_REPOSITORY:-}" ]; then
pr "You are building locally. Magisk updates will not be enabled."
ENABLE_MAGISK_UPDATE=false
fi
BUILD_MINDETACH_MODULE=$(toml_get "$main_config_t" build-mindetach-module) || abort "ERROR: build-mindetach-module is missing"
BUILD_MINDETACH_MODULE=$(toml_get "$main_config_t" build-mindetach-module) || BUILD_MINDETACH_MODULE=false
if [ "$BUILD_MINDETACH_MODULE" = true ] && [ ! -f "mindetach-magisk/mindetach/detach.txt" ]; then
pr "mindetach module was not found."
BUILD_MINDETACH_MODULE=false
@ -49,11 +48,16 @@ PREBUILTS_DIR="${TEMP_DIR}/tools-${RV_BRAND_F}"
mkdir -p "$BUILD_DIR" "$PREBUILTS_DIR"
# -- Main config --
if ((COMPRESSION_LEVEL > 9)) || ((COMPRESSION_LEVEL < 0)); then abort "compression-level must be from 0 to 9"; fi
if ((COMPRESSION_LEVEL > 9)) || ((COMPRESSION_LEVEL < 0)); then abort "compression-level must be within 0-9"; fi
if [ "${NOSET:-}" = true ]; then set_prebuilts; else get_prebuilts || set_prebuilts; fi
if [ "$BUILD_MINDETACH_MODULE" = true ]; then : >$PKGS_LIST; fi
if [ "$LOGGING_F" = true ]; then mkdir -p logs; fi
#check_deps
jq --version >/dev/null || abort "\`jq\` is not installed. install it with 'apt install jq' or equivalent"
java --version | grep openjdk | grep 17 >/dev/null || abort "\`openjdk 17\` is not installed. install it with 'apt install openjdk-17-jre-headless' or equivalent"
zip --version >/dev/null || abort "\`zip\` is not installed. install it with 'apt install zip' or equivalent"
# --
log "**App Versions:**"
idx=0
@ -97,7 +101,8 @@ for table_name in $(toml_get_table_names); do
abort "ERROR: arch '${app_args[arch]}' is not a valid option for '${table_name}': only 'all', 'arm64-v8a', 'arm-v7a' is allowed"
fi
} || app_args[arch]="all"
app_args[merge_integrations]=$(toml_get "$t" merge-integrations) || app_args[merge_integrations]=true
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"
app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || {
app_name_l=${app_args[app_name],,}

View File

@ -1,4 +1,3 @@
compression-level = 9 # compression level for module zips. between 1 and 9
logging-to-file = true # enables logging of every patch process to a seperate file
enable-magisk-update = true # set this to false if you do not want to receive updates for the module in magisk app
build-mindetach-module = true
@ -9,7 +8,7 @@ build-mindetach-module = true
[YouTube]
enabled = true
build-mode = "both" # 'both', 'apk' or 'module'
excluded-patches = "debugging" # space-seperated patches to exclude (multiline strings are not supported)
excluded-patches = "" # 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', 'beta' or a custom one like '17.40.41'
exclusive-patches = false # excludes all patches by default

View File

@ -31,13 +31,29 @@ if BASEPATH=$(pm path __PKGNAME); then
elif [ ! -d ${BASEPATH}/lib ]; then
ui_print "* Invalid installation found. Uninstalling..."
pm uninstall -k --user 0 __PKGNAME
elif [ ! -f $MODPATH/__PKGNAME.apk ]; then
ui_print "* Stock __PKGNAME APK was not found"
VERSION=$(dumpsys package __PKGNAME | grep -m1 versionName)
VERSION="${VERSION#*=}"
if [ "$VERSION" = __PKGVER ] || [ -z "$VERSION" ]; then
ui_print "* Skipping stock installation"
INS=false
else
abort "ERROR: Version mismatch
installed: $VERSION
module: __PKGVER
"
fi
elif cmpr $BASEPATH/base.apk $MODPATH/__PKGNAME.apk; then
ui_print "* __PKGNAME is up-to-date"
INS=false
fi
fi
if [ $INS = true ]; then
ui_print "* Updating __PKGNAME (v__PKGVER)"
if [ ! -f $MODPATH/__PKGNAME.apk ]; then
abort "ERROR: Stock __PKGNAME apk was not found"
fi
ui_print "* Updating __PKGNAME to __PKGVER"
settings put global verifier_verify_adb_installs 0
SZ=$(stat -c "%s" $MODPATH/__PKGNAME.apk)
if ! SES=$(pm install-create --user 0 -i com.android.vending -r -d -S "$SZ" 2>&1); then

View File

@ -22,7 +22,7 @@ if [ $svcl = 0 ]; then
if [ -d $BASEPATH/lib ]; then
VERSION=$(dumpsys package __PKGNAME | grep -m1 versionName)
VERSION="${VERSION#*=}"
if [ "$VERSION" = __PKGVER ]; then
if [ "$VERSION" = __PKGVER ] || [ -z "$VERSION" ]; then
grep __PKGNAME /proc/mounts | while read -r line; do
mp=${line#* }
mp=${mp%% *}

View File

@ -2,7 +2,7 @@
{
rm $NVBASE/rvhc/__PKGNAME_rv.apk
rmdir $NVBASE/rvhc
if __ISBNDL :; then
if __ISBNDL; then
until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
sleep 15
pm uninstall __PKGNAME

View File

@ -410,7 +410,7 @@ build_rv() {
patched_apk="${TEMP_DIR}/${app_name_l}-${RV_BRAND_F}-${version_f}-${arch}.apk"
fi
if [ "$build_mode" = module ]; then
if [ $is_bundle = false ]; then
if [ $is_bundle = false ] || [ "${args[include_stock]}" = false ]; then
patcher_args+=("--unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a")
else
patcher_args+=("--unsigned")
@ -439,11 +439,11 @@ build_rv() {
fi
local isbndl extrct stock_apk_module
if [ $is_bundle = true ]; then
isbndl=""
isbndl=":"
extrct="base.apk"
stock_apk_module=$stock_bundle_apk
else
isbndl="!"
isbndl="! :"
extrct="${pkg_name}.apk"
stock_apk_module=$stock_apk
fi
@ -463,7 +463,7 @@ build_rv() {
if [ ! -f "$module_output" ] || [ "$REBUILD" = true ]; then
pr "Packing module ($app_name)"
cp -f "$patched_apk" "${base_template}/base.apk"
cp -f "$stock_apk_module" "${base_template}/${pkg_name}.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"
zip -"$COMPRESSION_LEVEL" -FSqr "../../${BUILD_DIR}/${module_output}" .
popd >/dev/null || :