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 (” “)
Functions used:
ui_print(” “) – Prints string enclosed in double quotes. You can write anything between double quotes.
Example: ui_print(“Formatting partitions…”); will display Strings between double quotes i.e. Formatting partitions…
show_progress(fraction, seconds) – Shows progress bar over a period of seconds. Use 3.14 in fraction and total seconds required to complete flashing in seconds.
Example: show_progress(3.14, 100); will advance progress bar from 0% to 100% in 100 seconds. If flashing takes 20 seconds to finish then use 20, if it takes 200 seconds then use 200.
format(“filesystem”, “partition_type”, “device”) – Used to format a specified partition. Use MTK droid tools -> Block maps to see block details of your phone.
Example: format(“ext4″, “EMMC”, “/dev/block/mmcblk0p5″); will format /system partition. Every phone may have different filesystem, partition type, device. Here ext4 is the filesystem type, EMMC is partition type and /dev/block/mmcblk0p5 is the device.
mount(“filesystem”, “partition_type”, “device”, “mountpoint”) – Used to mount a specified partition.
Example: mount(“ext4″, “EMMC”, “/dev/block/mmcblk0p5″, “/system”) will mount /system partition.
delete(“file_path”) – Used to delete an individual file where file_path is the location of the file which is to be deleted.
Example: delete(“/system/app/Music.apk”); will delete Music.apk from /system/app directory.
delete_recursive(“folder_path”) – Used to delete all files from a directory. It will delete the directory too.
Example: delete_recursive(“/system/etc/bluetooth”); will delete bluetooth directory from /system/etc.
package_extract_file(“source”, “destination”) – Used to extract individual file.
Example: package_extract_file(“logo.bin”, “/dev/logo”); will extract logo.bin file to /dev directory with name logo. Here logo.bin is source path in flashable zip and /dev/logo is destination path in device.
package_extract_dir(“source”, “destination”) – Used to extract all contents from source directory in flashable zip to the destination directory. Example: package_extract_dir(“system”, “/system”); will search for system folder in root of zip and copy all contents from system folder to the /system partition.
set_perm(uid, gid, mode, “file_path”) – Used to set permission for an individual file. Here uid denotes user id, gid denotes groud id and mode is the permission to be set to the file.
Example: set_perm(0, 0, 0644, “/system/priv-app/SystemUI.apk”); will set permission rw- r– r– for SystemUI.apk.
set_perm_recursive(uid, gid, dirmode, filemode, “directory_path”) – Used to set permission to the files and folders present inside specified folder.
Example: set_perm_recursive(0, 0, 0755, 0644, “/system”); will set permission rwx r-x r-x to all the folders present inside /system and rw- r– r– permission to all the files present inside /system.
r stands for read permission
w stands for write permission
x stands for execute permission
Octal values:
1 : –x
2 : -w-
3 : -wx
4 : r–
5 : r-x
6 : rw-
7 : rwx
You can use root explorer app to see permissions of any file or directory.
Default permission for /system partition and /data/app directory is set in flashable zip provided above.
write_raw_image(“file_path”, “filename”) – Used to write an image file to the device (/dev).
Example: write_raw_image(“/tmp/boot.img”, “bootimg”) will write boot.img file from /tmp directory to /dev
unmount(“mountpoint”) – Used to unmount a specified partition.
Example: unmount(“/system”); will unmount /system partition.
Understanding and editing downloaded zip:
# UPDATER-SCRIPT PROVIDED BY VISHAL KAUSHIK
# FOR GUIDE
These lines are comments. Used for information only. Will be ignored by recovery.
ui_print(“”);
Print a blank line.
show_progress(3.14, 150);
Advance progress bar for 150 seconds. Considering flashing will take 150 seconds to finish.
ui_print(“—————-“);
ui_print(” ROM NAME /”);
ui_print(” VERSION NAME /”);
ui_print(“—————-“);
ui_print(“”);
Print —————- in 1st line,
ROM NAME in 2nd line
VERSION NAME in 3rd line
—————- in 4th line
and blank in 5th line.
ui_print(“Formatting partitions…”);
format(“ext4″, “EMMC”, “/dev/block/mmcblk0p5″);
format(“ext4″, “EMMC”, “/dev/block/mmcblk0p6″);
format(“ext4″, “EMMC”, “/dev/block/mmcblk0p7″);
1st statement will print Formatting partitions…
2nd statement will format /system partition where all system files are stored. Use this option only if you are flashing a new ROM. Don’t use in update.
3rd statement will format /cache partition.
4th statement will format /data partition where all user apps and data for user and system apps are stored. Don’t use in update.
ui_print(“Mounting partitions…”);
mount(“ext4″, “EMMC”, “/dev/block/mmcblk0p5″, “/system”);
mount(“ext4″, “EMMC”, “/dev/block/mmcblk0p7″, “/data”);
1st statement will print Mounting partitions…
2nd and 3rd statements will mount /system and /data partitions respectively.
Partitions must be mounted to delete old files and copy new files
ui_print(“Removing unneeded files…”);
delete(“file_path”);
delete_recursive(“folder_path”);
Replace file_path with the path of the file which you want to delete. Example: /system/app/Music.apk, /system/priv-app/Settings.apk, /data/app/com.whatsapp-1.apk, /system/bin/vold, etc.
Replace folder_path with the path of the folder which you want to delete. Example: /system/etc/bluetooth, /system/res, /data/dalvik-cache, etc.
ui_print(“Extracting files…”);
package_extract_dir(“data”, “/data”);
package_extract_dir(“system”, “/system”);
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”);
These are the permissions for /system partition and /data/app directory. You don’t need to add new permission for /system files. Just push files and correct permission will be set by above statements.
ui_print(“Flashing kernel…”);
assert(package_extract_file(“boot.img”, “/tmp/boot.img”),
write_raw_image(“/tmp/boot.img”, “bootimg”),
delete(“/tmp/boot.img”));
These lines will flash kernel/boot.img. Place boot.img in root of zip.
ui_print(“Flashing logo…”);
package_extract_file(“logo.bin”, “/dev/logo”);
This is used to flash new logo. Place logo.bin in root of zip.
ui_print(“Wiping dalvik-cache…”);
delete_recursive(“/data/dalvik-cache”);
Use to wipe dalvik-cache. Dalvik-cache must be wiped after flashing update to prevent force close.
ui_print(“Unmounting partitions…”);
unmount
#thanq_to_qamrul_and_me... :)
For any queries comment here
Like us on facebook too...
1 comments:
Only Copy paste! What have u made urself?
Post a Comment