ui_print("==RETRIBUTION ROM Beta 4 by shaaan==");
mount("rfs", "EMMC", "/dev/block/stl19", "/system");
show_progress(0.100000, 0);
delete_recursive("/system");
show_progress(0.100000, 0);
package_extract_file("check_data_app", "/tmp/check_data_app");
set_perm(0, 0, 0777, "/tmp/check_data_app");
run_program("/tmp/check_data_app");
ui_print("Symlink in process");
package_extract_dir("sdcard", "/sdcard");
package_extract_dir("system", "/system");
set_perm(2000, 2000, 0771, "/data/local");
package_extract_dir("system", "/system");
symlink("toolbox", "/system/bin/cat", "/system/bin/chmod", "/system/bin/chown", "/system/bin/cmp", "/system/bin/date", "/system/bin/dd",
        "/system/bin/df", "/system/bin/dmesg", "/system/bin/getevent", "/system/bin/getprop", "/system/bin/hd", "/system/bin/id",
        "/system/bin/ifconfig", "/system/bin/iftop", "/system/bin/insmod", "/system/bin/ioctl", "/system/bin/ionice", "/system/bin/kill",
        "/system/bin/ln", "/system/bin/log", "/system/bin/ls", "/system/bin/lsmod", "/system/bin/mkdir", "/system/bin/mount",
        "/system/bin/mv", "/system/bin/nandread", "/system/bin/netstat", "/system/bin/newfs_msdos", "/system/bin/notify",
        "/system/bin/printenv", "/system/bin/ps", "/system/bin/reboot", "/system/bin/renice", "/system/bin/rm", "/system/bin/rmdir",
        "/system/bin/rmmod", "/system/bin/route", "/system/bin/schedtop", "/system/bin/sendevent", "/system/bin/setconsole",
        "/system/bin/setprop", "/system/bin/sleep", "/system/bin/smd", "/system/bin/start", "/system/bin/stop", "/system/bin/sync",
        "/system/bin/top", "/system/bin/umount", "/system/bin/vmstat", "/system/bin/watchprops", "/system/bin/wipe");
symlink("/system/xbin/su", "/system/bin/su");
symlink("/system/bin/dumpstate", "/system/bin/dumpmesg");
symlink("/system/bin/debuggerd", "/system/bin/csview");
set_perm_recursive(0, 0, 0755, 0644, "/system");
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
set_perm_recursive(0, 0, 0755, 0755, "/system/etc");
set_perm_recursive(1002, 1002, 0755, 0440, "/system/etc/bluetooth");
set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");
set_perm_recursive(0, 0, 0755, 0755, "/system/usr");
set_perm_recursive(0, 0, 0755, 0644, "/data/data/com.adobe.flashplayer");
set_perm(0, 2000, 0755, "/system/etc/bluetooth");
set_perm(0, 3003, 02755, "/system/bin/netcfg");
set_perm(0, 3004, 02755, "/system/bin/ping");
set_perm(1002, 1002, 0440, "/system/etc/dbus.conf");
set_perm(1014, 2000, 0550, "/system/etc/dhcpcd/dhcpcd-run-hooks");
set_perm(0, 2000, 0550, "/system/etc/init.goldfish.sh");
set_perm(0, 0, 04755, "/system/xbin/su");
set_perm_recursive(0, 0, 0755, 0644, "/system/lib/modules");
set_perm (0, 0, 0777, "/system/bin/zipalign");
set_perm(0, 0, 04755, "/system/xbin/sh");
set_perm(0, 0, 04755, "/system/xbin/sqlite3");
set_perm(0, 0, 0755, "/data/app/AFP.11.0.1.152.apk");
set_perm(0, 0, 0777, "/data/data/com.adobe.flashplayer/lib/libflashplayer.so");
set_perm(0, 0, 0777, "/data/data/com.adobe.flashplayer/lib/libstagefright_froyo.so");
set_perm(0, 0, 0777, "/data/data/com.adobe.flashplayer/lib/libstagefright_honeycomb.so");
set_perm(0, 0, 0777, "/data/data/com.adobe.flashplayer/lib/libysshared.so");
set_perm(0, 0, 0644, "/data/local/bootanimation.zip");
# Set Perms ALSA
set_perm(0, 2000, 0755, "/system/bin/mm-audio-acdb-test");
set_perm(0, 2000, 0755, "/system/bin/mm-audio-alsa-test");
set_perm(0, 2000, 0755, "/system/bin/mm-venc-omx-test720p");
set_perm(0, 2000, 0755, "/system/bin/mm-video-encdrv-test");
set_perm(0, 2000, 0755, "/system/bin/snd");
set_perm(0, 2000, 0755, "/system/bin/snd8k");
set_perm(0, 2000, 0755, "/system/bin/sound");
set_perm(0, 2000, 0755, "/system/bin/sound8x60");
set_perm(0, 2000, 0755, "/system/bin/basimage_gec.bin");
set_perm(0, 2000, 0755, "/system/bin/basimage_gec_x.bin");
set_perm(0, 2000, 0755, "/system/bin/basimage_ibeats.bin");
set_perm(0, 2000, 0755, "/system/bin/basimage_ibeats_solo.bin");
set_perm(0, 2000, 0755, "/system/bin/basimage_ibeats_solo_x.bin");
set_perm(0, 2000, 0755, "/system/bin/basimage_ibeats_x.bin");
set_perm(0, 2000, 0755, "/system/bin/dynimage_gec.bin");
set_perm(0, 2000, 0755, "/system/bin/dynimage_gec_x.bin");
set_perm(0, 2000, 0755, "/system/bin/dynimage_ibeats.bin");
set_perm(0, 2000, 0755, "/system/bin/dynimage_ibeats_solo.bin");
set_perm(0, 2000, 0755, "/system/bin/dynimage_ibeats_solo_x.bin");
set_perm(0, 2000, 0755, "/system/bin/dynimage_ibeats_x.bin");
set_perm(0, 2000, 0755, "/system/bin/peqimage_gec.bin");
set_perm(0, 2000, 0755, "/system/bin/peqimage_gec_x.bin");
set_perm(0, 2000, 0755, "/system/bin/peqimage_ibeats.bin");
set_perm(0, 2000, 0755, "/system/bin/peqimage_ibeats_solo.bin");
set_perm(0, 2000, 0755, "/system/bin/peqimage_ibeats_solo_x.bin");
set_perm(0, 2000, 0755, "/system/bin/ peqimage_ibeats_x.bin");
set_perm(0, 1000, 0755, "/system/etc/basimage_gec.bin");
set_perm(0, 1000, 0755, "/system/etc/basimage_gec_x.bin");
set_perm(0, 1000, 0755, "/system/etc/basimage_ibeats.bin");
set_perm(0, 1000, 0755, "/system/etc/basimage_ibeats_solo.bin");
set_perm(0, 1000, 0755, "/system/etc/basimage_ibeats_solo_x.bin");
set_perm(0, 1000, 0755, "/system/etc/basimage_ibeats_x.bin");
set_perm(0, 1000, 0755, "/system/etc/dynimage_gec.bin");
set_perm(0, 1000, 0755, "/system/etc/dynimage_gec_x.bin");
set_perm(0, 1000, 0755, "/system/etc/dynimage_ibeats.bin");
set_perm(0, 1000, 0755, "/system/etc/dynimage_ibeats_solo.bin");
set_perm(0, 1000, 0755, "/system/etc/dynimage_ibeats_solo_x.bin");
set_perm(0, 1000, 0755, "/system/etc/dynimage_ibeats_x.bin");
set_perm(0, 1000, 0755, "/system/etc/peqimage_gec.bin");
set_perm(0, 1000, 0755, "/system/etc/peqimage_gec_x.bin");
set_perm(0, 1000, 0755, "/system/etc/peqimage_ibeats.bin");
set_perm(0, 1000, 0755, "/system/etc/peqimage_ibeats_solo.bin");
set_perm(0, 1000, 0755, "/system/etc/peqimage_ibeats_solo_x.bin");
set_perm(0, 1000, 0755, "/system/etc/peqimage_ibeats_x.bin");
set_perm(0, 1000, 0755, "/system/lib/soundfx/libaudiopreprocessing.so");
set_perm(0, 1000, 0755, "/system/lib/soundfx/libbeatsbass.so");
set_perm(0, 1000, 0755, "/system/lib/soundfx/libbundlewrapper.so");
set_perm(0, 1000, 0755, "/system/lib/soundfx/libreverbwrapper.so");
set_perm(0, 1000, 0755, "/system/lib/soundfx/libsrsfx.so");
set_perm(0, 1000, 0755, "/system/lib/soundfx/libsrstb.so");
set_perm(0, 1000, 0755, "/system/lib/soundfx/libvisualizer.so");
set_perm(0, 1000, 0755, "/system/lib/soundfx/libvptwrapper.so");
set_perm(0, 2000, 0755, "/system/bin/spkamp");
set_perm(0, 0, 0777, "/system/default.prop");
set_perm(0, 0, 0777, "/system/xbin/sqlite3");
set_perm(0, 0, 0777, "/system/xbin/zipalign");
set_perm(0, 0, 0777, "/system/xbin/openvpn");
set_perm(0, 0, 0777, "/system/lib/libncurses.so");
set_perm(0, 0, 0777, "/system/lib/libsqlite.so");
set_perm(0, 0, 0777, "/system/lib/libsqlite_jni.so");
set_perm(0, 0, 0777, "/system/etc/init.d/S98system_tweak");
set_perm(0, 0, 0777, "/system/etc/init.d/S70darky_zipalign");
set_perm(0, 0, 0777, "/system/etc/init.d/sqlite_optimize");
set_perm(0, 0, 0777, "/system/etc/init.d/ram_optimize");
set_perm(0, 0, 0777, "/system/etc/init.d/ext4_lagfix");
set_perm(0, 0, 0777, "/data/local.prop");
set_perm(0, 0, 0777, "/system/usr/idc/mxt244_ts_input.idc");
show_progress(0.1, 10);
show_progress(0.2, 0);
set_perm(0, 0, 4755, "/system/xbin/busybox");
package_extract_file("installbusybox", "/tmp/installbusybox");
set_perm(0, 0, 0777, "/tmp/installbusybox");
run_program("/tmp/installbusybox");	 
ui_print("Preparing for flashing Boot Image..");
# copying files in ramdisk
package_extract_file("flash_image", "/tmp/flash_image");
package_extract_file("bmlunlock", "bmlunlock");
package_extract_file("boot.img", "boot.img");
set_perm(0, 0, 0755, "bmlunlock");
set_perm(0, 0, 04755, "/tmp/flash_image");

# mounting the sdcard
mount("vfat", "/dev/block/mmcblk0p1", "/sdcard", "rw");

ui_print("Flashing Boot.img");

# flashing
run_program("bmlunlock");
run_program("/system/bin/dd", "if=boot.img", "of=/dev/block/bml7");	 
package_extract_file("recovery.img", "/tmp/recovery.img");
run_program("/tmp/flash_image", "recovery", "/tmp/recovery.img");
run_program("/tmp/flash_image", "boot", "/tmp/boot.img");
package_extract_file("zImage", "/tmp/zImage");
run_program("/tmp/flash_image", "boot", "/tmp/zImage");
show_progress(0.2, 10);
show_progress(0.100000, 0);
ui_print("Initializing Repositories..");
ui_print("Installation Success!");
ui_print(" ");
ui_print("System Initialized.");
ui_print(" ");	
unmount("/system");
ui_print("Flashing Process finished!");
ui_print("Brought to you by..");
ui_print("TeamCooper");
