| <html devsite><head> |
| <title>OTA 软件包工具</title> |
| <meta name="project_path" value="/_project.yaml"/> |
| <meta name="book_path" value="/_book.yaml"/> |
| </head> |
| <body> |
| <!-- |
| Copyright 2017 The Android Open Source Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <p><code>build/tools/releasetools</code> 中提供的 <a href="https://android.googlesource.com/platform/build/+/master/tools/releasetools/ota_from_target_files">ota_from_target_files</a> 工具可以构建两种类型的软件包:完整更新软件包和增量更新软件包。<i></i><i></i>该工具将 Android 构建系统生成的 target_files .zip 文件作为输入文件。<i></i></p> |
| |
| <h2 id="full-updates">完整更新</h2> |
| <p>完整更新是指软件包将对设备的整个最终状态(系统分区、启动分区和恢复分区)进行更新。<i></i>只要设备能够接收软件包并启动恢复系统,软件包就可以安装所需的版本,而不受设备当前状态的影响。</p> |
| <p>示例:使用发布工具为假设的 <b>tardis</b> 设备构建完整更新:</p> |
| |
| <pre class="devsite-click-to-copy"> |
| # first, build the target-files .zip |
| <code class="devsite-terminal">. build/envsetup.sh && lunch tardis-eng</code> |
| <code class="devsite-terminal">mkdir dist_output</code> |
| <code class="devsite-terminal">make dist DIST_DIR=dist_output</code> |
| </pre> |
| |
| <p>target_files .zip 包含构建 OTA 软件包所需的所有内容。 |
| </p> |
| |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">./build/tools/releasetools/ota_from_target_files dist_output/tardis-target_files.zip ota_update.zip</code> |
| </pre> |
| |
| <p>ota_update.zip 现已准备就绪,可以发送到测试设备(所有内容均使用测试密钥进行签名)。对于用户设备,请生成并使用自己的私钥,有关详情,请参阅<a href="/devices/tech/ota/sign_builds.html">签名版本以供发布</a>。 |
| |
| </p><h2 id="incremental-updates">增量更新</h2> |
| <p>增量更新包含一组要应用于设备上的已有数据的二进制补丁程序。<i></i>以下原因可能会导致此类更新软件包非常小:</p> |
| <ul> |
| <li>未更改的文件不需要包含在其中。</li> |
| <li>更改的文件通常与之前的版本非常相似,因此软件包中只需包含针对两个文件之间的不同之处进行的编码。</li></ul> |
| <p>只有当设备具有构建相应软件包所使用的旧版本或源版本时,您才能在设备上安装增量更新软件包。要构建增量更新,您需要拥有上一个版本(您要更新的版本)中的 target_files .zip 以及新版本中的 target_files .zip。<i></i></p> |
| |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">./build/tools/releasetools/ota_from_target_files -i PREVIOUS-tardis-target_files.zip dist_output/tardis-target_files.zip incremental_ota_update.zip # make incremental from the older version</code> |
| </pre> |
| |
| <p>该版本与上一个版本非常类似,而且增量更新软件包(约 1 MB)比对应的完整更新软件包 (60 MB) 小得多。</p> |
| <p class="note"><strong>注意</strong>:要为后续更新生成<a href="/devices/tech/ota/block.html">基于块的 OTA</a>,请将 <code>--block</code> 选项传递到 <code>ota_from_target_files</code>。</p> |
| <p>仅当设备运行的上一个版本与相应增量更新软件包的起点版本完全一样时,才向其分发该增量更新软件包。如果尝试在运行其他版本的设备上安装该增量包,系统将会显示恢复错误图标。此时用户只要重新启动设备,即可回到旧系统;软件包会先验证它要更新的所有文件是否已回到之前的状态,然后再对其执行操作,因此,如果发生上述情况,设备不应留在半升级状态。</p> |
| |
| <h2 id="update-packages">更新软件包</h2> |
| <p>更新软件包(<code>ota_update.zip</code>、<code>incremental_ota_update.zip</code>)是包含可执行二进制文件 <code>META-INF/com/google/android/update-binary</code> 的 .zip 文件。对软件包上的签名进行验证后,恢复进程会将该二进制文件解压到 <code>/tmp</code> 并运行它,然后传递以下参数:</p> |
| <ul> |
| <li><b>更新二进制 API 版本号</b>。如果向更新二进制文件传递的参数发生变化,此数字将递增。</li> |
| <li><b>命令管道的文件描述符</b><i></i>。更新程序可以使用此管道将命令发送回恢复二进制文件(主要用于界面变化,例如向用户指示进度)。</li> |
| <li><b>更新软件包 .zip 文件的文件名</b>。</li> |
| </ul> |
| <p>恢复软件包可以使用任何静态链接的二进制文件作为更新二进制文件。OTA 软件包构建工具使用更新程序(<code>bootable/recovery/updater</code> 中的源),该程序提供一种可以执行很多安装任务的简单脚本语言。您可以替换设备上运行的任何其他二进制文件。</p> |
| <p>要详细了解更新程序二进制文件、edify 语法和内置函数,请参阅 <a href="/devices/tech/ota/inside_packages.html">OTA 软件包内部探秘</a>。 |
| |
| </p></body></html> |