ui_print(" ______________________________ ");
ui_print("|                              |");
ui_print("|  Kernel Cor Plenus[tm] v2.1  |");
ui_print("|          for S5570I          |"); 
ui_print("|______________________________|");
#
# Added GT-S5360 because the installation is failing when people
# try to install it over a ROM for the Galaxy Y.
assert(getprop("ro.product.device") == "GT-S5570I" || getprop("ro.build.product") == "GT-S5570I" || getprop("ro.product.device") == "GT-S5360" || getprop("ro.build.product") == "GT-S5360");
ui_print("|   Installation started....   |");
ui_print("|______________________________|");
#
# Mount /system. Only for S5570I
#
show_progress(0.34,2);
ui_print("| Mounting /system             |");
mount("rfs", "EMMC", "/dev/block/stl9", "/system");
#
# Remove bloatware
#
ui_print("| Removing bloatware           |");
delete("/system/app/Quickoffice.apk");
delete("/system/app/SamsungApps.apk");
delete("/system/app/SamsungAppsUNA3.apk");
delete("/system/app/mtv_android-1.7.5-20110629.apk");
#
# Unroot the ROM
#
ui_print("| Unrooting                    |");
delete("/system/bin/su");
delete("/system/xbin/su");
delete("/system/bin/busybox");
delete("/system/xbin/busybox");
delete("/system/xbin/su-v1");
delete("/system/xbin/su-v2");
delete("/system/xbin/su-v3");
delete("/system/app/suhax.apk");
delete("/system/app/SuperUser.apk");
delete("/system/app/Superuser.apk");
delete("/system/app/superuser.apk");
delete("/system/app/Supersu.apk");
delete("/system/app/Rootvalidator.apk");
sleep(1);
#
# Starts the real installation
#
ui_print("| Installing system components |");
show_progress(0.68,3);
#
# The sounds will be replaced with louder ones
# Also clean the modules and scripts. They may come from another kernel/ROM
#
delete_recursive("/system/media/audio/notifications");
delete_recursive("/system/media/audio/ringtones");
delete_recursive("/system/media/audio/alarms");
# Do not remove /system/media/audio/ui. Only one file gets updated
##################################################################
delete_recursive("/system/lib/modules");
delete_recursive("/system/etc/init.d");
#
package_extract_dir("system", "/system");
#
ui_print("| Setting permissions          |");
set_perm_recursive(0, 0, 0755, 0754, "/system/etc/init.d");
set_perm_recursive(0, 0, 0755, 0644, "/system/lib");
set_perm_recursive(0, 0, 0755, 0644, "/system/app");
set_perm_recursive(0, 0, 0755, 0755, "/system/xbin");
set_perm_recursive(0, 0, 0755, 0644, "/system/media");
set_perm_recursive(0, 0, 0755, 0644, "/system/csc");
set_perm_recursive(0, 0, 0755, 0755, "/system/etc/terminfo");
#
set_perm(0, 0, 0644, "/system/build.prop");
set_perm(0, 0, 0755, "/system/etc/bash.bashrc");
set_perm(0, 0, 0755, "/system/etc/profile");
#
# Switch sh with bash.
#
symlink("/system/xbin/bash", "/system/bin/sh");
set_perm(0, 0, 0755, "/system/xbin/bash");
#
# Keep sh0 as a backup. Not that it is really needed
set_perm(0, 0, 0755, "/system/bin/sh0");
#
# Fix su sticky bit permission
#
ui_print("| Rooting                      |");
set_perm(0, 0, 06755, "/system/xbin/su");
set_perm(0, 0, 06755, "/system/xbin/.su");
#
# Setup busybox applets. They are extra programs, must go to /system/xbin
#
run_program("/system/xbin/busybox","--install","-s","/system/xbin");
#
# copying files in ramdisk for flashing the kernel
#
show_progress(1.00,2);
ui_print("|______________________________|");
ui_print("|                              |");
ui_print("|      Flashing boot image     |");
package_extract_file("bmlunlock", "bmlunlock");
package_extract_file("boot.img", "boot.img");
set_perm(0, 0, 0755, "bmlunlock");
#
# flashing the kernel. Unlock the block device first
#
run_program("bmlunlock");
assert(run_program("/system/bin/dd", "if=boot.img", "of=/dev/block/bml7", "bs=4096"));
sleep(1);
set_progress(1.33);
#
ui_print("|______________________________|");
ui_print("|  Installation was Successful |");
ui_print("|      Reboot System Now !     |");
ui_print("|______________________________|");
ui_print("| By:   Miche1asso @ XDA       |");
ui_print("|       Michelasso             |");
ui_print("|           @ androidiani.com  |");
ui_print("|______________________________|");
sleep(3);
