- fix copy of any subdirectories under modules/ - adjust display of modules installation text to match the others - add support for custom user scripts (at /data/custom_boot_image_patch.sh - same as latest SuperSU zips) to automatically execute before reflashing the rebuilt boot image for bump, loki etc. modifications
92 lines
2.5 KiB
Bash
Executable File
92 lines
2.5 KiB
Bash
Executable File
#!/sbin/sh
|
|
# AnyKernel2 Backend
|
|
# osm0sis @ xda-developers
|
|
|
|
OUTFD=/proc/self/fd/$2;
|
|
ZIP="$3";
|
|
DIR=`dirname "$ZIP"`;
|
|
|
|
ui_print() {
|
|
until [ ! "$1" ]; do
|
|
echo -e "ui_print $1\nui_print" > $OUTFD;
|
|
shift;
|
|
done;
|
|
}
|
|
show_progress() { echo "progress $1 $2" > $OUTFD; }
|
|
set_perm_recursive() {
|
|
dirs=$(echo $* | awk '{ print substr($0, index($0,$5)) }');
|
|
for i in $dirs; do
|
|
chown -R $1.$2 $i; chown -R $1:$2 $i;
|
|
find "$i" -type d -exec chmod $3 {} +;
|
|
find "$i" -type f -exec chmod $4 {} +;
|
|
done;
|
|
}
|
|
file_getprop() { grep "^$2" "$1" | cut -d= -f2; }
|
|
getprop() { test -e /sbin/getprop && /sbin/getprop $1 || file_getprop /default.prop $1; }
|
|
abort() { ui_print "$*"; umount /system; umount /data; exit 1; }
|
|
|
|
show_progress 1.34 4;
|
|
ui_print " ";
|
|
mkdir -p /tmp/anykernel;
|
|
cd /tmp/anykernel;
|
|
unzip -o "$ZIP";
|
|
if [ $? != 0 -o -z "$(ls /tmp/anykernel)" ]; then
|
|
abort "Unzip failed. Aborting...";
|
|
fi;
|
|
|
|
ui_print "$(file_getprop /tmp/anykernel/anykernel.sh kernel.string)";
|
|
ui_print " ";
|
|
ui_print "AnyKernel2 by osm0sis @ xda-developers";
|
|
ui_print " ";
|
|
/sbin/busybox mount -o ro /system;
|
|
/sbin/busybox mount /data;
|
|
|
|
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;
|
|
|
|
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.initd)" == 1 ]; then
|
|
ui_print "Creating init.d...";
|
|
ui_print " ";
|
|
/sbin/busybox mount -o remount,rw /system;
|
|
mkdir /system/etc/init.d;
|
|
set_perm_recursive 0 0 0755 0755 /system/etc/init.d;
|
|
/sbin/busybox mount -o remount,ro /system;
|
|
fi;
|
|
|
|
ui_print "Installing kernel...";
|
|
/sbin/sh /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...";
|
|
/sbin/busybox mount -o remount,rw /system;
|
|
cp -rf /tmp/anykernel/modules/* /system/lib/modules/;
|
|
set_perm_recursive 0 0 0755 0644 /system/lib/modules;
|
|
/sbin/busybox mount -o remount,ro /system;
|
|
fi;
|
|
|
|
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.cleanup)" == 1 ]; then
|
|
rm -rf /tmp/anykernel;
|
|
fi;
|
|
|
|
umount /system;
|
|
umount /data;
|
|
ui_print " ";
|
|
ui_print "Done!";
|
|
|