The current Update-script script format is edify, which is different from amend, we only analyze the main syntax, and the process control of the script.
First, Update-script script syntax Introduction:
we look at the syntax that is primarily involved in the generated script.
1.assert (condition): If the condition parameter evaluates to FALSE, the script execution is stopped, otherwise the script continues to execute.
2.show_progress (frac,sec): Frac represents the number of progress completed, the SEC represents the total seconds of the whole process. The main use is to display the progress bar on the UI.
3.format (fs_type,partition_type,location): fs_type, File system type, value is generally "YAFFS2" or "Ext4". Partition_type, the partition type, the general value is "MTD" or "EMMC". Primarily used to format the specified file system. Examples are as follows: Format ("YAFFS2", "MTD", "system").
4.mount (Fs_type,partition_type,location,mount_point): The first two parameters above, location to mount the device, Mount_point mount point. Role: Mounts a file system to the specified mount point.
5.package_extract_dir (Src_path,destination_path): Src_path, the directory to extract, Destination_path the destination directory. Function: From within the upgrade package, extract the directory to the specified location. Example: Package_extract_dir ("System", "/system").
6.symlink (Target,src1,src2,......, SRCN): Target, String type, is the destination of the symbolic connection. SRCX represents the target point of the symbolic connection to be created. Example: Symlink ("toolbox", "/system/bin/ps"), establishing a pointer to the Toolbox symbolic connection/system/bin/ps, it is worth noting that the symbolic connection already exists before the new symbolic connection is established.
7.set_perm (uid,gid,mode,file1,file2,......, filen): The role is to set a single file or a series of file permissions, at least to specify a file.
8.set_perm_recursive (Uid,gid,mode,dir1,dir2,......, Dirn): Same as above, but it also changes the permissions of one or more directories and their files.
9.package_extract_file (srcfile_path,desfile_paht): Srcfile_path, the file to extract, Desfile_path, the target location of the extracted file. Example: Package_extract_file ("boot.img", "/tmp/boot.img") copies the boot.img files in the upgrade package to/TMP of the memory file system.
10.write_raw_image (src-image,partition): src-image source image file, partition, destination partition. Role: Writes the image to the destination partition. Example: Write_raw_image ("/tmp/boot.img", "boot") writes the boot.img image to the boot partition of the system.
11.getprop (Key): Gets the corresponding property information by specifying the value of the key. Example: Getprop ("Ro.product.device") gets the property value of Ro.product.device.
Ui_print (String): Used in flash mode to display the content
Delete (FilePath): a command to delete a file
Run_program (Shell, ScriptPath): For example: Run_program ("/sbin/sh", "/system/bin/install.sh");
Umount (Path): Uninstalling the file system
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
Second, Updater-script script execution Process analysis:
Let's take a look at the upgrade scripts generated by the command make otapackage during the test process 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");p Ackage_extract_dir ("Recovery", "/system");p Ackage_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, 0755, 0755, "/system/bin"); Set_perm (0, 3003, 02750, "/system/bin/netcfg"); Set_perm (0, 3004, 02755, "/system/bin/ping"); Set_perm (0, 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 (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, 0550, "/system/etc/dhcpcd/dhcpcd-run-hooks"); Set_perm (0, 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, 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 is an analysis of the execution of this script:
① comparison timestamp: Terminates execution of the script if the upgrade package is older.
② Match device information: Stops execution of the script if it is inconsistent with the current device information.
③ Show progress bar: If the above two steps match, the upgrade progress bar will start to appear.
④ format the system partition and mount it.
⑤ extracts the recovery in the package and the contents of the system directory to the/system of the systems.
⑥ establishes a symbolic connection for the command file under/system/bin/.
⑦ sets the/system/directory and the properties of the file.
⑧ extracts the boot.img from the package to/tmp/boot.img.
⑨ writes the/tmp/boot.img image file to the boot partition.
⑩ Uninstall/system when finished.
The above is the syntax in the Updater-script script, and the specific process of execution. By analyzing its execution process, we can find that in the execution process, the upgrade package is not extracted to another place, but what is needed to extract what. It is important to place the contents of the recovery and system directories in the/system/. During the operation, nothing in the Update.zip package was deleted or changed. After the actual update is complete, our Update.zip package does still exist in its original location.
Iii. Summary
The above nine focuses on the analysis of the Android system in the recovery mode, that is, we do a good update.zip package in the system to update the flow through the process. The core part is how the recovery service works. The other two factory RESET, ENCRYPTED FILE SYSTEM enable/disable are interlinked with Ota install. The point is to understand how the recovery service works. In addition, detailed analysis of its upgrade process, for us in the actual upgrade, we can make corresponding changes according to our needs.
http://blog.csdn.net/tody_guo/article/details/7948083
How Android Recovery works using the UPDATE.ZIP upgrade process---updater-script script syntax introduction and execution process (GO)