Rename rules to preinit

It is possible that we will allow more preinit files for modules.
Rename the partition and folders from rules to preinit.
This commit is contained in:
topjohnwu
2023-03-16 04:07:00 -07:00
committed by John Wu
parent 7048aa1014
commit 4e2b88b3d0
18 changed files with 110 additions and 118 deletions

View File

@ -63,9 +63,9 @@ export KEEPFORCEENCRYPT=true
echo "KEEPVERITY=$KEEPVERITY" > config
echo "KEEPFORCEENCRYPT=$KEEPFORCEENCRYPT" >> config
if [ -e "/system/bin/linker64" ]; then
echo "RULESDEVICE=$(./magisk64 --rules-device)" >> config
echo "PREINITDEVICE=$(./magisk64 --preinit-device)" >> config
else
echo "RULESDEVICE=$(./magisk32 --rules-device)" >> config
echo "PREINITDEVICE=$(./magisk32 --preinit-device)" >> config
fi
# For API 28, we also patch advancedFeatures.ini to disable SAR
# Manually override skip_initramfs by setting RECOVERYMODE=true

View File

@ -77,7 +77,6 @@ fi
export KEEPVERITY
export KEEPFORCEENCRYPT
export PATCHVBMETAFLAG
export MAGISKTMP
chmod -R 755 .
@ -138,7 +137,7 @@ case $((STATUS & 3)) in
;;
esac
# Work around custom legacy Sony /init -> /(s)bin/init_sony : /init.real setup
# Workaround custom legacy Sony /init -> /(s)bin/init_sony : /init.real setup
INIT=init
if [ $((STATUS & 4)) -ne 0 ]; then
INIT=init.real
@ -153,24 +152,26 @@ ui_print "- Patching ramdisk"
# Compress to save precious ramdisk space
SKIP32="#"
SKIP64="#"
if [ -f magisk32 ]; then
$BOOTMODE && [ -z "$RULESDEVICE" ] && RULESDEVICE=$(./magisk32 --rules-device)
./magiskboot compress=xz magisk32 magisk32.xz
unset SKIP32
fi
if [ -f magisk64 ]; then
$BOOTMODE && [ -z "$RULESDEVICE" ] && RULESDEVICE=$(./magisk64 --rules-device)
$BOOTMODE && [ -z "$PREINITDEVICE" ] && PREINITDEVICE=$(./magisk64 --preinit-device)
./magiskboot compress=xz magisk64 magisk64.xz
unset SKIP64
fi
if [ -f magisk32 ]; then
$BOOTMODE && [ -z "$PREINITDEVICE" ] && PREINITDEVICE=$(./magisk32 --preinit-device)
./magiskboot compress=xz magisk32 magisk32.xz
unset SKIP32
fi
./magiskboot compress=xz stub.apk stub.xz
echo "KEEPVERITY=$KEEPVERITY" > config
echo "KEEPFORCEENCRYPT=$KEEPFORCEENCRYPT" >> config
echo "PATCHVBMETAFLAG=$PATCHVBMETAFLAG" >> config
echo "RECOVERYMODE=$RECOVERYMODE" >> config
[ -n "$RULESDEVICE" ] && ui_print "- Rules partition device ID: $RULESDEVICE"
[ -n "$RULESDEVICE" ] && echo "RULESDEVICE=$RULESDEVICE" >> config
if [ -n "$PREINITDEVICE" ]; then
ui_print "- Pre-init storage partition device ID: $PREINITDEVICE"
echo "PREINITDEVICE=$PREINITDEVICE" >> config
fi
[ -n "$SHA1" ] && echo "SHA1=$SHA1" >> config
./magiskboot cpio ramdisk.cpio \

View File

@ -49,7 +49,7 @@ getvar() {
local VARNAME=$1
local VALUE
local PROPPATH='/data/.magisk /cache/.magisk'
[ ! -z $MAGISKTMP ] && PROPPATH="$MAGISKTMP/config $PROPPATH"
[ ! -z $MAGISKTMP ] && PROPPATH="$MAGISKTMP/.magisk/config $PROPPATH"
VALUE=$(grep_prop $VARNAME $PROPPATH)
[ ! -z $VALUE ] && eval $VARNAME=\$VALUE
}
@ -629,7 +629,7 @@ run_migrations() {
done
}
copy_rules() {
copy_preinit_files() {
local RULESDIR=$(magisk --path)/.magisk/rules
if ! grep -q " $RULESDIR " /proc/mounts; then
ui_print "- Unable to find rules dir"
@ -785,10 +785,10 @@ install_module() {
cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop
fi
# Copy over custom rules
# Copy over custom sepolicy rules
if [ -f $MODPATH/sepolicy.rule ]; then
ui_print "- Installing custom sepolicy rules"
copy_rules
copy_preinit_files
fi
# Remove stuff that doesn't belong to modules and clean up any empty directories