Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1385664
  • 博文数量: 478
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 4833
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-28 11:12
文章分类

全部博文(478)

文章存档

2019年(1)

2018年(27)

2017年(21)

2016年(171)

2015年(258)

我的朋友

分类: Android平台

2016-05-31 11:55:35

写在前面:

    写在前面:若能直译,不会意译,意译不成,为了选择不误导他人也会漏译无伤大雅的部分,英语是硬伤,如果有误译,请路过的朋友帮忙指正,以免误导更多的朋友。

    OTA打包工具ota_from_target_filesbuild/tools/releasetools/目录下)可以为我们创建两种类型的更新包:整包和增量包。打包工具一般来说会对我们称之为目标文件(target-files.zip)进行打包,该目标文件是有编译系统产生,通常可在终端下使用make otapackage生成。

 

一、整包升级

    一个整包包含了Android设备的整个终态(system/boot/recovery分区),只要设备可以接收更新包并且进入recovery系统,就可以安装更新包而无需考虑设备当前状态。那么如何创建一个整包呢?

下面我们使用发布的打包工具来创建一个整包。

1.创建target-files.zip

[cpp] view plain copy
 print?
  1. % . build/envsetup.sh && lunch tardis-eng  
  2. % mkdir dist_output  
  3. % make dist DIST_DIR=dist_output  
  4.   [...]  
  5. % ls -l dist_output/*target_files*  
  6. -rw-r----- 1 user eng  69965275 Sep 29 15:51 tardis-target_files.zip  


2.创建整包

[plain] view plain copy
 print?
  1. % ./build/tools/releasetools/ota_from_target_files \  
  2.     dist_output/tardis-target_files.zip ota_update.zip  
  3. unzipping target target-files...  
  4. done.  
  5. % ls -l ota_update.zip  
  6. -rw-r----- 1 user eng 62236561 Sep 29 15:58 ota_update.zip  


    注!如果你看到的编译命令与工作中不一致,是由于不同平台(MTK、高通等)进行进一步封装,这里的文档只是做个参考。

 

二、增量升级

    一个增量包包含了一系列相对于现有设备的二进制补丁,增量包相对来说比较小。因为如果文件没有发生变化就不会有内容包含在更新包中,如果文件文件相对于前一个版本改变很小,那么增量包中仅仅是包含两个文件不同的内容。

那么制作增量包就需要old版本的target_files.zipnew版本的target_files.zip。参考命令如下:

[plain] view plain copy
 print?
  1. % ./build/tools/releasetools/ota_from_target_files \  
  2.     -i PREVIOUS-tardis-target_files.zip \  # make incremental from this older version  
  3.     dist_output/tardis-target_files.zip incremental_ota_update.zip  
  4. unzipping target target-files...  
  5. unzipping source target-files...  
  6.    [...]  
  7. done.  
  8. % ls -l incremental_ota_update.zip  
  9. -rw-r----- 1 user eng 1175314 Sep 29 16:10 incremental_ota_update.zip  


    进行增量升级的时候必须保证设备中当前运行的版本与增量包old target_files.zip的版本保持一致。否则会安装中断。因此应在更新包安装前进行校验。

三、更新包

    更新包是.zip格式的压缩包(ota_update.zip,incremental_ota_update.zip),它包含了可执行的二进制文件(META-INF/com/google/android/update-binary.在对更新包进行签名验证之后,recovery会通过下面的参水对将其提取到/tmp下并且执行它。

Update binaly API version number.二进制文件会通过这个参数增大它的值。

File descriptor of the command pipe.更新程序可以使用这个通道发送指令给recovery binary

Filename of the update package .zip file.

 

 

原文如下:



The  tool provided in build/tools/releasetoolscan build two types of package: full and incremental. The tool takes thetarget-files .zip file produced by the Android build system as input.

Full updates


full update is one where the entire final state of the device (system, boot, and recovery partitions) is contained in the package. As long as the device is capable of receiving the package and booting the recovery system, the package can install the desired build regardless of the current state of the device.

Example: Using the release tools to build a full update for the hypothetical tardis device:

# first, build the target-files .zip % . build/envsetup.sh && lunch tardis-eng % mkdir dist_output % make dist DIST_DIR=dist_output   [...] % ls -l dist_output/*target_files* -rw-r----- 1 user eng  69965275 Sep 29 15:51 tardis-target_files.zip

The target-files .zip contains everything needed to construct OTA packages.

% ./build/tools/releasetools/ota_from_target_files \     dist_output/tardis-target_files.zip ota_update.zip unzipping target target-files... done. % ls -l ota_update.zip -rw-r----- 1 user eng 62236561 Sep 29 15:58 ota_update.zip

The ota_update.zip is now ready to be sent to test devices (everything is signed with the test key). For user devices, generate and use your own private keys as detailed in Signing builds for release.

Incremental updates


An incremental update contains a set of binary patches to be applied to the data already on the device. This can result in considerably smaller update packages:

  • Files that have not changed don't need to be included.
  • Files that have changed are often very similar to their previous versions, so the package need only contain an encoding of the differences between the two files.

You can install the incremental update package only on a device that has the old or source build used when constructing the package. To build an incremental update, you need the target_files .zip from the previous build (the one you want to update from) as well as the target_files .zip from the new build.

% ./build/tools/releasetools/ota_from_target_files \     -i PREVIOUS-tardis-target_files.zip \  # make incremental from this older version     dist_output/tardis-target_files.zip incremental_ota_update.zip unzipping target target-files... unzipping source target-files...    [...] done. % ls -l incremental_ota_update.zip -rw-r----- 1 user eng 1175314 Sep 29 16:10 incremental_ota_update.zip

This build is very similar to the previous build, and the incremental update package is much smaller than the corresponding full update (about 1 MB instead of 60 MB).

Note: To generate a block-based OTA for subsequent updates, pass the --block option toota_from_target_files.

Distribute an incremental package only to devices running exactly the same previous build used as the incremental package's starting point. Attempting to install the incremental package on a device with some other build results in the recovery error icon. Rebooting the device at this point returns the user to the old system; the package verifies the previous state of all the files it updates before touching them, so the device should not be left in a half upgraded state if this occurs.

Update packages


An update package (ota_update.zip, incremental_ota_update.zip) is a .zip file that contains the executable binary META-INF/com/google/android/update-binary. After verifying the signature on the package, recovery extracts this binary to /tmp and runs it, passing the following arguments:

  • Update binary API version number. If the arguments passed to the update binary change, this number is incremented.
  • File descriptor of the command pipe. The update program can use this pipe to send commands back to the recovery binary (mostly for UI changes such as indicating progress to the user).
  • Filename of the update package .zip file.

A recovery package can use any statically-linked binary as the update binary. The OTA package construction tools use the updater program (source in bootable/recovery/updater), which provides a simple scripting language that can do many installation tasks. You can substitute any other binary running on the device.

For details on the updater binary, edify syntax, and builtin functions, see Inside OTA Packages .


阅读(1064) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~