show_progress(0.900000, 16);
format("yaffs2", "MTD", "system");
mount("yaffs2", "MTD", "system", "/system");
package_extract_dir("system", "/system");
symlink("/data/www/configs", "/system/marvell/www/configs");
symlink("/data/www/css", "/system/marvell/www/css");
symlink("/data/www/templates", "/system/marvell/www/templates");
symlink("/system/xbin/busybox", "/system/marvell/bin/busybox",
        "/system/marvell/tel/busybox");
symlink("busybox", "/system/xbin/[", "/system/xbin/[[",
        "/system/xbin/adjtimex", "/system/xbin/arp", "/system/xbin/arping",
        "/system/xbin/ash", "/system/xbin/awk", "/system/xbin/base64",
        "/system/xbin/basename", "/system/xbin/bbconfig", "/system/xbin/blkid",
        "/system/xbin/blockdev", "/system/xbin/brctl", "/system/xbin/bunzip2",
        "/system/xbin/bzcat", "/system/xbin/bzip2", "/system/xbin/cal",
        "/system/xbin/cat", "/system/xbin/catv", "/system/xbin/chattr",
        "/system/xbin/chgrp", "/system/xbin/chmod", "/system/xbin/chown",
        "/system/xbin/chpasswd", "/system/xbin/chroot", "/system/xbin/chrt",
        "/system/xbin/cksum", "/system/xbin/clear", "/system/xbin/cmp",
        "/system/xbin/comm", "/system/xbin/cp", "/system/xbin/cpio",
        "/system/xbin/crond", "/system/xbin/crontab", "/system/xbin/cryptpw",
        "/system/xbin/cttyhack", "/system/xbin/cut", "/system/xbin/date",
        "/system/xbin/dc", "/system/xbin/dd", "/system/xbin/delgroup",
        "/system/xbin/deluser", "/system/xbin/depmod", "/system/xbin/devmem",
        "/system/xbin/df", "/system/xbin/dhcprelay", "/system/xbin/diff",
        "/system/xbin/dirname", "/system/xbin/dmesg", "/system/xbin/dnsd",
        "/system/xbin/dnsdomainname", "/system/xbin/dos2unix",
        "/system/xbin/du", "/system/xbin/dumpleases", "/system/xbin/echo",
        "/system/xbin/ed", "/system/xbin/egrep", "/system/xbin/env",
        "/system/xbin/envdir", "/system/xbin/ether-wake", "/system/xbin/expand",
        "/system/xbin/expr", "/system/xbin/false", "/system/xbin/fdflush",
        "/system/xbin/fdisk", "/system/xbin/fgrep", "/system/xbin/find",
        "/system/xbin/flash_eraseall", "/system/xbin/flash_lock",
        "/system/xbin/flash_unlock", "/system/xbin/flashcp",
        "/system/xbin/flock", "/system/xbin/fold", "/system/xbin/free",
        "/system/xbin/freeramdisk", "/system/xbin/fsync", "/system/xbin/ftpd",
        "/system/xbin/ftpget", "/system/xbin/ftpput", "/system/xbin/fuser",
        "/system/xbin/getopt", "/system/xbin/getty", "/system/xbin/grep",
        "/system/xbin/groups", "/system/xbin/gunzip", "/system/xbin/gzip",
        "/system/xbin/halt", "/system/xbin/hd", "/system/xbin/head",
        "/system/xbin/hexdump", "/system/xbin/hostname", "/system/xbin/httpd",
        "/system/xbin/hwclock", "/system/xbin/id", "/system/xbin/ifconfig",
        "/system/xbin/ifdown", "/system/xbin/ifenslave", "/system/xbin/ifplugd",
        "/system/xbin/ifup", "/system/xbin/inetd", "/system/xbin/insmod",
        "/system/xbin/install", "/system/xbin/ionice", "/system/xbin/iostat",
        "/system/xbin/ip", "/system/xbin/ipaddr", "/system/xbin/ipcalc",
        "/system/xbin/ipcrm", "/system/xbin/ipcs", "/system/xbin/iplink",
        "/system/xbin/iproute", "/system/xbin/iprule", "/system/xbin/iptunnel",
        "/system/xbin/kill", "/system/xbin/killall", "/system/xbin/killall5",
        "/system/xbin/klogd", "/system/xbin/length", "/system/xbin/less",
        "/system/xbin/ln", "/system/xbin/logger", "/system/xbin/login",
        "/system/xbin/logread", "/system/xbin/losetup", "/system/xbin/ls",
        "/system/xbin/lsattr", "/system/xbin/lsmod", "/system/xbin/lsof",
        "/system/xbin/lspci", "/system/xbin/lsusb", "/system/xbin/lzcat",
        "/system/xbin/lzma", "/system/xbin/lzop", "/system/xbin/lzopcat",
        "/system/xbin/makedevs", "/system/xbin/man", "/system/xbin/md5sum",
        "/system/xbin/mdev", "/system/xbin/mesg", "/system/xbin/mkdir",
        "/system/xbin/mkdosfs", "/system/xbin/mke2fs", "/system/xbin/mkfifo",
        "/system/xbin/mkfs.ext2", "/system/xbin/mkfs.vfat",
        "/system/xbin/mknod", "/system/xbin/mkpasswd", "/system/xbin/mkswap",
        "/system/xbin/mktemp", "/system/xbin/modinfo", "/system/xbin/modprobe",
        "/system/xbin/more", "/system/xbin/mount", "/system/xbin/mountpoint",
        "/system/xbin/mpstat", "/system/xbin/mv", "/system/xbin/nameif",
        "/system/xbin/nanddump", "/system/xbin/nandwrite",
        "/system/xbin/netstat", "/system/xbin/nice", "/system/xbin/nmeter",
        "/system/xbin/nohup", "/system/xbin/nslookup", "/system/xbin/ntpd",
        "/system/xbin/od", "/system/xbin/passwd", "/system/xbin/patch",
        "/system/xbin/pgrep", "/system/xbin/pidof", "/system/xbin/ping",
        "/system/xbin/ping6", "/system/xbin/pkill", "/system/xbin/pmap",
        "/system/xbin/poweroff", "/system/xbin/printenv", "/system/xbin/printf",
        "/system/xbin/ps", "/system/xbin/pscan", "/system/xbin/pstree",
        "/system/xbin/pwd", "/system/xbin/pwdx", "/system/xbin/rdate",
        "/system/xbin/rdev", "/system/xbin/readlink",
        "/system/xbin/readprofile", "/system/xbin/realpath",
        "/system/xbin/reboot", "/system/xbin/renice", "/system/xbin/reset",
        "/system/xbin/resize", "/system/xbin/rev", "/system/xbin/rm",
        "/system/xbin/rmdir", "/system/xbin/rmmod", "/system/xbin/route",
        "/system/xbin/rtcwake", "/system/xbin/run-parts", "/system/xbin/rx",
        "/system/xbin/sed", "/system/xbin/seq", "/system/xbin/setconsole",
        "/system/xbin/setlogcons", "/system/xbin/setserial",
        "/system/xbin/setsid", "/system/xbin/setuidgid", "/system/xbin/sh",
        "/system/xbin/sha1sum", "/system/xbin/sha256sum",
        "/system/xbin/sha512sum", "/system/xbin/slattach", "/system/xbin/sleep",
        "/system/xbin/softlimit", "/system/xbin/sort", "/system/xbin/split",
        "/system/xbin/start-stop-daemon", "/system/xbin/stat",
        "/system/xbin/strings", "/system/xbin/stty", "/system/xbin/su",
        "/system/xbin/sulogin", "/system/xbin/sum", "/system/xbin/swapoff",
        "/system/xbin/swapon", "/system/xbin/switch_root", "/system/xbin/sync",
        "/system/xbin/sysctl", "/system/xbin/syslogd", "/system/xbin/tac",
        "/system/xbin/tail", "/system/xbin/tar", "/system/xbin/tcpsvd",
        "/system/xbin/tee", "/system/xbin/telnet", "/system/xbin/telnetd",
        "/system/xbin/test", "/system/xbin/tftp", "/system/xbin/tftpd",
        "/system/xbin/time", "/system/xbin/timeout", "/system/xbin/top",
        "/system/xbin/touch", "/system/xbin/tr", "/system/xbin/traceroute",
        "/system/xbin/traceroute6", "/system/xbin/true", "/system/xbin/tty",
        "/system/xbin/ttysize", "/system/xbin/tunctl", "/system/xbin/tune2fs",
        "/system/xbin/udhcpc", "/system/xbin/udhcpd", "/system/xbin/udpsvd",
        "/system/xbin/umount", "/system/xbin/uname", "/system/xbin/uncompress",
        "/system/xbin/unexpand", "/system/xbin/uniq", "/system/xbin/unix2dos",
        "/system/xbin/unlzma", "/system/xbin/unlzop", "/system/xbin/unxz",
        "/system/xbin/unzip", "/system/xbin/uptime", "/system/xbin/usleep",
        "/system/xbin/uudecode", "/system/xbin/uuencode",
        "/system/xbin/vconfig", "/system/xbin/vi", "/system/xbin/vlock",
        "/system/xbin/watch", "/system/xbin/wc", "/system/xbin/wget",
        "/system/xbin/which", "/system/xbin/whoami", "/system/xbin/xargs",
        "/system/xbin/xz", "/system/xbin/xzcat", "/system/xbin/yes",
        "/system/xbin/zcat",
        "/system/xbin/zcip");
