- fix insert_line to perform more as expected by adding a newline automatically - add updated arm mkbootimg+unpackbootimg binaries from my AIK Build Farm, see my repos for changes - rewrite backend to use proper exit codes from anykernel.sh now that it is shell - fix ui_print and specific error messages by passing the outfd to anykernel.sh from the backend - add error messages for unpacking and repacking ramdisk, and make resulting image size check into its own error message - fix for cpio overwriting AK2 ramdisk files on some recoveries by using a tmp directory - add further ramdisk unpack verification by checking that there are actually files in the ramdisk directory prior to moving the tmp files back - add insert_file function to make multi-line additions easier - add patch_fstab function to greatly simplify mount option/flag changes (thanks @Khaon for the idea)
84 lines
2.1 KiB
Bash
Executable File
84 lines
2.1 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 "$*"; exit 1; }
|
|
|
|
show_progress 1.34 4;
|
|
ui_print " ";
|
|
mkdir -p /tmp/anykernel;
|
|
cd /tmp/anykernel;
|
|
unzip -o "$ZIP";
|
|
|
|
ui_print "$(file_getprop /tmp/anykernel/anykernel.sh kernel.string)";
|
|
ui_print " ";
|
|
ui_print "AnyKernel2 by osm0sis @ xda-developers";
|
|
ui_print " ";
|
|
/sbin/busybox mount /system;
|
|
|
|
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.devicecheck)" == 1 ]; then
|
|
ui_print "Checking device...";
|
|
ui_print " ";
|
|
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
|
|
match=1;
|
|
fi;
|
|
done;
|
|
if [ "$match" != 1 ]; then
|
|
umount /system;
|
|
abort "Unsupported device. Aborting...";
|
|
fi;
|
|
fi;
|
|
|
|
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.initd)" == 1 ]; then
|
|
ui_print "Creating init.d...";
|
|
ui_print " ";
|
|
mkdir /system/etc/init.d;
|
|
set_perm_recursive 0 0 0755 0755 /system/etc/init.d;
|
|
fi;
|
|
|
|
ui_print "Installing kernel...";
|
|
/sbin/sh /tmp/anykernel/anykernel.sh $2;
|
|
if [ $? != "0" ]; then
|
|
umount /system;
|
|
abort;
|
|
fi;
|
|
|
|
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.modules)" == 1 ]; then
|
|
ui_print "Pushing modules...";
|
|
ui_print " ";
|
|
cp -f /tmp/anykernel/modules/* /system/lib/modules/;
|
|
set_perm_recursive 0 0 0755 0644 /system/lib/modules;
|
|
fi;
|
|
|
|
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.cleanup)" == 1 ]; then
|
|
rm -rf /tmp/anykernel;
|
|
fi;
|
|
|
|
umount /system;
|
|
ui_print " ";
|
|
ui_print "Done!";
|
|
|