mirror of
https://github.com/j-hc/revanced-magisk-module.git
synced 2025-05-20 08:17:07 +02:00
use a stub apk when available
This commit is contained in:
parent
4d35c6ea69
commit
1786a6193c
@ -13,7 +13,7 @@ Get the [latest CI release](https://github.com/j-hc/revanced-magisk-module/relea
|
|||||||
* Support all present and future ReVanced and [ReVanced Extended](https://github.com//inotia00/revanced-patches) apps
|
* Support all present and future ReVanced and [ReVanced Extended](https://github.com//inotia00/revanced-patches) apps
|
||||||
* Can build Magisk modules and non-root APKs
|
* Can build Magisk modules and non-root APKs
|
||||||
* Updated daily with the latest versions of apps and patches
|
* Updated daily with the latest versions of apps and patches
|
||||||
* Cleans APKs
|
* Optimize APKs and modules for size
|
||||||
* Modules
|
* Modules
|
||||||
* recompile invalidated odex for faster usage
|
* recompile invalidated odex for faster usage
|
||||||
* receive updates from Magisk app
|
* receive updates from Magisk app
|
||||||
|
2
build.sh
2
build.sh
@ -42,7 +42,7 @@ mkdir -p "$BUILD_DIR" "$PREBUILTS_DIR"
|
|||||||
# -- Main config --
|
# -- 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 from 0 to 9"; fi
|
||||||
if [ "${DRYRUN:-}" = true ]; then set_prebuilts; else get_prebuilts || set_prebuilts; fi
|
if [ "${NOSET:-}" = true ]; then set_prebuilts; else get_prebuilts || set_prebuilts; fi
|
||||||
if [ "$BUILD_MINDETACH_MODULE" = true ]; then : >$PKGS_LIST; fi
|
if [ "$BUILD_MINDETACH_MODULE" = true ]; then : >$PKGS_LIST; fi
|
||||||
if [ "$LOGGING_F" = true ]; then mkdir -p logs; fi
|
if [ "$LOGGING_F" = true ]; then mkdir -p logs; fi
|
||||||
jq --version >/dev/null || abort "\`jq\` is not installed. install it with 'apt install jq' or equivalent"
|
jq --version >/dev/null || abort "\`jq\` is not installed. install it with 'apt install jq' or equivalent"
|
||||||
|
@ -50,7 +50,8 @@ fi
|
|||||||
BASEPATHLIB=${BASEPATH%base.apk}lib/${ARCH}
|
BASEPATHLIB=${BASEPATH%base.apk}lib/${ARCH}
|
||||||
if [ -z "$(ls -A1 ${BASEPATHLIB})" ]; then
|
if [ -z "$(ls -A1 ${BASEPATHLIB})" ]; then
|
||||||
ui_print "* Extracting native libs"
|
ui_print "* Extracting native libs"
|
||||||
if ! op=$(unzip -j $MODPATH/__PKGNAME.apk lib/${ARCH_LIB}/* -d ${BASEPATHLIB} 2>&1); then
|
mkdir -p $BASEPATHLIB
|
||||||
|
if ! op=$(unzip -j $MODPATH/__EXTRCT lib/${ARCH_LIB}/* -d ${BASEPATHLIB} 2>&1); then
|
||||||
ui_print "ERROR: extracting native libs failed"
|
ui_print "ERROR: extracting native libs failed"
|
||||||
abort "$op"
|
abort "$op"
|
||||||
fi
|
fi
|
||||||
|
@ -2,4 +2,10 @@
|
|||||||
{
|
{
|
||||||
rm /data/adb/rvhc/__PKGNAME_rv.apk
|
rm /data/adb/rvhc/__PKGNAME_rv.apk
|
||||||
rmdir /data/adb/rvhc
|
rmdir /data/adb/rvhc
|
||||||
|
if __ISBNDL :; then
|
||||||
|
until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
|
||||||
|
until [ "$(getprop init.svc.bootanim)" = stopped ]; do sleep 1; done
|
||||||
|
sleep 3
|
||||||
|
pm uninstall __PKGNAME
|
||||||
|
fi
|
||||||
} &
|
} &
|
||||||
|
54
utils.sh
54
utils.sh
@ -272,7 +272,7 @@ build_rv() {
|
|||||||
fi
|
fi
|
||||||
pr "Choosing version '${version}' (${app_name})"
|
pr "Choosing version '${version}' (${app_name})"
|
||||||
local version_f=${version// /}
|
local version_f=${version// /}
|
||||||
local stock_apk="${TEMP_DIR}/${pkg_name}-stock-${version_f}-${arch}.apk"
|
local stock_apk="${TEMP_DIR}/${pkg_name}-${version_f}-${arch}.apk"
|
||||||
if [ ! -f "$stock_apk" ]; then
|
if [ ! -f "$stock_apk" ]; then
|
||||||
if [ "$dl_from" = apkmirror ]; then
|
if [ "$dl_from" = apkmirror ]; then
|
||||||
pr "Downloading '${app_name}' from APKMirror"
|
pr "Downloading '${app_name}' from APKMirror"
|
||||||
@ -307,6 +307,27 @@ build_rv() {
|
|||||||
if [ "$microg_patch" ]; then
|
if [ "$microg_patch" ]; then
|
||||||
p_patcher_args=("${p_patcher_args[@]//-[ei] ${microg_patch}/}")
|
p_patcher_args=("${p_patcher_args[@]//-[ei] ${microg_patch}/}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local stock_bundle="${TEMP_DIR}/${pkg_name}-${version_f}-${arch}-bundle.zip"
|
||||||
|
local stock_bundle_apk="${TEMP_DIR}/${pkg_name}-${version_f}-${arch}-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"
|
||||||
|
if dl_apkmirror "${args[apkmirror_dlurl]}" "$version" "BUNDLE</span>[^@]*@\([^#]*\)" "$stock_bundle"; then
|
||||||
|
pr "'${app_name}' bundle was downloaded successfully and will be used for the module"
|
||||||
|
is_bundle=true
|
||||||
|
unzip "$stock_bundle" "base.apk" -d $TEMP_DIR
|
||||||
|
mv ${TEMP_DIR}/base.apk "$stock_bundle_apk"
|
||||||
|
rm -f "$stock_bundle"
|
||||||
|
else
|
||||||
|
pr "'${app_name}' bundle was not found"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$mode_arg" = module ]; then
|
if [ "$mode_arg" = module ]; then
|
||||||
build_mode_arr=(module)
|
build_mode_arr=(module)
|
||||||
elif [ "$mode_arg" = apk ]; then
|
elif [ "$mode_arg" = apk ]; then
|
||||||
@ -314,7 +335,6 @@ build_rv() {
|
|||||||
elif [ "$mode_arg" = both ]; then
|
elif [ "$mode_arg" = both ]; then
|
||||||
build_mode_arr=(apk module)
|
build_mode_arr=(apk module)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local patcher_args patched_apk build_mode
|
local patcher_args patched_apk build_mode
|
||||||
for build_mode in "${build_mode_arr[@]}"; do
|
for build_mode in "${build_mode_arr[@]}"; do
|
||||||
patcher_args=("${p_patcher_args[@]}")
|
patcher_args=("${p_patcher_args[@]}")
|
||||||
@ -330,7 +350,11 @@ build_rv() {
|
|||||||
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}.apk"
|
||||||
fi
|
fi
|
||||||
if [ "$build_mode" = module ]; then
|
if [ "$build_mode" = module ]; then
|
||||||
|
if [ $is_bundle = false ]; then
|
||||||
patcher_args+=("--unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a")
|
patcher_args+=("--unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a")
|
||||||
|
else
|
||||||
|
patcher_args+=("--unsigned")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$patched_apk" ] || [ "$REBUILD" = true ]; then
|
if [ ! -f "$patched_apk" ] || [ "$REBUILD" = true ]; then
|
||||||
if ! patch_apk "$stock_apk" "$patched_apk" "${patcher_args[*]}"; then
|
if ! patch_apk "$stock_apk" "$patched_apk" "${patcher_args[*]}"; then
|
||||||
@ -353,10 +377,20 @@ build_rv() {
|
|||||||
else
|
else
|
||||||
upj="${app_name_l}-${arch}-update.json"
|
upj="${app_name_l}-${arch}-update.json"
|
||||||
fi
|
fi
|
||||||
|
local isbndl extrct stock_apk_module
|
||||||
|
if [ $is_bundle = true ]; then
|
||||||
|
isbndl=""
|
||||||
|
extrct="base.apk"
|
||||||
|
stock_apk_module=$stock_bundle_apk
|
||||||
|
else
|
||||||
|
isbndl="!"
|
||||||
|
extrct="${pkg_name}.apk"
|
||||||
|
stock_apk_module=$stock_apk
|
||||||
|
fi
|
||||||
|
|
||||||
uninstall_sh "$pkg_name" "$base_template"
|
uninstall_sh "$pkg_name" "$isbndl" "$base_template"
|
||||||
service_sh "$pkg_name" "$version" "$base_template"
|
service_sh "$pkg_name" "$version" "$base_template"
|
||||||
customize_sh "$pkg_name" "$version" "$arch" "$base_template"
|
customize_sh "$pkg_name" "$version" "$arch" "$extrct" "$base_template"
|
||||||
module_prop \
|
module_prop \
|
||||||
"${args[module_prop_name]}" \
|
"${args[module_prop_name]}" \
|
||||||
"${app_name} ${RV_BRAND}" \
|
"${app_name} ${RV_BRAND}" \
|
||||||
@ -367,7 +401,7 @@ build_rv() {
|
|||||||
|
|
||||||
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}.zip"
|
||||||
if [ ! -f "$module_output" ] || [ "$REBUILD" = true ]; then
|
if [ ! -f "$module_output" ] || [ "$REBUILD" = true ]; then
|
||||||
zip_module "$patched_apk" "$module_output" "$stock_apk" "$pkg_name" "$base_template"
|
zip_module "$patched_apk" "$module_output" "$stock_apk_module" "$pkg_name" "$base_template"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pr "Built ${app_name} (${arch}) (root): '${BUILD_DIR}/${module_output}'"
|
pr "Built ${app_name} (${arch}) (root): '${BUILD_DIR}/${module_output}'"
|
||||||
@ -378,16 +412,20 @@ join_args() {
|
|||||||
echo "$1" | tr -d '\t\r' | tr ' ' '\n' | grep -v '^$' | sed "s/^/${2} /" | paste -sd " " - || :
|
echo "$1" | tr -d '\t\r' | tr ' ' '\n' | grep -v '^$' | sed "s/^/${2} /" | paste -sd " " - || :
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall_sh() { echo "${UNINSTALL_SH//__PKGNAME/$1}" >"${2}/uninstall.sh"; }
|
uninstall_sh() {
|
||||||
|
local s="${UNINSTALL_SH//__PKGNAME/$1}"
|
||||||
|
echo "${s//__ISBNDL/$2}" >"${3}/uninstall.sh"
|
||||||
|
}
|
||||||
customize_sh() {
|
customize_sh() {
|
||||||
local s="${CUSTOMIZE_SH//__PKGNAME/$1}"
|
local s="${CUSTOMIZE_SH//__PKGNAME/$1}"
|
||||||
# shellcheck disable=SC2016,SC2001
|
s="${s//__EXTRCT/$4}"
|
||||||
|
# shellcheck disable=SC2001
|
||||||
if [ "$3" = "arm64-v8a" ]; then
|
if [ "$3" = "arm64-v8a" ]; then
|
||||||
s=$(sed 's/#arm$/abort "ERROR: Wrong arch\nYour device: arm\nModule: arm64"/g' <<<"$s")
|
s=$(sed 's/#arm$/abort "ERROR: Wrong arch\nYour device: arm\nModule: arm64"/g' <<<"$s")
|
||||||
elif [ "$3" = "arm-v7a" ]; then
|
elif [ "$3" = "arm-v7a" ]; then
|
||||||
s=$(sed 's/#arm64$/abort "ERROR: Wrong arch\nYour device: arm64\nModule: arm"/g' <<<"$s")
|
s=$(sed 's/#arm64$/abort "ERROR: Wrong arch\nYour device: arm64\nModule: arm"/g' <<<"$s")
|
||||||
fi
|
fi
|
||||||
echo "${s//__PKGVER/$2}" >"${4}/customize.sh"
|
echo "${s//__PKGVER/$2}" >"${5}/customize.sh"
|
||||||
}
|
}
|
||||||
service_sh() {
|
service_sh() {
|
||||||
local s="${SERVICE_SH//__PKGNAME/$1}"
|
local s="${SERVICE_SH//__PKGNAME/$1}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user