[Android] TheRoyalSeeker:
Disclaimer

I will not be responsible if you screw up with your device.

Do make a Nandroid backup first.

Before we start

Downloads

WinRAR

Notepad++

Template Zip

Lets get started

I have provided you with the template zip inside which by making changes we can create our flashable zips. All necessary files are inside Template zip

Open up the template zip. There you will see two folders "META-INF" and "system". [In "META-INF" all the coding stuff resides and in "system" all your apps and media files resides.]

META-INF

In META-INF have one folder "com" and three files [We don't have to edit these three files]

Now open "com" folder and inside it open "google" folder then "android" folder.

Now inside "android" folder you will see two files "update-binary" [We don't have to edit this file, leave it as it is.] and "updater-script"[It is the file which is used to tell custom recovery what to do with the flashable zip ].

We have to edit "updater-script" file by using notepad++. [Scroll below to see how to edit updater-script]

System Folder

It is the folder where all of your apks, zips, libs reside.

Inside System Folder make folders as following:

If you want to flash an app and make it system app create "app" folder and if not a system app make "priv-app" folder. You can also make "lib" folder along with "app" folder if your apps uses libs.

If you want to flash a bootanimation or ringtones etc make "media" folder.

If you want to flash something else ask it below.

How to edit "updater-script"?

​

What is updater-script?

updater-script is a file written in edify script language which instructs the recovery to perform certain tasks.

updater-script is located in /META-INF/com/google/android/updater-script in flashable zip

Some basic rules:

Every statement must end with a semicolon (; )

Comments must start with #

Strings must be delimited by double quotes (” “)

Commands

Now i will try to explain commands used in updater-script in very easy language or noob language.

format("yaffs2", "MTD", "system", "/system");

The above command is used to format the specified partition

Syntax explanation:

format - The main command to direct the recovery to format using the following parameters

"yaffs2" - Filesystem type used in the device

"MTD" - Type of the partition used in the file system

"system" - Name of the partition to be formatted

"/system" - Location of the partition to be formatted

======================================================================================================

ui_print("Format Completed");

The above command directs the recovery to display the following text enclosed in double quotes in the user interface (display).

After successful formatting it displays "Format Completed" in the device screen.

======================================================================================================

mount("yaffs2", "MTD", "system", "/system");

The mount command directs the recovery to mount the following file system and the following partition

The text syntax is same as format command as instead of formatting it mounts.

======================================================================================================

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

This command searches for the directory (folder) named "system" in the root of the zip file and copies all the content of the "system" folder from the zip file into the "/system" partition which is already mounted by the previous mount command ie it copies all the folder items inside system folder like apps, media etc as explained above.

======================================================================================================

package_extract_file("autoroot.sh", "/tmp/autoroot.sh");

This command searches for the file named "autoroot.sh" in the root of the zip file and copies the file to "/tmp" folder and names it as "autoroot.sh" (here it does not change the name)

======================================================================================================

symlink("mksh", "/system/bin/sh");

The above command creates a symlink.

What is symlink?

Symlink is nothing but shortcuts, for example if a file is required in two different places instead of copy pasting the file in two different locations, the file is copied to one of the two locations and in the other location a shortcut to the file(symlink) is created. The source and the symlink can have different names (actually this is the prime use of symlinks).

Let me explain it in a noob friendly manner.

Take the above symlink, it creates a shortcut(symlink) for the command "mksh" and places it in the path of the operating system. The shortcut(symlink) directs to the file "/system/bin/sh" , so whenever the os gets a request to execute the "mksh" command, the actual

binary that gets excuted will be "/system/bin/sh" .

Creating symlinks saves a lot of space because instead of copying the whole file and placing it in requiered places we are just creating shortcuts which directs to the source file which can be placed anywhere in the file system (generally placed in the path of the os).

======================================================================================================

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

The above command is used to set permission recursively for the files and folders present inside a folder (in this case for "/system" folder).

Explanation of syntax:

0 - uid - It defines that the following permission is set for the user id 0 .

0 - gid - It defines that the following permission is set for the group id 0 .

0775 - Dirmode - It defines that 0775 permission to set to directories contained within the specified directory.

0644 - Filemode - t defines that 0644 permission to set to files contained within the specified directory.

"/system" - Target directory to set the above mentioned permissions.

======================================================================================================

set_perm(0, 3003, 06755, "/system/bin/ip");

The above command is used to set permission for a individual file (in this case for "/system/bin/ip" file).

syntax explanation:

0 - uid - It defines that the following permission is set for the user id 0 .

3003 - gid - It defines that the following permission is set for the group id 3003 .

06775 - It defines that 06775 permission to set to the specific file.

"/system/bin/ip" - Target file to set the above mentioned permissions.

Other Permission commands:

Use to push new files to /data partition and /system partition.

ui_print(“Setting permissions…”);

set_perm_recursive(1000, 1000, 0771, 0644, “/data/app”);

set_perm_recursive(0, 0, 0755, 0644, “/system”);

set_perm_recursive(0, 0, 0777, 0777, “/system/etc/init.d”);

set_perm_recursive(0, 2000, 0755, 0755, “/system/bin”);

set_perm(0, 3003, 06755, “/system/bin/ip”);

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

set_perm(0, 0, 0755, “/system/etc/bluetooth”);

set_perm(1000, 1000, 0640, “/system/etc/bluetooth/auto_pair_devlist.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_recursive(0, 0, 0755, 0555, “/system/etc/ppp”);

set_perm_recursive(0, 2000, 0755, 0644, “/system/vendor”);

set_perm_recursive(0, 2000, 0755, 0644, “/system/vendor/etc”);

set_perm(0, 2000, 0755, “/system/vendor/lib”);

set_perm(0, 2000, 0755, “/system/vendor/lib/hw”);

set_perm_recursive(0, 2000, 0755, 0755, “/system/xbin”);

set_perm(0, 0, 06755, “/system/xbin/su”);

set_perm(0, 1000, 0755, “/system/xbin/busybox”);

======================================================================================================

unmount("/system");

This command just unmount the system.

======================================================================================================

iflesh Command:

Ifelse(condition),(do_this),(else_do_this);

Example:

ifelse mount("yaffs2", "MTD", "system", "/system") == "system", ui_print("Mounted!"), ui_print("Mount Failed!");

Ifelse command can be explained simply as asking the system to do something based on the result of a condition.

From example:

The ifelse command would attempt to mount the MTD partition named "system" to "/system".

If the mounting process succeeds (the condition), the script will display "Mounted!", else it will display "Mount Failed!"

======================================================================================================

abort()

It just abort's the script execution.

Note: It is usually paired with some other command for example the getprop command or with ifelse. Independently specifying abort() in the updater-script will kill the script abruptly right there so use this command carefully.

======================================================================================================

show_progress(fraction,duration)

show_progress(0.2,5);

fraction = a fraction of the bar (more on that in a moment)

duration = seconds

The "seconds" part just means how long the progress bar should take to fill up to the new level. It will not delay your script in any way: it will only take this much time if something else in the script is also taking that much time.

For example, if you run this snippet, you can watch the progress bar partially fill up pieces at a time. Each piece will take 5 seconds to fill, then pause for 2 seconds before the next piece starts (sleep command is for 7, so after the progress bar is done its 5 seconds of movement, there are 2 seconds of sleep left until the next command)

======================================================================================================

ALWAYS LEAVE TWO BLANK LINE AT THE END OF THE update-script (if the code contains 50 lines then 52 lines should be visible in the notepad++ including two blank line after the end of the script)

======================================================================================================

HOPE I HELPED YOU GUYS..... IF I MISS SOMETHING PLEASE LET ME KNOW.... AND DON'T FORGET TO PRESS THANKS....:good:

For More Info visit: http://xdaforums.com/wiki/Edify_script_language