• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Edify Script Language Reference (updater-script)

Koumajutsu

Android Expert
Aug 26, 2011
1,434
1,092
Needles, CA
www.paypal.com
OK, in the spirit of helping out my fellow modders, I took some time to sit down and read some of the sourcecode for the updater binary that goes in what we commonly refer to as CWM flash-able zips. I have compiled this list of commands for updater-script, a good bit taken directly from teh comments in the source itself, some from my own interpretation of the code.

I believe this is more complete than anything else I've been able to find from searching.

anyways, enjoy

mount(fs_type, partition_type, location, mount_point)
fs_type="yaffs2" partition_type="MTD" location=partition
fs_type="ext4" partition_type="EMMC" location=device
Returns mountpoint if successful

is_mounted(mount_point)
Returns mount_point if mounted

unmount(mount_point)
Returns mountpoint if successful

format(fs_type, partition_type, location)
fs_type="yaffs2" partition_type="MTD" location=partition
fs_type="ext4" partition_type="EMMC" location=device
Returns location if successful

show_progress(frac, sec)
update progress bar by 'frac' over 'sec' seconds
frac represents a double precision value from 0 = 0% to 1 = 100%
returns 'frac' as a string if successful

set_progress(frac)
set progress bar to 'frac'
returns 'frac' as a string if successful

delete(file1,...,fileN)
delete_recursive(file1,...,fileN)

delete files or folders recursively
returns a count of files or folders deleted

package_extract_dir(package_path, destination_path)
extract package_path from zip to destination_path
returns "t" if successful

package_extract_file(package_path, destination_path)
extract the file at package_path from zip to destination_path
returns "t" if successful
or
package_extract_file(package_path)
to return the entire contents of the file

symlink(target, src1 ...)
unlinks any previously existing src1, src2, etc before creating symlinks.
returns empty string

set_perm(uid,gid,mode,target)
set_perm_recursive(uid,gid,dirmode,filemode,target)

set file(s) user to uid, group to gid, and permissions to mode/filemode for files, and dirmode for directories
returns empty string

getprop(key)
returns value of key or "" if key is not defined

file_getprop(file, key)
interprets 'file' as a getprop-style file (key=value pairs, one
per line, # comment lines and blank lines okay), and returns the value
for 'key' (or "" if it isn't defined).

write_raw_image(file, partition)
writes the contents of file to MTD device: partition.
does not support EMMC devices
returns partition if successful

apply_patch(srcfile, tgtfile, tgtsha1, tgtsize, sha1_1, patch_1, ...)
apply srcfile to tgtfile patch_N .... you know what, this shit is rediculous and meant to save filespace in update.zips, I'm, skipping it and it's sha1 cousins

read_file(file)
return the contents of file

ui_print(msg1...)
concatenate arguments and display on screen

run_program(program)
or
run_program(program, arg1...)
run program with args
returns program exit status

Some items I skipped and why:

apply_patch
apply_patch_check
apply_patch_space
sha1_check

SHA1 stuff breaks my brain. This is all part of patching large files with lists of changes. Pretty useful for OTA updates where file sizes need to be kept small, but not as useful for the custom ROM community. If you absolutely NEED to use these, you either already know how to, or you can go read <android source directory>/bootable/recovery/updater/install.c and its defined includes


What the "Returns..." stuff means:
In theory, you should be able to use one command as an argument for another, leading to more complex, powerful updater-scripts.
I.E:
mount(getprop(systemfstype),getprop(systemparttype),unmount(getprop(systempart)),getprop(systemmountpoint))
 
cool write up.

In case anyone runs into problems with number of mount arguments. Id like to just mention this.

I had this problem when using the 4 arguments for mounting, it wouldn't mount. cwm returned an error expecting three arguments. This is because different update-binaries take different numbers. also, the syntax changes, for instance when mounting yaffs2, you drop the "yaffs2" part.

here's a thread where I found the answer. [solved] [FIX] updater-script expected arguments | Android

>>> ** For future reference, it is the update-binary causing problems! Replace it with a binary from another build that takes format and mounts commands in the correct amount of arguments. ** <<<

The binary from the Desire HD takes:

-3 arguments for format
EX: format("MTD", "yaffs2", "system");

- and 4 arguments for mount
EX: mount ("MTD", "yaffs2", "system", "/system");

meanwhile, in AOSP, the update-binary takes

-2 arguments for format
EX: format("MTD", "system");

- and 3 arguments for mount
EX: mount("MTD", "system", "/system");
sorry to clutter, but that little problem drove me nuts for days and I wish someone posted it over here. So hopefully that can save someone a headache.

thanks kouma.
 
  • Like
Reactions: Koumajutsu
Upvote 0
Just adding another function:

ifelse(condition, (commands if true), (commands if false));
If the condition evaluates to true, the first block of code is executed.
Otherwise, the second is executed.
Eg.:
[HIGH]ifelse(package_extract_dir("system", "/system") == "t",
(
ui_print("extracted!");
),
(
ui_print("failed to extract...");
)
);[/HIGH]
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones