Build update.zip from your own Android source code

Source: Internet
Author: User

To build an update.zip package that can be flushed in the android recoverymode, assume that you have a compiled Android source code tree myandroid.

 

In Android 2.1-update1, the structure of a basic update.zip package is as follows:

 

.

 

| -- META-INF

 

| '-- Com

 

| '-- Google

 

| '-- Android

 

| -- Update-binary

 

| '-- Updater-script

 

'-System

  • Update-binary: a binary file, which is equivalent to a script interpreter and can recognize the operations described in Updater-script. This file is renamed by myandroid/out/target/product/you_product/system/bin/Updater. The specific name is determined by the value of macro assumed_update_binary_name in myandroid/bootable/recovery/install. C.
  • Updater-Script: This file needs to be written based on the content to be updated in the update package. the specific name is myandroid/bootable/recovery/Updater. the macro script_name value in the C file depends on. (Note: It is Updater-script instead of update-script ).
  • System: content to be updated under the directory. for example, if you only need to add several system software, add an app directory under this directory and copy the system software to be added. if you want to create a system update package. copy all files in myandroid/out/target/product/you_product/system/to this directory.
How to Create a system update update.zip package (experiment on a Ubuntu PC, if any command is missing, install it on your own)
  1. $ Mkdir update # create a directory named update under any directory
  2. $ CD upadte # enter this directory
  3. $ Mkdir-P META-INF/COM/Google/Android/& mkdir system # create 2 subdirectories under the update directory
  4. $ CP myandroid/out/target/product/you_product/system/bin/Updater META-INF/COM/Google/Android/update-binary # Get the update-binary file
  5. $ CP myandroid/out/target/product/you_product/system/# obtain the file required to update the MTD of the system.
  6. $ CP myandroid/out/target/product/you_product/boot. IMG./# obtain the files required to update the system boot region. This boot. IMG = kernel + ramdisk
  7. $ Vim META-INF/COM/Google/Android/Updater-script # Open the Updater-Script script to start the update process)
  8. $ Zip update.zip-R./META-INF/./system/./boot. IMG # After editing the Updater-Script script, compress all content in update into an update.zip package.
  9. $ Java-jar --- signature --- # use Java to sign the update.zip package (detailed below)
  • Compile the Updater-Script script (Step 7)

The Updater-script content is actually a line of update-binery that can recognize other command sequences. file myandroid/bootable/recovery/update/install. C describes all executable commands. the following describes how to use some commands:

    • Mount:

Eg: Mount ("MTD", "system", "/System ");

Mount the system partition of MTD to the/system directory of the file system.

  •  

    • Ui_print:

Eg: ui_print ("Hello word !");

Print the prompt on the screen.

  •  

    • Format:

Eg: Format ("MTD", "system ");

Format the MTD system partition

  •  

    • Package_extract_dir:

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

Copy all the content in System in the update package to the file system/system.

 

  • Update.zip signature (Step 9)

After the update.zip package is complete, you need to sign the zip package. Otherwise, an error message indicating authentication failure will appear when you flash the package in recovery mode. The complete command in Step 9 above is:

$ Java-jar myandroid/out/host/linux-x86/framework/signapk. jar-W myandroid/build/target/product/security/testkey. x509.pem/testkey. pk8 update.zip update_signed.zip

 

With this command, the update.zip package will be signed, and then an update_signed.zip signed update package will be output. This will serve as the final update package. This command requires five conditions:

  1. The host needs to be installed with a Java environment, ubuntu for the sun-java5-jdk Deb package
  2. Signapk. jar file. Under the compiled myandroid/out/host/linux-x86/framework directory
  3. Testkey. x509.pem is in the myandroid/build/target/product/security directory of the source code.
  4. Testkey. pk8 is in the compiled myandroid/build/target/product/security directory.
  5. Update.zip is a zip package that has not been signed.
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.