ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("");
ui_print("............................................");
ui_print(":                                          :");
ui_print(":                   Installing             :");
ui_print(":              ____  __  ___  ______       :");
ui_print(":             / __ \/  |/  /     /         :");
ui_print(":            / / / / /|_/ /     /          :"); 
ui_print(":           / /_/ / /  / /     /           :");
ui_print(":           \____/_/  /_/ /___/            :");
ui_print(":           ____  ____  __  ___            :");
ui_print(":          / __ \/ __ \/  |/  /            :");
ui_print(":         / /_/ / / / / /|_/ /             :"); 
ui_print(":        / _  _/ /_/ / /  / /              :");
ui_print(":       /_/ |_|\____/_/  /_/               :");
ui_print(":                                          :");
ui_print("............................................");
ui_print("");
ui_print("");
show_progress(0.1, 15);
ui_print("");
ui_print("Formatting CACHE Partition...");
unmount("/cache");
run_program("/sbin/erase_image", "cache");
format("ext4", "EMMC", "/dev/block/mmcblk0p25");
ui_print("Formatting DATA Partition...");
unmount("/data");
run_program("/sbin/erase_image", "userdata");
format("ext4", "EMMC", "/dev/block/mmcblk0p24");
ui_print("Formatting SYSTEM Partition...");
unmount("/system");
run_program("/sbin/erase_image", "system");
format("ext4", "EMMC", "/dev/block/mmcblk0p23");
ui_print("Formatting BOOT Partition...");
unmount("/boot");
run_program("/sbin/erase_image", "boot");
ui_print("Removing Old SYSTEM Files From SD Card...");
run_program("/sbin/busybox", "mount", "/sdcard");
delete_recursive("/sdcard/.android_secure");
delete_recursive("/sdcard/.bookmark_thumb1");
delete_recursive("/sdcard/.data/footprints");
delete_recursive("/sdcard/.data/mail");
delete_recursive("/sdcard/Android/data/com.android.providers.media");
delete_recursive("/sdcard/Android/data/com.google.android.apps.genie.geniewidget.news-content-cache");
delete_recursive("/sdcard/Android/data/com.google.android.apps.maps");
delete_recursive("/sdcard/.data/navigator/Data/Temporary");
delete_recursive("/sdcard/LazyList");
delete_recursive("/sdcard/LOST.DIR");
unmount("/sdcard");
ui_print("Extracting New DATA Files...");
mount("ext4", "EMMC", "/dev/block/mmcblk0p24", "/data");
show_progress(0.1, 10);
package_extract_dir("data", "/data");
ui_print("Extracting New SYSTEM Files...");
mount("ext4", "EMMC", "/dev/block/mmcblk0p23", "/system");
show_progress(0.84, 115);
package_extract_dir("system", "/system");
ui_print("Creating Symlinks...");
set_progress(0);
show_progress(0.1, 5);
symlink("dumpstate", "/system/bin/bugreport");
symlink("dumpstate", "/system/bin/dumpcrash");
symlink("toolbox", "/system/bin/cat", "/system/bin/cmp",
        "/system/bin/date", "/system/bin/dd", "/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/log", "/system/bin/lsmod",
        "/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/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/uptime",
        "/system/bin/vmstat", "/system/bin/watchprops",
        "/system/bin/wipe");