symlink("ml_tool", "/system/marvell/tel/ml_fifo",
        "/system/marvell/tel/ml_ini", "/system/marvell/tel/ml_setid",
        "/system/marvell/tel/ml_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/lsof",
        "/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/uptime", "/system/bin/vmstat", "/system/bin/watchprops",
        "/system/bin/wipe");
set_perm_recursive(0, 1000, 0770, 0770, "/system");
set_perm(0, 0, 0755, "/system");
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
set_perm(0, 2000, 06750, "/system/bin/run-as");
set_perm(0, 0, 0744, "/system/build.prop");
set_perm_recursive(0, 0, 0755, 0744, "/system/etc");
set_perm(1002, 1002, 0440, "/system/etc/dbus.conf");
set_perm(0, 2000, 0550, "/system/etc/init.goldfish.sh");
set_perm_recursive(0, 0, 0755, 0744, "/system/lib");
set_perm_recursive(0, 1000, 0770, 0644, "/system/marvell/usr/sbin");
set_perm_recursive(0, 0, 0755, 0744, "/system/sbin");
set_perm_recursive(0, 0, 0755, 0744, "/system/usr");
set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");
set_perm(0, 0, 06755, "/system/xbin/busybox");
set_perm(0, 0, 06755, "/system/xbin/tcpdump");
unmount("/system");
show_progress(0.500000, 20);
ui_print("Writing /bootloader partition...");
ui_print("Writing u-boot.bin filename...");
assert(package_extract_file("u-boot.bin", "/tmp/uboot.img"),
       write_raw_image("/tmp/uboot.img", "uboot"),
       delete("/tmp/uboot.img"));
