##################################################
show_progress(0.1, 10);
ui_print("formating Kernel...");
format("MTD", "KERNEL:");
show_progress(0.1, 10);
ui_print("write_kernel_image uImage...");
write_kernel_image("uImage", "KERNEL:" );

show_progress(0.1, 10);
ui_print("formating Ramdisk...");
format("MTD", "RAMDISK:");
show_progress(0.1, 10);
ui_print("write_ramdisk_image uramdisk.img...");
write_ramdisk_image("uramdisk.img", "RAMDISK:" );
show_progress(0.1, 10);
##################################################

# format and copy system image.
ui_print("formating SYSTEM...");
format("MTD", "SYSTEM:");
mount("MTD", "SYSTEM:", "");
show_progress(0.1, 10);
ui_print("copying files to SYSTEM...");
package_extract_dir("system", "SYSTEM:/system/");
show_progress(0.1, 10);

##################################################
# permimissions...
ui_print("Symlinks and permissions...");
symlink("toolbox", "/system/bin/ionice","/system/bin/nandread");
set_perm_recursive(0, 0, 0755, 0644, "/system");
show_progress(0.1, 10);
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
set_perm(0, 3003, 02750, "/system/bin/netcfg");
set_perm(0, 3004, 02755, "/system/bin/ping");
set_perm(0, 2000, 06750, "/system/bin/run-as");
set_perm_recursive(1002, 1002, 0755, 0440, "/system/etc/bluetooth");
show_progress(0.1, 10);
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(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, 0544, "/system/etc/install-recovery.sh");

set_perm(0, 0, 0755, "/system/etc/init.gprs-pppd");
set_perm_recursive(0, 0, 0755, 0755, "/system/etc/modem");
set_perm_recursive(0, 0, 0755, 0755, "/system/etc/ppp");

show_progress(0.1, 10);
unmount("/system");