symlink("/system/bin/mksh", "/system/bin/sh");
symlink("/system/xbin/su", "/system/bin/su");
symlink("/proc/calibration", "/system/etc/calibration");
symlink("/system/xbin/sqlite3", "/system/bin/sqlite3");
ui_print("Installing Busybox...");
set_perm(0, 1000, 0755, "/system/xbin/busybox");
run_program("/system/xbin/busybox", "--install", "-s", "/system/xbin");
ui_print("Setting Permissions...");
show_progress(0.1, 5);
set_perm(1000, 1000, 0771, "/data");
set_perm_recursive(1000, 1000, 0771, 0644, "/data/app");
set_perm_recursive(1000, 1000, 0771, 0644, "/data/local");
set_perm_recursive(0, 0, 0755, 0644, "/system");
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
set_perm_recursive(1002, 1002, 0755, 0440, "/system/etc/bluetooth");
set_perm_recursive(1002, 1002, 0775, 0440, "/system/etc/bluez");
set_perm_recursive(0, 2000, 0755, 0755, "/system/etc/init.d");
set_perm_recursive(0, 0, 0755, 0555, "/system/etc/ppp");
set_perm_recursive(1000, 1000, 0771, 0644, "/system/mnt");
set_perm_recursive(0, 2000, 0755, 0644, "/system/vendor");
set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");
set_perm(0, 3003, 02750, "/system/bin/netcfg");
set_perm(0, 2000, 0775, "/system/bin/iptables");
set_perm(0, 0, 0775, "/system/etc/bluez");
set_perm(1000, 1000, 0755, "/system/xbin/openvpn");
set_perm(0, 3003, 0755, "/system/bin/ip");
set_perm(0, 3003, 0755, "/system/bin/ipd");
set_perm(0, 3003, 02755, "/system/bin/netcfg");
set_perm(0, 3003, 06755, "/system/bin/netd");
set_perm(0, 2000, 06755, "/system/bin/reboot");
set_perm(0, 2000, 06750, "/system/bin/run-as");
set_perm(0, 1000, 04750, "/system/bin/tc");
set_perm(0, 0, 06755, "/system/xbin/su");
set_perm(0, 0, 06755, "/system/bin/su");
set_perm(0, 0, 04755, "/system/bin/sh");
set_perm (0, 0, 0777, "/system/bin/sysinit");
set_perm (0, 0, 0777, "/system/bin/e2fsck");
set_perm (0, 0, 0777, "/system/bin/tune2fs");
set_perm(0, 0, 0755, "/system/etc/be_movie","/system/etc/be_photo");
set_perm(0, 0, 0755, "/system/etc/bluetooth");
set_perm(1000, 1000, 0640, "/system/etc/bluetooth/auto_pairing.conf");
set_perm(3002, 3002, 0444, "/system/etc/bluetooth/blacklist.conf");
set_perm(0, 0, 0644, "/system/etc/bluetooth/a2dp_avrcp.conf");
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, 2000, 0755, "/system/vendor");
set_perm(0, 2000, 0755, "/system/vendor/firmware");
set_perm(0, 0, 04755, "/system/etc/ppp/ip-up-vpn");
set_perm(1000, 1000, 0555, "/system/etc/init.qcom.sdio.sh");
set_perm(0, 0, 04755, "/system/xbin/busybox");
set_perm(0, 0, 04755, "/system/xbin/sqlite3");
set_perm (0, 0, 0777, "/system/xbin/zipalign");
set_perm(1000, 1000, 0755, "/system/xbin/openvpn");
set_perm(1000, 1000, 0755, "/system/xbin/sysro");
set_perm(1000, 1000, 0755, "/system/xbin/sysrw");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-r0-ri30.4a/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-rn30-ri30.5/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-rp30-ri30.5/full_model.bin");
set_perm(0, 0, 0644, "/system/vendor/pittpatt/models/recognition/face.face.y0-y0-22-b-N/full_model.bin");
show_progress(0.1, 10);
ui_print("Extracting BOOT Image...");
unmount("/cache");
run_program("/sbin/erase_image", "cache");
assert(package_extract_file("kernel/boot.img", "/tmp/boot.img"),
	write_raw_image("/tmp/boot.img", "boot"),
	delete("/tmp/boot.img"));
format("ext4", "EMMC", "/dev/block/mmcblk0p25");
ui_print("");
ui_print("Done. I hope you enjoy OMJ's ROM!");;
unmount("/system");
unmount("/data");
unmount("/cache");
sleep(1);
