Androidsystemrecoveryuse update.zip upgrade process-Updater-Script script syntax introduction and execution process

Source: Internet
Author: User
Tags symlink

Currently, the update-Script script format is edify. What is the difference between it and amend? For the moment, we will not discuss it. We will only analyze the main syntax and script process control.

I. Introduction to the Update-Script script Syntax:

The generated script mainly involves the syntax.

1. Assert (condition): If the result of the condition parameter is false, stop the script execution; otherwise, continue to execute the script.

2. show_progress (frac, Sec): frac indicates the progress completed value, and SEC indicates the total number of seconds of the entire process. It mainly uses and displays the progress bar on the UI.

3. Format (fs_type, partition_type, location): fs_type, file system type. The value is generally "yaffs2" or "ext4 ". Partition_type: partition type. Generally, the value is "MTD" or "emmc ". It is mainly used to format a specified file system. Example: Format ("yaffs2", "MTD", "system ").

4. Mount (fs_type, partition_type, location, mount_point): The first two parameters are the same as above. The mount_point mount point is the device to be mounted by location. Purpose: mount a file system to a specified mount point.

5. package_extract_dir (src_path, destination_path): src_path, the directory to be extracted, and the destination directory of destination_path. Purpose: extract the directory from the update package to the specified location. Example: package_extract_dir ("system", "/system ").

6. symlink (target, src1, src2 ,......, Srcn): Target, string type, is the target of the symbolic connection. Srcx indicates the target point of the symbolic connection to be created. Example: symlink ("toolbox", "/system/bin/Ps") to establish a connection to the Toolbox symbol/system/bin/PS. It is worth noting that, before creating a new symbolic connection, you must disconnect an existing symbolic connection.

7. set_perm (UID, GID, mode, file1, file2 ,......, Filen): sets the permissions for a single file or a series of files. At least one file must be specified.

8. set_perm_recursive (UID, GID, mode, dir1, dir2 ,......, Dirn): the same role as above, but the permission for one or more directories and their files is changed at the same time.

9. package_extract_file (srcfile_path, desfile_paht): srcfile_path, the file to be extracted, desfile_path, and the target location of the file to be extracted. Example: package_extract_file ("boot. IMG", "/tmp/boot. IMG") copies the boot. imgfile in the upgrade package to/tmp in the memory file system.

10. write_raw_image (SRC-image, partition): Src-image source image file, partition, target partition. Purpose: Write the image to the target partition. Example: write_raw_image ("/tmp/boot. IMG", "Boot") writes the boot. IMG image to the boot partition of the system.

11. getprop (key): obtains the attribute information by specifying the key value. Example: getprop ("Ro. Product. device") gets the property value of Ro. Product. device.

12. ui_print (string): used to display the content in flash mode.

13. Delete (filepath): Command Used to delete files

14. run_program (shell, scriptpath): for example, run_program ("/sbin/sh", "/system/bin/install. Sh ");

15. umount (PATH): unmount the File System

16. cmdlist:

is_mountedunmountformatshow_progressset_progressdeletedelete_recursivepackage_extract_dirpackage_extract_fileretouch_binariesundo_retouch_binariessymlinkset_permset_perm_recursivegetpropfile_getpropwrite_raw_imageapply_patchapply_patch_checkapply_patch_spaceread_filesha1_checkwipe_cacheui_printrun_programset_bootloader_env


Ii. Updater-Script script execution process analysis:

The upgrade script generated by the command make otapackage during the test is as follows:

assert(!less_than_int(1331176658, getprop("ro.build.date.utc")));assert(getprop("ro.product.device") == "tcc8800" ||       getprop("ro.build.product") == "tcc8800");show_progress(0.500000, 0);format("yaffs2", "MTD", "system");mount("yaffs2", "MTD", "system", "/system");package_extract_dir("recovery", "/system");package_extract_dir("system", "/system");symlink("busybox", "/system/bin/cp", "/system/bin/grep",        "/system/bin/tar", "/system/bin/unzip",        "/system/bin/vi");symlink("toolbox", "/system/bin/cat", "/system/bin/chmod",        "/system/bin/chown", "/system/bin/cmp", "/system/bin/date",        "/system/bin/dd", "/system/bin/df", "/system/bin/dmesg",        "/system/bin/getevent", "/system/bin/getprop", "/system/bin/hd",        "/system/bin/id", "/system/bin/ifconfig", "/system/bin/iftop",        "/system/bin/insmod", "/system/bin/ioctl", "/system/bin/ionice",        "/system/bin/kill", "/system/bin/ln", "/system/bin/log",        "/system/bin/ls", "/system/bin/lsmod", "/system/bin/lsof",        "/system/bin/mkdir", "/system/bin/mount", "/system/bin/mv",        "/system/bin/nandread", "/system/bin/netstat",        "/system/bin/newfs_msdos", "/system/bin/notify", "/system/bin/printenv",        "/system/bin/ps", "/system/bin/reboot", "/system/bin/renice",        "/system/bin/rm", "/system/bin/rmdir", "/system/bin/rmmod",        "/system/bin/route", "/system/bin/schedtop", "/system/bin/sendevent",        "/system/bin/setconsole", "/system/bin/setprop", "/system/bin/sleep",        "/system/bin/smd", "/system/bin/start", "/system/bin/stop",        "/system/bin/sync", "/system/bin/top", "/system/bin/umount",        "/system/bin/uptime", "/system/bin/vmstat", "/system/bin/watchprops",        "/system/bin/wipe");set_perm_recursive(0, 0, 0755, 0644, "/system");set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");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_pairing.conf");set_perm(3002, 3002, 0444, "/system/etc/bluetooth/blacklist.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(0, 0, 0544, "/system/etc/install-recovery.sh");set_perm_recursive(0, 0, 0755, 0555, "/system/etc/ppp");set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");set_perm(0, 0, 06755, "/system/xbin/librank");set_perm(0, 0, 06755, "/system/xbin/procmem");set_perm(0, 0, 06755, "/system/xbin/procrank");set_perm(0, 0, 06755, "/system/xbin/su");set_perm(0, 0, 06755, "/system/xbin/tcpdump");show_progress(0.200000, 0);show_progress(0.200000, 10);assert(package_extract_file("boot.img", "/tmp/boot.img"),       write_raw_image("/tmp/boot.img", "boot"),       delete("/tmp/boot.img"));show_progress(0.100000, 0);unmount("/system");

The following describes the execution process of the script:

① Compare timestamp: If the upgrade package is older, the script will be executed.

② Match the device information: if the device information is inconsistent with the current information, the script is stopped.

③ Display progress bar: if the above two steps match, the upgrade progress bar is displayed.

④ Format and mount the system partition.

⑤ Extract the recovery in the package and the content in the system directory to the system/system.

⑥ Create a symbolic connection for the command file under/system/bin.

7. Set/system/directory and file attributes.

Extract boot. IMG from the package to/tmp/boot. IMG.

Worker writes the/tmp/boot. IMG image file to the boot partition.

Uninstall/system after logging.

The above is the syntax in the Updater-Script script and the specific process of execution. By analyzing the execution process, we can find that the upgrade package is not extracted to another place, but what needs to be extracted. It is worth noting that when extracting the content in the recovery and System directories, it is put under/system. In the operation process, you have not deleted or modified any content in the update.zip package. After the upgrade, our update.zip package exists in the original location.


Iii. Summary

The previous nine articles repeat one of the recoverymodes in the androidsystem, that is, the process of update.zip packages that we have completed when updating the system. The core part is the working principle of the recovery service. The other two types of factory reset, encrypted file system enable/disable and OTA install are the same. The focus is to understand the working principles of the recovery service. In addition, the upgrade process is analyzed in detail. During the actual upgrade, we can make corresponding modifications as needed.

For more information, see!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.