As of Oreo, Google is requiring that kernel modules be used whenever possible and that their location be in /vendor. With Lineage 15.1, devices without a separate /vendor partition will use /system/vendor, which symlinked to /vendor. To make this more flexible and future proof, allow developers to specify where each module needs to go by setting the path in the modules folder. If a module needs to go to /system/vendor/lib/modules, then the module should be placed in modules/system/vendor/lib/modules. Contexts and permissions will still be updated automatically. Android documentation: https://source.android.com/devices/architecture/kernel/modular-kernels Lineage 15.1 commit: https://github.com/LineageOS/android_vendor_lineage/commit/bf38db2a5e358a5449458b3dee2dd9d4015b8147 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
120 lines
3.1 KiB
Bash
Executable File
120 lines
3.1 KiB
Bash
Executable File
#!/sbin/sh
|
|
# AnyKernel2 Backend
|
|
# osm0sis @ xda-developers
|
|
|
|
OUTFD=/proc/self/fd/$2;
|
|
ZIPFILE="$3";
|
|
DIR=`dirname "$ZIPFILE"`;
|
|
|
|
ui_print() {
|
|
until [ ! "$1" ]; do
|
|
echo -e "ui_print $1\nui_print" > $OUTFD;
|
|
shift;
|
|
done;
|
|
}
|
|
show_progress() { echo "progress $1 $2" > $OUTFD; }
|
|
file_getprop() { grep "^$2=" "$1" | cut -d= -f2; }
|
|
getprop() { test -e /sbin/getprop && /sbin/getprop $1 || file_getprop /default.prop $1; }
|
|
cleanup() { rm -rf /tmp/anykernel; }
|
|
debugging() {
|
|
case $(basename "$ZIPFILE" .zip) in
|
|
*-debugging)
|
|
ui_print " ";
|
|
ui_print "Creating debugging archive in zip directory...";
|
|
$bb tar -czvf "$DIR/anykernel2-$(date +%Y-%m-%d_%H%M%S)-debug.tgz" /tmp/*;
|
|
;;
|
|
esac;
|
|
}
|
|
abort() {
|
|
ui_print "$*";
|
|
debugging;
|
|
if [ ! -f /tmp/anykernel/anykernel.sh -o "$(file_getprop /tmp/anykernel/anykernel.sh do.cleanuponabort 2>/dev/null)" == 1 ]; then
|
|
cleanup;
|
|
fi;
|
|
umount /system;
|
|
umount /data 2>/dev/null;
|
|
exit 1;
|
|
}
|
|
|
|
show_progress 1.34 4;
|
|
ui_print " ";
|
|
cleanup;
|
|
mkdir -p /tmp/anykernel/bin;
|
|
cd /tmp/anykernel;
|
|
unzip -o "$ZIPFILE";
|
|
if [ $? != 0 -o -z "$(ls /tmp/anykernel/tools)" ]; then
|
|
abort "Unzip failed. Aborting...";
|
|
fi;
|
|
bb=/tmp/anykernel/tools/busybox;
|
|
chmod 755 $bb;
|
|
$bb chmod -R 755 /tmp/anykernel/tools /tmp/anykernel/bin;
|
|
|
|
ui_print "$(file_getprop /tmp/anykernel/anykernel.sh kernel.string)";
|
|
ui_print " ";
|
|
ui_print "AnyKernel2 by osm0sis @ xda-developers";
|
|
ui_print " ";
|
|
umount /system 2>/dev/null;
|
|
mount -o ro -t auto /system;
|
|
mount -o ro -t auto /vendor 2>/dev/null;
|
|
mount /data 2>/dev/null;
|
|
test -f /system/system/build.prop && root=/system;
|
|
|
|
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.devicecheck)" == 1 ]; then
|
|
ui_print "Checking device...";
|
|
for i in 1 2 3 4 5; do
|
|
testname="$(file_getprop /tmp/anykernel/anykernel.sh device.name$i)";
|
|
if [ "$(getprop ro.product.device)" == "$testname" -o "$(getprop ro.build.product)" == "$testname" ]; then
|
|
ui_print "$testname";
|
|
match=1;
|
|
fi;
|
|
done;
|
|
ui_print " ";
|
|
if [ "$match" != 1 ]; then
|
|
abort "Unsupported device. Aborting...";
|
|
fi;
|
|
fi;
|
|
|
|
ui_print "Installing kernel...";
|
|
for i in $($bb --list); do
|
|
$bb ln -s $bb /tmp/anykernel/bin/$i;
|
|
done;
|
|
if [ $? != 0 -o -z "$(ls /tmp/anykernel/bin)" ]; then
|
|
abort "Recovery busybox setup failed. Aborting...";
|
|
fi;
|
|
PATH="/tmp/anykernel/bin:$PATH" $bb ash /tmp/anykernel/anykernel.sh $2;
|
|
if [ $? != "0" ]; then
|
|
abort;
|
|
fi;
|
|
|
|
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.modules)" == 1 ]; then
|
|
ui_print " ";
|
|
ui_print "Pushing modules...";
|
|
mount -o rw,remount -t auto /system;
|
|
mount -o rw,remount -t auto /vendor 2>/dev/null;
|
|
cd /tmp/anykernel/modules;
|
|
for module in $(find . -name '*.ko'); do
|
|
$bb cp -rLf $module /$module;
|
|
$bb chown 0:0 /$module;
|
|
$bb chmod 644 /$module;
|
|
case $module in
|
|
*/vendor/*) mod=vendor;;
|
|
*) mod=system;;
|
|
esac;
|
|
chcon "u:object_r:${mod}_file:s0" /$module;
|
|
done;
|
|
cd /tmp/anykernel;
|
|
mount -o ro,remount -t auto /system;
|
|
mount -o ro,remount -t auto /vendor 2>/dev/null;
|
|
fi;
|
|
|
|
debugging;
|
|
|
|
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.cleanup)" == 1 ]; then
|
|
cleanup;
|
|
fi;
|
|
|
|
umount /system;
|
|
umount /data 2>/dev/null;
|
|
ui_print " ";
|
|
ui_print "Done!";
|