[WIP] How to Write an Updater-Script with Edify Code
First and foremost I take no credit for the majority of this thread. I am merely posting this here as a reference for you all. I had to dig around a lot for this information and piece it together from several different threads as well as pull examples from updater-scripts in several different roms/theme/etc. Everyone else put in the work, I am just trying to make it easier for the rest of us

.
Mounting Partitions:
MTD:
Code:
mount("MTD", "system", "/system");
mount("MTD", "userdata", "/data");
mount("MTD", "cache", "/cache");
mount("MTD", "sdcard", "/sdcard");
EMMC with EXT3 and EXT4 file systems:
Code:
mount("ext4", "EMMC", "/dev/block/mountpoint", "/system");
mount("ext4", "EMMC", "/dev/block/mountpoint", "/data");
mount("ext4", "EMMC", "/dev/block/mountpoint", "/cache");
Code:
mount("ext3", "EMMC", "/dev/block/mountpoint", "/system");
mount("ext3", "EMMC", "/dev/block/mountpoint", "/data");
mount("ext3", "EMMC", "/dev/block/mountpoint", "/cache");
“mountpoint” will vary from device to device. Decide what partition you want to mount, find where it mounts (there will be resources in the second post, and paste it in place of “mountpoint” in your script.
Mounting system, data, and cache on the EVO 3D
Code:
mount("ext4", "EMMC", "/dev/block/mmcblk0p23", "/system");
mount("ext4", "EMMC", "/dev/block/mmcblk0p24", "/data");
mount("ext4", "EMMC", "/dev/block/mmcblk0p25", "/cache");
Amend
Unmounting Partitions:
MTD and EMMC:
Code:
unmount("/system");
unmount("/data"); OR unmount("/userdata");
unmount("/cache");
unmount("/sdcard");
Amend
Format Partitions:
MTD:
Code:
format("MTD", "system");
format("MTD", "cache");
format("MTD", "data");
format("MTD", "boot");
EMMC EXT3/4:
Code:
format("ext4", "EMMC", "/dev/block/mountpoint");
Code:
format("ext3", "EMMC", "/dev/block/mountpoint");
Formatting system, data, cache, and boot on EVO 3D.
Code:
format("ext4", "EMMC", "/dev/block/mmcblk0p23");
format("ext4", "EMMC", "/dev/block/mmcblk0p24");
format("ext4", "EMMC", "/dev/block/mmcblk0p25");
format("ext4", "EMMC", "/dev/block/mmcblk0p22");
Amend:
Code:
format SYSTEM:
format DATA:
format BOOT:
format CACHE:
Copy files from .zip file to phone partition or sd card:
Code:
package_extract_dir("Source", "Destination");
“Source” = folder in .zip file. "Destination" = partition to copy to,
Code:
package_extract_dir("system", "/system");
package_extract_dir("data", "/data");
package_extract_dir("sdcard", "/sdcard");
Amend:
Code:
copy_dir PACKAGE:system SYSTEM:
copy_dir PACKAGE:data DATA:
copy_dir PACKAGE:sdcard SDCARD:
Write an .img file:
MTD:
Code:
assert(package_extract_file("boot.img", "/tmp/boot.img"),
write_raw_image("/tmp/boot.img", "boot"),
delete("/tmp/boot.img"));
EMMC:
Code:
package_extract_file("boot.img", "/dev/block/mountpoint");
Amend
Code:
write_raw_image PACKAGE:boot.img BOOT:
Output a line of text:
MTD/EMMC:
Code:
ui_print("Text Here");
Amend
Delete a file:
Use delete for a single file. Use delete recursive for an entire folder.
Code:
delete_recursive("file/path");
Code:
delete("/path/to/file");
Amend
Code:
delete_recursive PARTITION:path/to/file
Code:
delete PARTITION:path/to/file
Set ownership and permissions for folder:
Code:
set_perm_recursive(uid, gid, dmode, fmode, “/path/to/folder”);
Amend
Code:
set_perm_recursive uid gid dmode fmode PARTITION:path
Set ownership and permissions for a file:
Code:
set_perm(uid, gid, mode, “/path/to/file”);
Amend
Code:
set_perm uid gid mode PARTITION:file
Run a program:
Code:
run_program("programtorun");
Amend
Code:
run_program PACKAGE:programtorun
Creating symlinks:
Code:
symlink("/path/to/file", "/path/tofile");
Amend
Code:
symlink /path/to/file PARTITION:path/to/file
Progress bar:
Code:
show_progress(fraction, duration);
Amend
Code:
show_progress fraction, duration