ui_print("Finish updating /bootloader!");
ui_print("Writing /obm partition...");
ui_print("Writing main_obm_itemp_toby_router.bin filename...");
assert(package_extract_file("main_obm_itemp_toby_router.bin", "/tmp/obm.img"),
       write_raw_image("/tmp/obm.img", "obm"),
       delete("/tmp/obm.img"));
ui_print("Finish updating /obm!");
ui_print("Writing /arbelbinary partition...");
ui_print("Writing Arbel_ESHEL.bin filename...");
assert(package_extract_file("Arbel_ESHEL.bin", "/tmp/arbelbinary.img"),
       write_raw_image("/tmp/arbelbinary.img", "arbelbinary"),
       delete("/tmp/arbelbinary.img"));
ui_print("Finish updating /arbelbinary!");
ui_print("Writing /msabinary partition...");
ui_print("Writing Eshel2_C0_MRAT_R8Tech_AI_M22_Flash.bin filename...");
assert(package_extract_file("Eshel2_C0_MRAT_R8Tech_AI_M22_Flash.bin", "/tmp/msabinary.img"),
       write_raw_image("/tmp/msabinary.img", "msabinary"),
       delete("/tmp/msabinary.img"));
ui_print("Finish updating /msabinary!");
ui_print("Writing /rfplugin partition...");
ui_print("Writing plugin_NABANDS_L201.bin filename...");
assert(package_extract_file("plugin_NABANDS_L201.bin", "/tmp/rfplugin.img"),
       write_raw_image("/tmp/rfplugin.img", "rfplugin"),
       delete("/tmp/rfplugin.img"));
