AK3+Backend: introduce systemless kernel modules support
- with do.systemless prop enabled in anykernel.sh, will push the contents of modules/ to create a simple "ak3-helper" Magisk module, where testing on devices thus far shows it loads early enough that even replacement kernel object .ko modules will get loaded - the ak3-helper module info is populated from the kernel.string and parsed kernel version from the kernel being flashed, and if at boot time a different kernel is detected the module automatically removes itself before being loaded to avoid conflicts - since logical partitions and ext4-dedup on Android 10 now prevent mounting /system or /vendor rw under any circumstances, this feature gives kernel developers back the freedom they had before all this to improve kernel .ko modules, .conf files, etc. with the added bonus of it cleaning up after itself
This commit is contained in:
2 files changed
+69
-28
No files matched your search
@@ -140,6 +140,24 @@ abort() {
|
|||||||
fi;
|
fi;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
dump_moduleinfo() {
|
||||||
|
cat <<EOF > $1;
|
||||||
|
name=AK3 Helper Module
|
||||||
|
version=$($bb awk '{ print $3 }' $home/vertmp) $($bb grep -oE '#.[0-9]' $home/vertmp)
|
||||||
|
versionCode=1
|
||||||
|
author=AnyKernel3
|
||||||
|
description=$kernel_string
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
dump_moduleremover() {
|
||||||
|
cat <<EOF > $1;
|
||||||
|
#!/system/bin/sh
|
||||||
|
MODDIR=\${0%/*};
|
||||||
|
if [ "\$(cat /proc/version)" != "\$(cat \$MODDIR/version)" ]; then
|
||||||
|
rm -rf \$MODDIR;
|
||||||
|
fi;
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
show_progress 1.34 4;
|
show_progress 1.34 4;
|
||||||
ui_print " ";
|
ui_print " ";
|
||||||
@@ -174,7 +192,8 @@ if [ -f banner ]; then
|
|||||||
ui_print " " " ";
|
ui_print " " " ";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
ui_print "$(file_getprop anykernel.sh kernel.string)";
|
kernel_string="$(file_getprop anykernel.sh kernel.string)";
|
||||||
|
ui_print "$kernel_string";
|
||||||
if [ -f version ]; then
|
if [ -f version ]; then
|
||||||
ui_print " ";
|
ui_print " ";
|
||||||
ui_printfile version;
|
ui_printfile version;
|
||||||
@@ -310,35 +329,54 @@ if [ $? != 0 ]; then
|
|||||||
fi;
|
fi;
|
||||||
|
|
||||||
if [ "$(file_getprop anykernel.sh do.modules)" == 1 ]; then
|
if [ "$(file_getprop anykernel.sh do.modules)" == 1 ]; then
|
||||||
ui_print " " "Pushing modules...";
|
if [ "$(file_getprop anykernel.sh do.systemless)" == 1 ]; then
|
||||||
$bb mount -o rw,remount -t auto /system;
|
cd $home/modules;
|
||||||
$bb mount -o rw,remount -t auto /vendor 2>/dev/null;
|
ui_print " " "Creating kernel helper Magisk module...";
|
||||||
cd $home/modules;
|
if [ -d /data/adb/magisk -a -f $home/split_img/.magisk ]; then
|
||||||
for module in $(find . -name '*.ko'); do
|
umask 022;
|
||||||
modtarget=$(echo $module | $bb cut -c2-);
|
moddir=/data/adb/modules/ak3-helper;
|
||||||
if [ ! -e $modtarget ]; then
|
rm -rf $moddir;
|
||||||
case $module in
|
mkdir -p system $moddir;
|
||||||
*/vendor/*) modcon=vendor;;
|
($bb mv -f product system;
|
||||||
*) modcon=system;;
|
$bb mv -f vendor system) 2>/dev/null;
|
||||||
esac;
|
$bb cp -rLf * $moddir;
|
||||||
|
dump_moduleinfo $moddir/module.prop;
|
||||||
|
dump_moduleremover $moddir/post-fs-data.sh;
|
||||||
|
cp -f $home/vertmp $moddir/version;
|
||||||
|
else
|
||||||
|
ui_print "Magisk installation not found. Skipped!";
|
||||||
fi;
|
fi;
|
||||||
if is_mounted $modtarget; then
|
else
|
||||||
$bb mount -o rw,remount -t auto $modtarget;
|
cd $home/modules;
|
||||||
fi;
|
ui_print " " "Pushing modules...";
|
||||||
mkdir -p $(dirname $modtarget);
|
$bb mount -o rw,remount -t auto /system;
|
||||||
$bb cp -rLf $module $modtarget;
|
$bb mount -o rw,remount -t auto /vendor 2>/dev/null;
|
||||||
$bb chown 0:0 $modtarget;
|
for module in $(find . -name '*.ko'); do
|
||||||
$bb chmod 644 $modtarget;
|
modtarget=$(echo $module | $bb cut -c2-);
|
||||||
if [ "$modcon" ]; then
|
if [ ! -e $modtarget ]; then
|
||||||
chcon "u:object_r:${modcon}_file:s0" $modtarget;
|
case $module in
|
||||||
fi;
|
*/vendor/*) modcon=vendor;;
|
||||||
if is_mounted $modtarget; then
|
*) modcon=system;;
|
||||||
$bb mount -o ro,remount -t auto $modtarget;
|
esac;
|
||||||
fi;
|
fi;
|
||||||
done;
|
if is_mounted $modtarget; then
|
||||||
|
$bb mount -o rw,remount -t auto $modtarget;
|
||||||
|
fi;
|
||||||
|
mkdir -p $(dirname $modtarget);
|
||||||
|
$bb cp -rLf $module $modtarget;
|
||||||
|
$bb chown 0:0 $modtarget;
|
||||||
|
$bb chmod 644 $modtarget;
|
||||||
|
if [ "$modcon" ]; then
|
||||||
|
chcon "u:object_r:${modcon}_file:s0" $modtarget;
|
||||||
|
fi;
|
||||||
|
if is_mounted $modtarget; then
|
||||||
|
$bb mount -o ro,remount -t auto $modtarget;
|
||||||
|
fi;
|
||||||
|
done;
|
||||||
|
$bb mount -o ro,remount -t auto /system;
|
||||||
|
$bb mount -o ro,remount -t auto /vendor 2>/dev/null;
|
||||||
|
fi;
|
||||||
cd $home;
|
cd $home;
|
||||||
$bb mount -o ro,remount -t auto /system;
|
|
||||||
$bb mount -o ro,remount -t auto /vendor 2>/dev/null;
|
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
debugging;
|
debugging;
|
||||||
|
|||||||
@@ -326,6 +326,9 @@ flash_boot() {
|
|||||||
$comp -dc $kernel > kernel;
|
$comp -dc $kernel > kernel;
|
||||||
fi;
|
fi;
|
||||||
$bin/magiskboot hexpatch kernel 736B69705F696E697472616D667300 77616E745F696E697472616D667300;
|
$bin/magiskboot hexpatch kernel 736B69705F696E697472616D667300 77616E745F696E697472616D667300;
|
||||||
|
if [ "$(file_getprop $home/anykernel.sh do.systemless)" == 1 ]; then
|
||||||
|
strings kernel | grep -E 'Linux version.*#' > $home/vertmp;
|
||||||
|
fi;
|
||||||
if [ "$comp" ]; then
|
if [ "$comp" ]; then
|
||||||
$bin/magiskboot compress=$comp kernel kernel.$comp;
|
$bin/magiskboot compress=$comp kernel kernel.$comp;
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
|
|||||||
Reference in new issue
Block a user