module: extract native libs when needed

This commit is contained in:
j-hc 2023-01-12 23:05:35 +03:00
parent 1adb65c9aa
commit d5763cd0a0
6 changed files with 64 additions and 60 deletions

View File

@ -1,43 +1,42 @@
# Config # Config
Adding a new app is as easy as this: Adding a new app is as easy as this:
```toml ```toml
[Some-App] [Some-App]
apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" # download url for the app. apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" # download url for the app.
``` ```
or: or:
```toml ```toml
[Some-App] [Some-App]
uptodown-dlurl = "https://app.en.uptodown.com/android" # uptodown url. uptodown-dlurl = "https://app.en.uptodown.com/android" # uptodown url.
``` ```
## If you'd like to get to know more about other options: ## If you'd like to get to know more about other options:
There exists an example below with all defaults and all the keys explicitly set. There exists an example below with all defaults and all the keys explicitly set.
Almost all keys are optional and are assigned their default values if not set explicitly. Almost all keys are optional and are assigned their default values if not set explicitly.
```toml ```toml
[Some-App] [Some-App]
app-name = "SomeApp" # if set, app name becomes SomeApp instead of Some-App. default is same as table name. app-name = "SomeApp" # if set, app name becomes SomeApp instead of Some-App. default is same as table name.
# this affects the release name and stuff like that # this affects the release name and stuff like that
enabled = true # whether to build the app. default: true enabled = true # whether to build the app. default: true
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 allow-alpha-version = false # allow downloading alpha versions from apkmirror. default: false
rip-libs = false # removes all native libs from the app. default: false excluded-patches = "some-patch" # 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. default: "" (empty)
included-patches = "patch-name" # whitespace seperated list of patches to include. default: "" (empty) version = "auto" # 'auto', 'latest' or a custom one e.g. '17.40.41'. default: auto
version = "auto" # 'auto', 'latest' or a custom one e.g. '17.40.41'. default: auto exclusive-patches = false # exclude all patches by default. default: false
exclusive-patches = false # exclude all patches by default. default: false microg-patch = "microg-support" # name of the microg-patch if exists for the app. default: "" (empty)
microg-patch = "microg-support" # name of the microg-patch if exists for the app. default: "" (empty) 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 module-prop-name = "ytrv-magisk" # explicit magisk module prop name. not explicitly needed to be set.
module-prop-name = "ytrv-magisk" # explicit magisk module prop name. not explicitly needed to be set. merge-integrations = true # whether to merge revanced integrations. default: false
merge-integrations = true # whether to merge revanced integrations. default: false arch = "arm64-v8a" # 'arm64-v8a', 'arm-v7a' or 'all'.
arch = "arm64-v8a" # 'arm64-v8a', 'arm-v7a' or 'all'. # this option is sometimes needed to be able to download the apks from apkmirror. default: all
# this option is sometimes needed to be able to download the apks from apkmirror. default: all # and does not affect anything else
# and does not affect anything else
apkmirror-regex = 'APK</span>[^@]*@\([^#]*\)' # regex used to get the dl url in apkmirror. default: APK</span>[^@]*@\([^#]*\)
apkmirror-regex = 'APK</span>[^@]*@\([^#]*\)' # regex used to get the dl url in apkmirror. default: APK</span>[^@]*@\([^#]*\) # this default gets the url to the non-bundle apk.
# this default gets the url to the non-bundle apk. ```
```

View File

@ -11,6 +11,7 @@ Get the [latest CI release](https://github.com/j-hc/revanced-magisk-module/relea
## Features ## Features
* Can build Magisk modules and non-root APKs * Can build Magisk modules and non-root APKs
* Support all present and future Revanced apps
* Updated daily with the latest versions of apps and patches in accordance with your configuration * Updated daily with the latest versions of apps and patches in accordance with your configuration
* Cleans APKs from unneeded libs to make them smaller * Cleans APKs from unneeded libs to make them smaller
* Fully open-source, every binary or APK is compiled without human intervention * Fully open-source, every binary or APK is compiled without human intervention
@ -32,7 +33,7 @@ Get the [latest CI release](https://github.com/j-hc/revanced-magisk-module/relea
* Run the build [workflow](../../actions/workflows/build.yml) * Run the build [workflow](../../actions/workflows/build.yml)
* Grab your modules and APKs from [releases](../../releases) * Grab your modules and APKs from [releases](../../releases)
To get to know more about `config.toml`, read here [`CONFIG.md`](./CONFIG.md) To add more Revanced apps or know more about `config.toml`, read here [`CONFIG.md`](./CONFIG.md)
To be able to use non-root variants of YouTube and YT Music, install [Vanced MicroG](https://github.com/TeamVanced/VancedMicroG/releases). To be able to use non-root variants of YouTube and YT Music, install [Vanced MicroG](https://github.com/TeamVanced/VancedMicroG/releases).

View File

@ -32,7 +32,6 @@ for t in $(toml_get_all_tables); do
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]=$t app_args[app_name]=$(toml_get "$t" app-name) || app_args[app_name]=$t
app_args[allow_alpha_version]=$(toml_get "$t" allow-alpha-version) || app_args[allow_alpha_version]=false app_args[allow_alpha_version]=$(toml_get "$t" allow-alpha-version) || app_args[allow_alpha_version]=false
app_args[rip_libs]=$(toml_get "$t" rip-libs) || app_args[rip_libs]=false
app_args[build_mode]=$(toml_get "$t" build-mode) || app_args[build_mode]=apk app_args[build_mode]=$(toml_get "$t" build-mode) || app_args[build_mode]=apk
app_args[microg_patch]=$(toml_get "$t" microg-patch) || app_args[microg_patch]="" app_args[microg_patch]=$(toml_get "$t" microg-patch) || app_args[microg_patch]=""
app_args[uptodown_dlurl]=$(toml_get "$t" uptodown-dlurl) && app_args[uptodown_dlurl]=${app_args[uptodown_dlurl]%/} || app_args[uptodown_dlurl]="" app_args[uptodown_dlurl]=$(toml_get "$t" uptodown-dlurl) && app_args[uptodown_dlurl]=${app_args[uptodown_dlurl]%/} || app_args[uptodown_dlurl]=""

View File

@ -1,4 +1,4 @@
# See https://github.com/j-hc/revanced-magisk-module/blob/main/CONFIG.md for more detailed explanations # see https://github.com/j-hc/revanced-magisk-module/blob/main/CONFIG.md for more detailed explanations
[main-config] [main-config]
compression-level = 9 # compression level for module zips. between 1 and 9 compression-level = 9 # compression level for module zips. between 1 and 9
@ -19,7 +19,6 @@ microg-patch = "microg-support"
apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube/" apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube/"
module-prop-name = "ytrv-magisk" module-prop-name = "ytrv-magisk"
merge-integrations = true merge-integrations = true
rip-libs = true
[Music-arm64] [Music-arm64]
build-mode = "both" build-mode = "both"
@ -109,7 +108,7 @@ build-mode = "apk"
apkmirror-dlurl = "https://www.apkmirror.com/apk/awedea/nyx-music-player/" apkmirror-dlurl = "https://www.apkmirror.com/apk/awedea/nyx-music-player/"
[IconPackStudio] [IconPackStudio]
enabled = true enabled = false
version = "latest" version = "latest"
build-mode = "apk" build-mode = "apk"
apkmirror-dlurl = "https://www.apkmirror.com/apk/smart-launcher-team/icon-pack-studio/" apkmirror-dlurl = "https://www.apkmirror.com/apk/smart-launcher-team/icon-pack-studio/"

View File

@ -3,7 +3,9 @@ ui_print ""
if [ $ARCH = "arm" ]; then if [ $ARCH = "arm" ]; then
alias cmpr='$MODPATH/bin/arm/cmpr' alias cmpr='$MODPATH/bin/arm/cmpr'
ARCH_LIB=armeabi-v7a
elif [ $ARCH = "arm64" ]; then elif [ $ARCH = "arm64" ]; then
ARCH_LIB=arm64-v8a
alias cmpr='$MODPATH/bin/arm64/cmpr' alias cmpr='$MODPATH/bin/arm64/cmpr'
else else
abort "ERROR: unsupported arch: ${ARCH}" abort "ERROR: unsupported arch: ${ARCH}"
@ -26,17 +28,26 @@ BASEPATH=$(basepath)
if [ -n "$BASEPATH" ] && cmpr $BASEPATH $MODPATH/__PKGNAME.apk; then if [ -n "$BASEPATH" ] && cmpr $BASEPATH $MODPATH/__PKGNAME.apk; then
ui_print "* Updating with stock APK is not needed" ui_print "* Updating with stock APK is not needed"
else else
ui_print "* Updating __PKGNAME to __PKGVER" ui_print "* Updating __PKGNAME (v__PKGVER)"
set_perm $MODPATH/__PKGNAME.apk 1000 1000 644 u:object_r:apk_data_file:s0 set_perm $MODPATH/__PKGNAME.apk 1000 1000 644 u:object_r:apk_data_file:s0
if ! op=$(pm install --user 0 -i com.android.vending -r -d $MODPATH/__PKGNAME.apk 2>&1); then if ! op=$(cmd package install --user 0 -i com.android.vending -r -d $MODPATH/__PKGNAME.apk 2>&1); then
ui_print "ERROR: APK installation failed!" ui_print "ERROR: APK installation failed!"
abort "${op}" abort "$op"
fi fi
BASEPATH=$(basepath) BASEPATH=$(basepath)
if [ -z "$BASEPATH" ]; then if [ -z "$BASEPATH" ]; then
abort "ERROR: install __PKGNAME manually and reflash the module" abort "ERROR: install __PKGNAME manually and reflash the module"
fi fi
fi fi
BASEPATHLIB=${BASEPATH%base.apk}lib/${ARCH}
if ! ls ${BASEPATHLIB}/*.so; then
ui_print "* Extracting native libs"
if ! op=$(unzip -j $MODPATH/__PKGNAME.apk lib/${ARCH_LIB}/* -d ${BASEPATHLIB} 2>&1); then
ui_print "ERROR: extracting native libs failed"
abort "$op"
fi
set_perm_recursive ${BASEPATHLIB} 1000 1000 755 755 u:object_r:apk_data_file:s0
fi
ui_print "* Setting Permissions" ui_print "* Setting Permissions"
set_perm $MODPATH/base.apk 1000 1000 644 u:object_r:apk_data_file:s0 set_perm $MODPATH/base.apk 1000 1000 644 u:object_r:apk_data_file:s0
@ -48,12 +59,12 @@ if ! op=$(mount -o bind $RVPATH $BASEPATH 2>&1); then
ui_print "ERROR: Mount failed!" ui_print "ERROR: Mount failed!"
abort "$op" abort "$op"
fi fi
rm -r $MODPATH/bin $MODPATH/__PKGNAME.apk
am force-stop __PKGNAME am force-stop __PKGNAME
ui_print "* Optimizing __PKGNAME" ui_print "* Optimizing __PKGNAME"
cmd package compile --reset __PKGNAME & cmd package compile --reset __PKGNAME &
rm -r $MODPATH/bin $MODPATH/__PKGNAME.apk
ui_print "* Done" ui_print "* Done"
ui_print " by j-hc (github.com/j-hc)" ui_print " by j-hc (github.com/j-hc)"
ui_print " " ui_print " "

View File

@ -240,12 +240,8 @@ build_rv() {
patcher_args="$patcher_args --experimental" patcher_args="$patcher_args --experimental"
fi fi
if [ "$build_mode" = module ]; then if [ "$build_mode" = module ]; then
if [ "${args[rip_libs]}" = true ]; then # --unsigned and --rip-lib is only available in my revanced-cli builds
# --unsigned and --rip-lib is only available in my revanced-cli builds patcher_args="$patcher_args --unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a"
patcher_args="$patcher_args --unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a"
else
patcher_args="$patcher_args --unsigned"
fi
fi fi
if [ $get_latest_ver = true ]; then if [ $get_latest_ver = true ]; then
local apkmvers uptwodvers local apkmvers uptwodvers
@ -326,7 +322,6 @@ build_rv() {
local module_output="${app_name_l}-revanced-magisk-v${version}-${arch}.zip" local module_output="${app_name_l}-revanced-magisk-v${version}-${arch}.zip"
zip_module "$patched_apk" "$module_output" "$stock_apk" "$pkg_name" "$base_template" zip_module "$patched_apk" "$module_output" "$stock_apk" "$pkg_name" "$base_template"
rm -rf "$base_template"
echo "Built ${args[app_name]} (${arch}) (root): '${BUILD_DIR}/${module_output}'" echo "Built ${args[app_name]} (${arch}) (root): '${BUILD_DIR}/${module_output}'"
done done