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
Adding a new app is as easy as this:
```toml
[Some-App]
apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" # download url for the app.
```
or:
```toml
[Some-App]
uptodown-dlurl = "https://app.en.uptodown.com/android" # uptodown url.
```
## 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.
Almost all keys are optional and are assigned their default values if not set explicitly.
```toml
[Some-App]
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
enabled = true # whether to build the app. default: true
build-mode = "both" # 'both', 'apk' or 'module'. default: apk
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)
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
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)
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
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
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
# and does not affect anything else
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.
```
# Config
Adding a new app is as easy as this:
```toml
[Some-App]
apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" # download url for the app.
```
or:
```toml
[Some-App]
uptodown-dlurl = "https://app.en.uptodown.com/android" # uptodown url.
```
## 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.
Almost all keys are optional and are assigned their default values if not set explicitly.
```toml
[Some-App]
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
enabled = true # whether to build the app. default: true
build-mode = "both" # 'both', 'apk' or 'module'. default: apk
allow-alpha-version = false # allow downloading alpha versions from apkmirror. default: false
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)
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
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.
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.
merge-integrations = true # whether to merge revanced integrations. default: false
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
# and does not affect anything else
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.
```

View File

@ -11,6 +11,7 @@ Get the [latest CI release](https://github.com/j-hc/revanced-magisk-module/relea
## Features
* 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
* Cleans APKs from unneeded libs to make them smaller
* 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)
* 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).

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[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[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[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]=""

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]
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/"
module-prop-name = "ytrv-magisk"
merge-integrations = true
rip-libs = true
[Music-arm64]
build-mode = "both"
@ -109,7 +108,7 @@ build-mode = "apk"
apkmirror-dlurl = "https://www.apkmirror.com/apk/awedea/nyx-music-player/"
[IconPackStudio]
enabled = true
enabled = false
version = "latest"
build-mode = "apk"
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
alias cmpr='$MODPATH/bin/arm/cmpr'
ARCH_LIB=armeabi-v7a
elif [ $ARCH = "arm64" ]; then
ARCH_LIB=arm64-v8a
alias cmpr='$MODPATH/bin/arm64/cmpr'
else
abort "ERROR: unsupported arch: ${ARCH}"
@ -26,17 +28,26 @@ BASEPATH=$(basepath)
if [ -n "$BASEPATH" ] && cmpr $BASEPATH $MODPATH/__PKGNAME.apk; then
ui_print "* Updating with stock APK is not needed"
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
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!"
abort "${op}"
abort "$op"
fi
BASEPATH=$(basepath)
if [ -z "$BASEPATH" ]; then
abort "ERROR: install __PKGNAME manually and reflash the module"
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"
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!"
abort "$op"
fi
rm -r $MODPATH/bin $MODPATH/__PKGNAME.apk
am force-stop __PKGNAME
ui_print "* Optimizing __PKGNAME"
cmd package compile --reset __PKGNAME &
rm -r $MODPATH/bin $MODPATH/__PKGNAME.apk
ui_print "* Done"
ui_print " by j-hc (github.com/j-hc)"
ui_print " "

View File

@ -240,12 +240,8 @@ build_rv() {
patcher_args="$patcher_args --experimental"
fi
if [ "$build_mode" = module ]; then
if [ "${args[rip_libs]}" = true ]; then
# --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"
else
patcher_args="$patcher_args --unsigned"
fi
# --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"
fi
if [ $get_latest_ver = true ]; then
local apkmvers uptwodvers
@ -326,7 +322,6 @@ build_rv() {
local module_output="${app_name_l}-revanced-magisk-v${version}-${arch}.zip"
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}'"
done