[Motorola Atrix 2] deveshmanish:
This is a WIP.

Edify Scripting Commands

I came across the problem of creating flash-able ZIP files and Edify scripting and in the interests of sharing and helping this great community I would like to share what I have found and hopefully learn more through discussion, I certainly am no expert and am always willing to learn.

So I would like to try and put together a guide to Edify scripting commands and what their function is. I hope we can all collaborate to make this a helpful source of information to all budding devs...we all have to start somewhere right!?

***Please, if there are any mistakes in this post or if you can help by adding further info please post below, thanks***

If any of you have ever flashed a zip,ROM you most probably see things written on the recovery screen like wiping data,wiping cache or CM10 by so and so.You ever wonder how these things are written??

Well the answer is in Edify script.So all those of you who wanna learn how to do all that have to learn the commands used in Edify scripting.

Interested???

Ok lets begin...

Print text in the recovery during flashing process:

ui_print("Your text here");

ui_print(" ");

This simply prints a line of text in the recovery, it has no actual effect on the flashing process, if you want a blank line just leave a blank space as the second example.

Controlling the progress bar:

I believe I understand this correctly, if not please do post below with further clarification.

show_progress(0.000000, 0);

or

set_progress(0.000000);

You have two choices when controlling the progress bar, the first example allows you to define fractions of the progress bar and how long they will take to fill. The second example just allows you to specify that the bar fills to a certain fraction at whatever point during the flashing process.

The command is defined as:

For example the following code lines interspersed with your other commands would fill a fifth of the progress bar every five seconds:

show_progress(0.200000, 5);
ui_print(" ");
show_progress(0.200000, 5);
ui_print(" ");
show_progress(0.200000, 5);
ui_print(" ");
show_progress(0.200000, 5);
ui_print(" ");
show_progress(0.200000, 5);

This process will only complete if the script takes long enough to flash, therefore you need to be aware of what you are actually flashing and how long it will take when defining these values.

If you wish to just define a fraction without fill without a time scale you can use the following command:

set_progress(0.000000);

It is also best practice to include this element in your scripts as it will reassure people that their handset hasn't frozen during a flash.

Mounting/Unmounting a partition:

This has to be dealt with care as without mounting the required partition you can't do any modification.

To mount a partition you need to use the following syntax:

Example command would be:

mount("ext3", "EMMC", "/dev/block/mmcblk1p21", "/system");

To unmount a partition you need to input the following command:

unmount("/system");

Obviously replace the mount partition with whatever partition you are working in.

Format a partition:

To format a partition you need to use the following syntax:

Example:

format("ext3", "EMMC", "/dev/block/mmcblk1p21", "0");

Some scripts include the "0" and some do not, not sure exactly on the function difference when included or not, again clarification would be great.

Flashing the contents of your ZIP file:

To flash an entire directory i.e. to copy the contents of the entire directory from your zip into the respective folders in ROM:

package_extract_dir("system", "/system");

To flash a single file:

package_extract_file("youtube.apk", "/data");

These commands are structured as follows:

Entire directory:

Single File:

Deleting folders & files:

You can delete multiple folders or files using just one command, as follows:

To delete files:

delete("file-path-1", "file-path-2", "file-path-3);

To delete folders/directories:

delete_recursive("directory-path-1", "directory-path-2", "directory-path-3");

Setting Permissions

Here are the basics for setting permissions.

If you want to research the reasons behind this, there is some useful information on Linux permissions here: chmod wiki,

Set permissions of a file or set of files:

Example:

set_perm(0, 0, 06755, "/system/xbin/su");

Set permissions of a directory or set of directories and all files and folders within them:

Example:

set_perm_recursive(0, 0, 0755, 0644, "/system");

Permissions syntax explained...so I can understand it lol (if I do then anyone can!):

The following are the pre-defined Android UID's & GID's. Taken from the following link: Android UIDs and GIDs

You will need to also understand the way file permissions are represented:

Example = drwxrwxrwx

-Use Root Explorer to find the UID, GID, and permissions for a file. Permissions are the string that looks like some variation on 'rwxr-xr--' next to each file. Long press and choose "change owner" to get the UID and GID. You just want the number next to "owner" and "group", respectively.

-If you're replacing a file, look up these settings for the existing copy and use them. If you're adding a file, just find a file that does the same functions and copy what it has (for example, installing an app to /system/app? Just look at these settings for any other app in that directory).

-MODE is technically a 4-bit string, but the first character can be omitted. There doesn't seem to be any android file permissions with the first character set. For good practice, I think it's safe to assume you can always use a leading 0 unless you know otherwise for something specific. Or, just use a 3-digit MODE, which says to leave those settings as they are (disabled by default). (I.e. 0644=644).

The next 9 characters define the file permissions. These permissions are

given in groups of 3 each.

The first 3 characters are the permissions for the owner of the file or directory.

Example = -rwx------

The next 3 are permissions for the group that the file is owned by.

Example = ----rwx---

The final 3 characters define the access permissions for everyone not part of the group.

Example = -------rwx

There are 3 possible attributes that make up file access permissions.

r - Read permission. Whether the file may be read. In the case of a

directory* this would mean the ability to list the contents of the

directory.

w - Write permission. Whether the file may be written to or modified. For

a directory* this defines whether you can make any changes to the contents

of the directory. If write permission is not set then you will not be able

to delete* rename or create a file.

x - Execute permission. Whether the file may be executed. In the case of a

directory* this attribute decides whether you have permission to enter*

run a search through that directory or execute some program from that

directory

You set these permissions using the following binary based numerical system:

Code:

Default Linux permissions:

For Files:

"Read" means to be able to open and view the file

"Write" means to overwrite or modify the file

"eXecute" means to run the file as a binary

For Directories:

"Read" means to be able to view the contents of the directory

"Write" means to be able to create new files/directories within the directory

"eXecute" means to be able to "Change Directory" (cd) into the directory

Most of the time you set "Read" and "eXecute" together on directories (kind of useless when set by themselves)

Interestingly through further research it seems this system is based on the Octal Binary system...I may be wrong...

Further Commands:

In progress...

So, this is by no means an exhaustive list and I would appreciate it that if I have made any mistakes people make me aware in this thread and I can update this tutorial.

I would also like to add further commands and their uses, if people can provide more I will add them too.

I hope this helps people out! Many thanks!

Credits: wilskywalker for his guide from which I got the ideas and the knowledge.