Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NoName-exe authored Mar 29, 2023
2 parents 905a78c + 4f3aa1f commit fa9ab34
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 31 deletions.
17 changes: 11 additions & 6 deletions build-termux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ask() {
return 1
}

CFG=config.toml

if [ ! -f ~/.rvmm_"$(date '+%Y%m')" ]; then
pr "Setting up environment..."
yes "" | pkg update -y && pkg install -y openssl git wget jq openjdk-17 zip
Expand All @@ -32,26 +34,29 @@ if [ -d revanced-magisk-module ]; then
if git -C revanced-magisk-module status | grep -q 'is behind'; then
pr "revanced-magisk-module already is not synced with upstream."
pr "Cloning revanced-magisk-module. config.toml will be preserved."
cp -f revanced-magisk-module/config.toml .
cp -f revanced-magisk-module/config*toml .
rm -rf revanced-magisk-module
git clone https://github.com/j-hc/revanced-magisk-module --recurse --depth 1
mv -f config.toml revanced-magisk-module/config.toml
mv -f config*toml revanced-magisk-module/
fi
else
pr "Cloning revanced-magisk-module."
git clone https://github.com/j-hc/revanced-magisk-module --recurse --depth 1
sed -i '/^enabled.*/d; /^\[.*\]/a enabled = false' revanced-magisk-module/config.toml
sed -i '/^enabled.*/d; /^\[.*\]/a enabled = false' revanced-magisk-module/config*toml
fi
cd revanced-magisk-module
chmod +x build.sh build-termux.sh

if ask "Do you want to open the config.toml for customizations? [y/n]"; then
nano config.toml
if ! ask "Select config (y=revanced n=revanced extended)"; then
CFG=config-rv-ex.toml
fi
if ask "Do you want to open the config for customizations? [y/n]"; then
nano $CFG
fi
if ! ask "Setup is done. Do you want to start building? [y/n]"; then
exit 0
fi
./build.sh
./build.sh $CFG

cd build
pr "Ask for storage permission"
Expand Down
9 changes: 8 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ 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
PARALLEL_JOBS=$(toml_get "$main_config_t" parallel-jobs) || PARALLEL_JOBS=1
BUILD_MINDETACH_MODULE=$(toml_get "$main_config_t" build-mindetach-module) || abort "ERROR: build-mindetach-module is missing"
if [ "$BUILD_MINDETACH_MODULE" = true ] && [ ! -f "mindetach-magisk/mindetach/detach.txt" ]; then
pr "mindetach module was not found."
BUILD_MINDETACH_MODULE=false
fi
if ! PARALLEL_JOBS=$(toml_get "$main_config_t" parallel-jobs); then
if [ "$OS" = Android ]; then PARALLEL_JOBS=1; else PARALLEL_JOBS=$(nproc); fi
fi
LOGGING_F=$(toml_get "$main_config_t" logging-to-file) && vtf "$LOGGING_F" "logging-to-file" || LOGGING_F=false
CONF_PATCHES_VER=$(toml_get "$main_config_t" patches-version) || CONF_PATCHES_VER=
CONF_INTEGRATIONS_VER=$(toml_get "$main_config_t" integrations-version) || CONF_INTEGRATIONS_VER=
Expand Down Expand Up @@ -111,6 +117,7 @@ for table_name in $(toml_get_table_names); do
done
wait
rm -rf temp/tmp.*
if [ -z "$(ls -A1 ${BUILD_DIR})" ]; then abort "All builds failed."; fi

if [ "$BUILD_MINDETACH_MODULE" = true ]; then
pr "Building mindetach module"
Expand Down
1 change: 0 additions & 1 deletion config-rv-ex.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
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
parallel-jobs = 1 # max number of concurrent building jobs
build-mindetach-module = true

# extended
Expand Down
1 change: 0 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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
parallel-jobs = 1 # max number of concurrent building jobs
build-mindetach-module = false
patches-source = "inotia00/revanced-patches"
integrations-source = "inotia00/revanced-integrations"
Expand Down
16 changes: 10 additions & 6 deletions scripts/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ else
fi
set_perm_recursive $MODPATH/bin 0 0 0755 0777

nsenter -t1 -m grep __PKGNAME /proc/mounts | while read -r line; do
nsenter -t1 -m -- grep __PKGNAME /proc/mounts | while read -r line; do
ui_print "- Un-mount"
mp=${line#* }
mp=${mp%% *}
nsenter -t1 -m umount -l ${mp%%\\*}
nsenter -t1 -m -- umount -l "${mp%%\\*}"
done
am force-stop __PKGNAME

Expand All @@ -41,7 +41,7 @@ if [ $INS = true ]; then
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
ui_print "ERROR: session creation failed"
ui_print "ERROR: install-create failed"
abort "$SES"
fi
SES=${SES#*[}
Expand Down Expand Up @@ -71,17 +71,17 @@ if [ -z "$(ls -A1 ${BASEPATHLIB})" ]; 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
set_perm_recursive ${BASEPATH}/lib 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

ui_print "- Mounting __PKGNAME"
mkdir $NVBASE/rvhc 2>/dev/null
mkdir -p $NVBASE/rvhc
RVPATH=$NVBASE/rvhc/__PKGNAME_rv.apk
mv -f $MODPATH/base.apk $RVPATH

if ! op=$(nsenter -t1 -m mount -o bind $RVPATH $BASEPATH/base.apk 2>&1); then
if ! op=$(nsenter -t1 -m -- mount -o bind $RVPATH $BASEPATH/base.apk 2>&1); then
ui_print "ERROR: Mount failed!"
ui_print "$op"
fi
Expand All @@ -91,3 +91,7 @@ nohup cmd package compile --reset __PKGNAME >/dev/null 2>&1 &

ui_print "- Cleanup"
rm -rf $MODPATH/bin $MODPATH/__PKGNAME.apk

for s in "uninstall.sh" "service.sh"; do
sed -i "2 i\NVBASE=${NVBASE}" $MODPATH/$s
done
7 changes: 3 additions & 4 deletions scripts/service.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/system/bin/sh
# shellcheck disable=SC2086
MODDIR=${0%/*}
MODULES=${MODDIR%/*}
RVPATH=${MODULES%/*}/rvhc/__PKGNAME_rv.apk
RVPATH=${NVBASE}/rvhc/__PKGNAME_rv.apk

until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
while
BASEPATH=$(pm path __PKGNAME)
svcl=$?
[ $svcl = 20 ]
do sleep 1; done
sleep 5
do sleep 2; done
sleep 4

err() {
[ ! -f $MODDIR/err ] && cp $MODDIR/module.prop $MODDIR/err
Expand Down
3 changes: 0 additions & 3 deletions scripts/uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/system/bin/sh
{
MODDIR=${0%/*}
MODULES=${MODDIR%/*}
NVBASE=${MODULES%/*}
rm $NVBASE/rvhc/__PKGNAME_rv.apk
rmdir $NVBASE/rvhc
if __ISBNDL :; then
Expand Down
15 changes: 6 additions & 9 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,14 @@ semver_validate() {
[ ${#ac} = 0 ]
}
get_patch_last_supported_ver() {
local inc_sel exc_sel exclus_sel
inc_sel=$(list_args "$2" | sed 's/.*/\.name == "&"/' | sed 'N;s/\n/ or /' || :)
exc_sel=$(list_args "$3" | sed 's/.*/\.name != "&"/' | sed 'N;s/\n/ and /' || :)
if [ "$4" = false ]; then exclus_sel=".excluded==false"; else
exclus_sel="true"
inc_sel=${inc_sel:-false}
fi
local inc_sel exc_sel
inc_sel=$(list_args "$2" | sed 's/.*/\.name == "&"/' | paste -sd '~' | sed 's/~/ or /g' || :)
exc_sel=$(list_args "$3" | sed 's/.*/\.name != "&"/' | paste -sd '~' | sed 's/~/ and /g' || :)
inc_sel=${inc_sel:-false}
if [ "$4" = false ]; then inc_sel="${inc_sel} or .excluded==false"; fi
jq -r ".[]
| select(.compatiblePackages[].name==\"${1}\")
| select(${exclus_sel})
| select(${inc_sel:-true})
| select(${inc_sel})
| select(${exc_sel:-true})
| .compatiblePackages[].versions" "$RV_PATCHES_JSON" |
tr -d ' ,\t[]"' | grep -v '^$' | sort | uniq -c | sort -nr | head -1 | xargs | cut -d' ' -f2 || return 1
Expand Down

0 comments on commit fa9ab34

Please sign in to comment.