ui_print("Finish updating /rfplugin!");
ui_print("Writing /rfplugin_alt partition...");
ui_print("Writing plugin_NEGEV2_EUBANDS_TRFMD.bin filename...");
assert(package_extract_file("plugin_NEGEV2_EUBANDS_TRFMD.bin", "/tmp/rfplugin_alt.img"),
       write_raw_image("/tmp/rfplugin_alt.img", "rfplugin_alt"),
       delete("/tmp/rfplugin_alt.img"));
ui_print("Finish updating /rfplugin_alt!");
ui_print("Writing /ramdisk partition...");
ui_print("Writing ramdisk.img filename...");
assert(package_extract_file("ramdisk.img", "/tmp/init.img"),
       write_raw_image("/tmp/init.img", "init"),
       delete("/tmp/init.img"));
ui_print("Finish updating /ramdisk!");
ui_print("Writing /kernel partition...");
ui_print("Writing zImage filename...");
assert(package_extract_file("zImage", "/tmp/kernel.img"),
       write_raw_image("/tmp/kernel.img", "kernel"),
       delete("/tmp/kernel.img"));
ui_print("Finish updating /kernel!");
format("yaffs2", "MTD", "NVMFS");
mount("yaffs2", "MTD", "NVMFS", "/nvm");
package_extract_dir("system/marvell/tel/nvm_org", "/nvm");
delete("/cache/MAKE_RAMDUMP");
format("yaffs2", "MTD", "userdata");
mount("yaffs2", "MTD", "userdata", "/data");
package_extract_dir("system/marvell/tel/data_org", "/data");
ui_print("Start wiping /misc partition...");
format("mtd", "MTD", "misc");
ui_print("Finish wiping /misc!");
ui_print("Writing /obm_recovery partition...");
ui_print("Writing backup_obm_itemp_toby_router.bin filename...");
package_extract_file("backup_obm_itemp_toby_router.bin", "/tmp/obm_recovery.img");
write_raw_image("/tmp/obm_recovery.img", "obm_recovery");
delete("/tmp/obm_recovery.img");
ui_print("Finish updating /obm_recovery!");
ui_print("Writing /uboot_recovery partition...");
ui_print("Writing u-boot_recovery.bin filename...");
package_extract_file("u-boot_recovery.bin", "/tmp/uboot_recovery.img");
write_raw_image("/tmp/uboot_recovery.img", "uboot_recovery");
delete("/tmp/uboot_recovery.img");
ui_print("Finish updating /uboot_recovery!");
ui_print("Writing /maintenance partition...");
ui_print("Writing zImage_maintenance filename...");
package_extract_file("zImage_maintenance", "/tmp/maintenance.img");
write_raw_image("/tmp/maintenance.img", "maintenance");
delete("/tmp/maintenance.img");
ui_print("Finish updating /maintenance!");
show_progress(0.100000, 1);
ui_print("All done, just reboot and enjoy!");
unmount("/data");
unmount("/nvm");
