README.md
1# Updater<a name="EN-US_TOPIC_0000001148614629"></a>
2
3- [Introduction](#section184mcpsimp)
4- [Directory Structure](#section198mcpsimp)
5- [Usage](#section218mcpsimp)
6 - [Usage Guidelines](#section220mcpsimp)
7
8- [Repositories Involved](#section247mcpsimp)
9
10## Introduction<a name="section184mcpsimp"></a>
11
12The updater runs in the recovery partition. It reads the misc partition information to obtain the update package status and verifies the update package to ensure that the update package is valid. Then, the updater parses the executable program from the update package, creates a subprocess, and starts the update program. After that, update operations will be automatically implemented by the update script.
13
14## Directory Structure<a name="section198mcpsimp"></a>
15
16```
17base/update/updater/
18├── resources # UI image resources of the update subsystem
19├── services # Service code of the updater
20│ ├── applypatch # Update package data update code
21│ ├── fs_manager # File system and partition management code
22│ ├── include # Header files for the update subsystem
23│ ├── log # Log module of the update subsystem
24│ ├── package # Update packages
25│ ├── script # Update scripts
26│ ├── diffpatch # Differential package restore code
27│ ├── sparse_image # Sparse image parsing code
28│ ├── ui # UI code
29│ └── updater_binary # Executable programs
30├── interfaces
31│ └── kits # External APIs
32└── utils # Common utilities of the update subsystem
33 └── include # Header files for general functions of the update subsystem
34```
35
36## Usage<a name="section218mcpsimp"></a>
37
38### Usage Guidelines<a name="section220mcpsimp"></a>
39
40The updater runs in the recovery partition. To ensure proper functioning of the updater, perform the following operations:
41
421. Create a recovery partition.
43
44The recovery partition is independent of other partitions. It is recommended that the size of the recovery partition be greater than or equal to 20 MB. The recovery partition image is an ext4 file system. Ensure that the **config** option of the ext4 file system in the system kernel is enabled.
45
462. Create the misc partition.
47
48The misc partition stores metadata required by the update subsystem during the update process. Such data includes update commands and records of resumable data transfer upon power-off. This partition is a raw partition and its size is about 1 MB. You do not need to create a file system for the misc partition, because the update subsystem can directly access this partition.
49
503. Prepare the partition configuration table.
51
52During the update process, the updater needs to operate the partitions through the partition configuration table. The default file name of the partition configuration table is **fstab.updater**. You need to pack the **fstab.updater** file into the updater during compilation.
53
544. Start the updater.
55
56The init process in the recovery partition has an independent configuration file named **init.cfg**. The startup configuration of the updater is stored in this file.
57
585. Compile the updater.
59
60a. Add the updater configurations to the **build/subsystem\_config.json** file.
61
62Example configuration:
63
64```
65"updater": {
66"project": "hmf/updater",
67"path": "base/update/updater",
68"name": "updater",
69"dir": "base/update"
70},
71```
72
73b. Add the updater for the desired product.
74
75For example, to add the updater for Hi3516D V300, add the following code to the **productdefine/common/products/Hi3516DV300.json** file.
76
77```
78 "updater:updater":{},
79```
80
816. Compile the recovery partition image.
82
83Add the compilation configuration to the **build\_updater\_image.sh** script, which is stored in the **build** repository and called by the OpenHarmony compilation system.
84
85## Repositories Involved<a name="section247mcpsimp"></a>
86
87Update subsystem
88
89**update\_updater**
90
91build
92
93productdefine\_common
94
95
README_zh.md
1# 升级包安装组件<a name="ZH-CN_TOPIC_0000001148614629"></a>
2
3- [简介](#section184mcpsimp)
4- [目录](#section198mcpsimp)
5- [说明](#section218mcpsimp)
6 - [使用说明](#section220mcpsimp)
7
8- [相关仓](#section247mcpsimp)
9
10## 简介<a name="section184mcpsimp"></a>
11
12升级包安装组件运行在recovery分区,其功能主要包括读取misc分区信息获取升级包状态,对升级包进行校验,确保升级包合法有效;然后从升级包中解析出升级的可执行程序,创建子进程并启动升级程序。具体升级的动作由升级脚本控制。
13
14## 目录<a name="section198mcpsimp"></a>
15
16```
17base/update/updater/
18├── resources # 升级子系统用户界面图片资源目录
19├── services # 组件服务层代码目录
20│ ├── applypatch # 升级包数据更新代码目录
21│ ├── fs_manager # 文件系统和分区管理代码目录
22│ ├── include # 升级子系统头文件目录
23│ ├── log # 升级子系统日志模块目录
24│ ├── package # 升级包管理模块目录
25│ ├── script # 升级脚本管理目录
26│ ├── diffpatch # 差分还原代码目录
27│ ├── sparse_image # 稀疏镜像解析代码目录
28│ ├── ui # 升级ui界面代码目录
29│ └── updater_binary # 升级可执行程序目录
30├── interfaces
31│ └── kits # 对外模块接口定义
32└── utils # 升级子系统通用代码目录
33 └── include # 升级子系统通用函数头文件目录
34```
35
36## 说明<a name="section218mcpsimp"></a>
37
38### 使用说明<a name="section220mcpsimp"></a>
39
40升级包安装组件运行在recovery分区里,需要如下的操作
41
421、创建recovery分区
43
44recovery是一个独立的分区,分区大小建议不小于20MB。recovery分区镜像是ext4 格式文件系统。确保系统内核ext4 文件系统的config 是打开状态。
45
462、创建misc分区
47
48misc 分区中存储了升级子系统在升级过程中需要的元数据\(metadata\),如升级命令,掉电续传记录等。 misc 分区的大小约1MB,是一个裸分区,无需制作文件系统, 升级子系统直接访问。
49
503、分区配置表
51
52升级包安装组件在运行过程中,需要通过分区配置表操作分区。默认的分区配置表文件名是fstab.updater,在编译的时候,打包到升级包安装组件中。
53
544、升级包安装组件启动
55
56recovery分区的init 进程有单独的配置文件 init.cfg,升级包安装进程启动配置在该文件中。
57
585、升级包安装组件编译
59
60a、在build/subsystem\_config.json文件添加配置。
61
62如下:
63
64```
65"updater": {
66"project": "hmf/updater",
67"path": "base/update/updater",
68"name": "updater",
69"dir": "base/update"
70},
71```
72
73b、 产品中添加需要编译的组件
74
75以Hi3516DV300为例,在productdefine/common/products/Hi3516DV300.json 中添加updater:
76
77```
78 "updater:updater":{},
79```
80
816、recovery分区镜像编译
82
83编译配置在build仓下,build\_updater\_image.sh 脚本中,该脚本由OHOS 编译系统调用。
84
85## 相关仓<a name="section247mcpsimp"></a>
86
87升级子系统
88
89**update\_updater**
90
91build
92
93productdefine\_common
94
95