Remove NVBASE

We only move /cache/data_adb/magisk and /data/magisk to /data/adb/magisk (#7638), so NVBASE is redundant and we can just use MAGISKBIN.
This commit is contained in:
vvb2060 2024-07-17 02:16:15 +08:00 committed by John Wu
parent 2282365cf8
commit d33b077a13
3 changed files with 17 additions and 26 deletions

View File

@ -43,7 +43,7 @@ fix_env() {
# Cleanup and make dirs # Cleanup and make dirs
rm -rf $MAGISKBIN/* rm -rf $MAGISKBIN/*
mkdir -p $MAGISKBIN 2>/dev/null mkdir -p $MAGISKBIN 2>/dev/null
chmod 700 $NVBASE chmod 700 /data/adb
cp_readlink $1 $MAGISKBIN cp_readlink $1 $MAGISKBIN
rm -rf $1 rm -rf $1
chown -R 0:0 $MAGISKBIN chown -R 0:0 $MAGISKBIN
@ -97,7 +97,7 @@ restore_imgs() {
} }
post_ota() { post_ota() {
cd $NVBASE cd /data/adb
cp -f $1 bootctl cp -f $1 bootctl
rm -f $1 rm -f $1
chmod 755 bootctl chmod 755 bootctl
@ -116,8 +116,8 @@ EOF
add_hosts_module() { add_hosts_module() {
# Do not touch existing hosts module # Do not touch existing hosts module
[ -d $NVBASE/modules/hosts ] && return [ -d /data/adb/modules/hosts ] && return
cd $NVBASE/modules cd /data/adb/modules
mkdir -p hosts/system/etc mkdir -p hosts/system/etc
cat << EOF > hosts/module.prop cat << EOF > hosts/module.prop
id=hosts id=hosts

View File

@ -123,9 +123,9 @@ fi
# Magisk stuff # Magisk stuff
mkdir -p $MAGISKBIN 2>/dev/null mkdir -p $MAGISKBIN 2>/dev/null
unzip -oj magisk.apk 'assets/*.sh' -d $MAGISKBIN unzip -oj magisk.apk 'assets/*.sh' -d $MAGISKBIN
mkdir $NVBASE/modules 2>/dev/null mkdir /data/adb/modules 2>/dev/null
mkdir $NVBASE/post-fs-data.d 2>/dev/null mkdir /data/adb/post-fs-data.d 2>/dev/null
mkdir $NVBASE/service.d 2>/dev/null mkdir /data/adb/service.d 2>/dev/null
for file in magisk magisk32 magiskpolicy stub.apk; do for file in magisk magisk32 magiskpolicy stub.apk; do
chmod 755 ./$file chmod 755 ./$file

View File

@ -14,10 +14,6 @@
# The path to store temporary files that don't need to persist # The path to store temporary files that don't need to persist
# TMPDIR= # TMPDIR=
# The path to store files that can be persisted (non-volatile storage)
# Any modification to this variable should go through the function `set_nvbase`
# NVBASE=
# The non-volatile path where magisk executables are stored # The non-volatile path where magisk executables are stored
# MAGISKBIN= # MAGISKBIN=
@ -84,11 +80,6 @@ abort() {
exit 1 exit 1
} }
set_nvbase() {
NVBASE="$1"
MAGISKBIN="$1/magisk"
}
print_title() { print_title() {
local len line1len line2len bar local len line1len line2len bar
line1len=$(echo -n $1 | wc -c) line1len=$(echo -n $1 | wc -c)
@ -527,9 +518,9 @@ check_data() {
$DATA && [ -d /data/adb ] && touch /data/adb/.rw && rm /data/adb/.rw && DATA_DE=true $DATA && [ -d /data/adb ] && touch /data/adb/.rw && rm /data/adb/.rw && DATA_DE=true
$DATA_DE && [ -d /data/adb/magisk ] || mkdir /data/adb/magisk || DATA_DE=false $DATA_DE && [ -d /data/adb/magisk ] || mkdir /data/adb/magisk || DATA_DE=false
fi fi
set_nvbase "/data" MAGISKBIN="/data/magisk"
$DATA || set_nvbase "/cache/data_adb" $DATA || MAGISKBIN="/cache/data_adb/magisk"
$DATA_DE && set_nvbase "/data/adb" $DATA_DE && MAGISKBIN="/data/adb/magisk"
} }
run_migrations() { run_migrations() {
@ -575,7 +566,7 @@ copy_preinit_files() {
fi fi
# Copy all enabled sepolicy.rule # Copy all enabled sepolicy.rule
for r in $NVBASE/modules*/*/sepolicy.rule; do for r in /data/adb/modules*/*/sepolicy.rule; do
[ -f "$r" ] || continue [ -f "$r" ] || continue
local MODDIR=${r%/*} local MODDIR=${r%/*}
[ -f $MODDIR/disable ] && continue [ -f $MODDIR/disable ] && continue
@ -645,7 +636,7 @@ install_module() {
local MODDIRNAME=modules local MODDIRNAME=modules
$BOOTMODE && MODDIRNAME=modules_update $BOOTMODE && MODDIRNAME=modules_update
local MODULEROOT=$NVBASE/$MODDIRNAME local MODULEROOT=/data/adb/$MODDIRNAME
MODID=$(grep_prop id $TMPDIR/module.prop) MODID=$(grep_prop id $TMPDIR/module.prop)
MODNAME=$(grep_prop name $TMPDIR/module.prop) MODNAME=$(grep_prop name $TMPDIR/module.prop)
MODAUTH=$(grep_prop author $TMPDIR/module.prop) MODAUTH=$(grep_prop author $TMPDIR/module.prop)
@ -704,10 +695,10 @@ install_module() {
if $BOOTMODE; then if $BOOTMODE; then
# Update info for Magisk app # Update info for Magisk app
mktouch $NVBASE/modules/$MODID/update mktouch /data/adb/modules/$MODID/update
rm -rf $NVBASE/modules/$MODID/remove 2>/dev/null rm -rf /data/adb/modules/$MODID/remove 2>/dev/null
rm -rf $NVBASE/modules/$MODID/disable 2>/dev/null rm -rf /data/adb/modules/$MODID/disable 2>/dev/null
cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop cp -af $MODPATH/module.prop /data/adb/modules/$MODID/module.prop
fi fi
# Copy over custom sepolicy rules # Copy over custom sepolicy rules
@ -739,4 +730,4 @@ install_module() {
[ -z $BOOTMODE ] && BOOTMODE=false [ -z $BOOTMODE ] && BOOTMODE=false
TMPDIR=/dev/tmp TMPDIR=/dev/tmp
set_nvbase "/data/adb" MAGISKBIN="/data/adb/magisk"