1. Download our Official Android App: Forums for Android!

Root Edify Script Language Reference (updater-script)

Discussion in 'Android Devices' started by Koumajutsu, May 31, 2012.

  1. Koumajutsu

    Koumajutsu Android Expert
    Thread Starter
    Rank:
    None
    Points:
    313
    Posts:
    1,446
    Joined:
    Aug 26, 2011

    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))
     

    Advertisement

  2. kolosus

    kolosus Android Expert
    Rank:
    None
    Points:
    113
    Posts:
    923
    Joined:
    Oct 12, 2010

    Oct 12, 2010
    923
    341
    113
    PA/NJ Usa
    Holy compilation Batman! I'm pretty sure that this is a more complete list than can be found anywhere! This needs to be stickied in the CWM forum!
     
  3. Lordvincent 90

    Lordvincent 90 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
    Rank:
    None
    Points:
    583
    Posts:
    5,559
    Joined:
    Oct 5, 2011

    Oct 5, 2011
    5,559
    4,445
    583
    Male
    entertainer
    grand rapids,mi
    very nice write up. thanks bro :)
     
  4. fcortes626

    fcortes626 Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    442
    Joined:
    Jul 28, 2011

    Jul 28, 2011
    442
    67
    53
    FedEx and Auto tech student
    Los Angeles
    i was just looking for something like this. thanks
     
  5. Yogesh1969

    Yogesh1969 Newbie
    Rank:
    None
    Points:
    15
    Posts:
    11
    Joined:
    Dec 17, 2012

    Dec 17, 2012
    11
    0
    15
    I agree. Looks quite good!!
     
  6. wetbiker7

    wetbiker7 Extreme Android User
    Rank:
    None
    Points:
    333
    Posts:
    7,475
    Joined:
    Jun 27, 2011

    Jun 27, 2011
    7,475
    3,426
    333
    Male
    USN Vet. / Certified Drug and Alcohol Abuse Counse
    So-Cal
    Nice Kouma.
     
  7. out of ideas

    out of ideas Android Enthusiast
    Rank:
    None
    Points:
    93
    Posts:
    640
    Joined:
    May 19, 2012

    May 19, 2012
    640
    145
    93
    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

    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.
     
    Koumajutsu likes this.
  8. ppires

    ppires Lurker
    Rank:
    None
    Points:
    6
    Posts:
    1
    Joined:
    Jan 18, 2013

    Jan 18, 2013
    1
    3
    6
    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]
     
    AnimiAK, beezlewaxin and Koumajutsu like this.
  9. Hawker

    Hawker Android Expert
    Rank:
     #47
    Points:
    433
    Posts:
    4,096
    Joined:
    Aug 2, 2011

    Aug 2, 2011
    4,096
    1,911
    433
    Male
    UK
    Good write up mate.

    Any ideas anyone on how to use the ui_print command in a CWM script to do the following:

    1. ui_print a string without forcing a newline (eg. as in echo -n "123")
    2. ui_print a carriage return in the text (eg. as in echo -e "1\r2\r3")
     

Share This Page

Loading...