diff --git a/README.md b/README.md index 91d28b3..27d8acc 100755 --- a/README.md +++ b/README.md @@ -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 * Can build Magisk modules and non-root APKs * Updated daily with the latest versions of apps and patches - * Cleans APKs + * Optimize APKs and modules for size * Modules * recompile invalidated odex for faster usage * receive updates from Magisk app diff --git a/build.sh b/build.sh index 2447959..344f645 100755 --- a/build.sh +++ b/build.sh @@ -42,7 +42,7 @@ 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 [ "${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 [ "$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" diff --git a/scripts/customize.sh b/scripts/customize.sh index ef8f722..a471a73 100755 --- a/scripts/customize.sh +++ b/scripts/customize.sh @@ -50,7 +50,8 @@ fi BASEPATHLIB=${BASEPATH%base.apk}lib/${ARCH} if [ -z "$(ls -A1 ${BASEPATHLIB})" ]; then 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" abort "$op" fi diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index 99b6bb3..d3638b5 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -2,4 +2,10 @@ { rm /data/adb/rvhc/__PKGNAME_rv.apk 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 } & diff --git a/utils.sh b/utils.sh index 793a44f..93bc545 100755 --- a/utils.sh +++ b/utils.sh @@ -272,7 +272,7 @@ build_rv() { fi pr "Choosing version '${version}' (${app_name})" 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 [ "$dl_from" = apkmirror ]; then pr "Downloading '${app_name}' from APKMirror" @@ -307,6 +307,27 @@ build_rv() { if [ "$microg_patch" ]; then p_patcher_args=("${p_patcher_args[@]//-[ei] ${microg_patch}/}") 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[^@]*@\([^#]*\)" "$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 build_mode_arr=(module) elif [ "$mode_arg" = apk ]; then @@ -314,7 +335,6 @@ build_rv() { elif [ "$mode_arg" = both ]; then build_mode_arr=(apk module) fi - local patcher_args patched_apk build_mode for build_mode in "${build_mode_arr[@]}"; do 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" fi if [ "$build_mode" = module ]; then - patcher_args+=("--unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a") + if [ $is_bundle = false ]; then + patcher_args+=("--unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a") + else + patcher_args+=("--unsigned") + fi fi if [ ! -f "$patched_apk" ] || [ "$REBUILD" = true ]; then if ! patch_apk "$stock_apk" "$patched_apk" "${patcher_args[*]}"; then @@ -353,10 +377,20 @@ build_rv() { else upj="${app_name_l}-${arch}-update.json" 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" - customize_sh "$pkg_name" "$version" "$arch" "$base_template" + customize_sh "$pkg_name" "$version" "$arch" "$extrct" "$base_template" module_prop \ "${args[module_prop_name]}" \ "${app_name} ${RV_BRAND}" \ @@ -367,7 +401,7 @@ build_rv() { local module_output="${app_name_l}-${RV_BRAND_F}-magisk-v${version}-${arch}.zip" 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 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 " " - || : } -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() { local s="${CUSTOMIZE_SH//__PKGNAME/$1}" - # shellcheck disable=SC2016,SC2001 + s="${s//__EXTRCT/$4}" + # shellcheck disable=SC2001 if [ "$3" = "arm64-v8a" ]; then s=$(sed 's/#arm$/abort "ERROR: Wrong arch\nYour device: arm\nModule: arm64"/g' <<<"$s") elif [ "$3" = "arm-v7a" ]; then s=$(sed 's/#arm64$/abort "ERROR: Wrong arch\nYour device: arm64\nModule: arm"/g' <<<"$s") fi - echo "${s//__PKGVER/$2}" >"${4}/customize.sh" + echo "${s//__PKGVER/$2}" >"${5}/customize.sh" } service_sh() { local s="${SERVICE_SH//__PKGNAME/$1}"