Detailed description of the functions of Android updater-scripts (edify Script) (RPM)

Source: Internet
Author: User
Tags sha1 sha1 hash symlink

This is the basic introduction to the Android system to run Updater-scripts's edify language.

Most of the edify names are functions, and when these functions are called, the data is returned to the script. Of course, you can also use the return values of these functions to confirm success, such as:

IfElse (Mount ("YAFFS2", "MTD", "System", "/system") = = "System", Ui_print ("Successfully mounted!"), Ui_print ("Mount Failed! ");

This command will attempt to mount the "MTD" Partition named "System" to "/system". If the mount succeeds, the script displays "successfully mounted!", otherwise "Mount failed!" is displayed.

The present surface is an example of a function used in the edify updater-script:

Function Name: Mount

function Syntax : Mount (Fs_type, Partition_type, location, Mount_point)

detailed parameters : Fs_type-----------------"YAFFS2" or "Ext4"

Partition_type----------"MTD" or "EMMC"

Location-----------------partition (partition) or drive (device)

Mount_poin------------mount the target folder of the file system (target-folder to Mount FS)

function Explanation : mount a file system to a specified mount point

return value : Mount succeeded returns mount point, failure returns null

example Functions : Mount ("MTD", "System", "/system"), mount the system partition, set the return pointer "/system"

Mount ("Vfat", "/dev/block/mmcblk1p2", "/system"); Mount/DEV/BLOCK/MMCBLK1P2, return pointer "/system"

Function Name: is_mounted

function Syntax : is_mounted (Mount_point)

parameter Description: Mount_point-----------string to check if mount point is already mounted

function explanation : Check whether the file system is mounted

return value : Mount succeeded returns mount point, failure returns null

Examples of functions :

Function Name: unmount

function Syntax : unmount (Mount_point)

parameter Description: Mount_point-----------String, mount point to release Mount

function Explanation : Release File system mount

return value : The mount point was returned successfully when the mount was lifted, and the failure returned null

Function Example : Unmount ("/system"); Uninstalling the/system partition

Function Name: Format

function Syntax : Format (fs_type, Partition_type, location)

parameter Description: Fs_type-----------------string with data "YAFFS2" or "EXT4"

Partition_type----------String, "MTD" or "EMMC"

Location-----------------string, partition (partition) or drive (device)

function Interpretation : Format to the specified file system

Examples of functions : Format ("MTD", "System"), formatted system partition

Function Name: delete

function Syntax : delete (File1, file2, ..., filen)

parameter Details : string, file to be deleted

function Explanation : Delete a file. Specify at least one file, and multiple files can be specified as multiple parameters

Function Example : Delete ("/data/zipalign.log"); Remove file/data/zipalign.log

Function Name: delete_recursive

function Syntax : delete_recursive (Dir1, Dir2,..., Dirn)

parameter Details : string, directory to be removed recursively

role Explanation : Delete the folder and all the content it contains. Specify a minimum of 1 directories, and multiple directories can be specified as multiple parameters

example function : delete_recursive ("/data/dalvik-cache"); Delete Folder/data/dalvik-cache

Function Name: show_progress

function Syntax : show_progress (frac, SEC)

detailed parameter : Frac----------------------Progress Completion value

SEC----------------------Total number of seconds

function explanation : Shows progress in the recovery system

Function Example : Show_progress (0.1), show_progress the following operation may be 10s, complete the progress bar forward 0.1 (that is, 10%)

Function Name: set_progress

function Syntax : Set_prograss (Frac)

detailed parameters : Frac---------------------Progress values

Examples of functions :

Function Name: Package_extract_dir

function Syntax : Package_extract_dir (Package_path, Destination_path)

parameter Details : Package_path----------String, the directory to be extracted within the upgrade package

Destination_path--------String to extract the target directory of the file

function Explanation : Extract all files from the directory within the upgrade package to the specified destination directory

Examples of functions : Package_extract_dir ("System", "/system"), releasing all files and subfolders under the System folder in the ROM package to/system

Function Name: Package_extract_file

function Syntax : package_extract_file (Package_path) or Package_extract_file (Package_path, Destination_path)

parameter Details : Package_path----------String, the file to be extracted within the upgrade package

Destination_path-------String to extract the target directory of the file

function Explanation : Extracts a single file from the upgrade package to the specified destination directory

Examples of functions : Package_extract_file ("My.zip", "/system"), extracting my.zip files from the ROM package to/system

Function Name: File_getprop

function Syntax : file_getprop (file, key)

parameter Description: File----------------------string, file name to check

Key----------------------String that returns the name of the file in the data

function Explanation : Get the file attribute value in the file of format "key" = "value"

Examples of functions :

Function Name: symlink

function Syntax : symlink (target, Src1, Src2, ..., SRCN)

parameter details : Target-------------------String, destination of the symbolic link

SRCX---------------------String, the target point of the symbolic link to be created

function explanation : To break a symbolic link that already exists before creating a new symbolic link

Examples of functions : Symlink ("toolbox", "/system/bin/ps"), and establishing symbolic links to toolbox/system/bin/ps

Function Name: set_perm

function Syntax : set_perm (UID, GID, mode, file1, File2, ..., filen)

parameter Description: UID----------------------User ID

Gid----------------------User Group IDs (group ID)

Mode--------------------permission mode (permission modes)

Filex---------------------the file to set the license (permission to set)

function Explanation : Set the permissions of a single file or a series of files, specify at least 1 files, the first 4 parameters are required

Examples of functions : Set_perm (0,2000,0550, "system/etc/init.goldfish.sh"), setting etc/in Phone system init.goldfish.sh user is root, the user group is the shell, the owner and members of the owning user group can read and perform operations, other users do not have permission to operate.

Here 0 represents the user as root 2000 for the user group for the shell we describe 0550 this set of data, the last three bits of data 550, respectively, the "owner \ Group user \ Other users" permissions, that is, we in the RE management "user \ Group \ Other" three rows. We use XXX to represent these three sets of permissions, wherein: x=4 Read permission x=2 Write permission X=1 Execute permission We must first understand the meaning of the attribute represented by a number: 0 means no permissions, 1 means executable, 2 is writable, 4 is read, and then it is added. So the format of the numeric attribute should be 3 octal numbers from 0 to 7. For example, if you want the owner of a file to have "read/write" Two permissions, you need to have 4 (readable) +2 (writable) =6 (read/write). The Rwx property is 4+2+1=7, the Rw-property is 4+2=6, and the R-x property is 4+1=5. Common commands for modifying permissions: Set_perm 0 0 0600xxx (only the owner has read and write permissions) set_perm 0 0 0644xxx (owner has read and write permissions, group user only Read permissions) set_perm 0 0 0700xxx (only the owner has Read and write and Execute permissions) set_perm 0 0 0666xxx (everyone has read and write permissions) set_perm 0 0 0777xxx (everyone has read and write and Execute permissions)

Function Name: set_perm_recursive

function Syntax : set_perm_recursive (uid, GID, Dirmode, FileMode, Dir1, Dir2, ... Dirn)

parameter Description: UID----------------------User ID

Gid----------------------User Group IDs (group ID)

Dirmode----------------permissions for directories within a specified directory

Filemode---------------permissions for files within a specified directory

DirX---------------------the target to set permissions for

function Explanation : Set the permissions of all files inside a single directory or a series of directories, specify at least 1 directories, 5 parameters are required

Examples of functions : set_perm_recursive 0 0 0755 0644 system:app; Set the phone System/app folder and the user with the file in the root, the user group for the Root,app folder permissions for the owner can read , write, perform operations, and other users can read and perform operations where the permissions of the file are read and written by the owner, and other users can perform the reading operation

Function Name: Getprop

function Syntax : Getprop (Key)

parameter Description: Key---------------------String, the property that you want the system to return

function explanation : This function is used to return the value of the specified property. It is used to query the phone's information from the Build.props file.

Examples of functions :

Function Name: write_raw_image

function Syntax : write_raw_image (file, partition)

parameter Description: File----------------------string, img source file to read

Partition-----------------string, destination partition to write to the img file

role Explanation : This function is used to write an IMG file to the partition

Function Example : Write_raw_image ("/tmp/boot.img", "boot") writes the boot package in YAFFS2 format directly to the boot partition

Function Name: Apply_patch

function Syntax : Apply_patch (Srcfile, Tgtfile, TGTSHA1, Tgtsize, Sha1_1, patch_1, ..., sha1_x, patch1_x)

parameter Details : Srcfile-------------------String, the source file to be patched (the file to be read in)

Tgtfile-------------------String, the patch file to be written to the target file

TGTSHA1-----------------String, SHA1 hash of the target file to which the patch file is written

Sha1_x------------------String, SHA1 hash of patch data to be written to the destination file

Patch1_x----------------strings, actually patches applied to the target file

function explanation : This function is used to make patches to files.

Examples of functions :

Function Name: Apply_patch_check

function Syntax : apply_patch_check (file, Sha1_1, ..., sha1_x)

parameter Description: File----------------------string, files to check

Sha1_x------------------the hash value to check

function explanation : Check whether the file has been patched, or can be patched. You need to check the source code for the "Applypatch_check" function call.

Examples of functions :

Function Name: Apply_patch_space

function Syntax : apply_patch_space (bytes)

Detailed Parameters : bytes-------------------Check the number of bytes

Role explanation : Check the cache to determine if there is enough space to write the patch file and return some data.

Examples of functions :

Function Name: Read_file

function Syntax : read_file (filename)

parameter Description: FileName----------------string to read the file name of the content

role Explanation : This function returns the contents of a file

Examples of functions :

Function Name: Sha1_check

function Syntax : Sha1_check (data) or sha1_check (data, Sha1_hex, ..., SHA1_HEXN)

parameter Details: Data---------------------The contents of the file to calculate the SHA1 hash value-must be a read-only file format

Sha1_hexn--------------file data to match a specific hexadecimal Sha1_hex hash value string

function Explanation : If you specify only the data parameter, this function returns the hexadecimal Sha1_hex hash value string for the data parameter. Other parameters are used to confirm that the file you are checking is not one of the hash values in the list. It returns a matching hash value, or null if no hash value is matched.

Examples of functions :

Function Name: Ui_print

function Syntax : ui_print (MSG1, ..., MSGN)

parameter Description: Msg----------------------string, the information to be output to the user during processing

function Explanation : The information displayed at the console when the script is running. To specify a minimum of 1 parameters, you can specify additional msg parameters, and they will connect to lose

Function Example : Ui_print ("It's ready!"); Screen printing it ' s ready!

Function Name: Run_program

function Syntax : run_program (Prog, Arg1,.., ArgN)

parameter details : Prog--------------------string, the program to execute

ArgN--------------------string, running parameters of the program to be executed

function Explanation : Executes the program with the specified parameter

Function Example : Run_program ("/system/xbin/installbusybox.sh"); Run installbusybox.sh script file

Function Name: IfElse

function Syntax : ifelse (condition, truecondition, falsecondition)

Detailed parameters : condition----------------expressions to be calculated

Truecondition the edify script block executed when the value is true-----------

Falsecodnition the edify script block executed when the value is False-----------

function Explanation : This is the Edify scripting language of the if-then structure. The statement can be a single edify command or a script block under true or non-conditional statements. Script blocks can be delimited with parentheses, separated by semicolons.

Examples of functions :

Function Name: Abort

function Syntax : Abort ()

parameter Details : no parameters

role Explanation : Abort script execution

Examples of functions :

Function Name: Assert

function Syntax : ASSERT (condition)

Detailed parameters : Condition---------------Boolean

function Explanation : If the condition parameter evaluates to FALSE, stop the script execution, or continue executing the script

Examples of functions : Assert (Package_extract_file ("boot.img", "/tmp/boot.img"), Write_raw_image ("/tmp/boot.img", "boot"), Delete ("/tmp/boot.img"))

Executes Package_extract_file, executes write_raw_image if no error is returned, and executes delete if Write_raw_image is not faulted

http://blog.csdn.net/tody_guo/article/details/7948083

Detailed description of the functions of Android updater-scripts (edify Script) (RPM)

Related Article

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.