OtaPackageToolOTA 打包工具
OtaPackageTool 是一個(gè) OTA 打包工具,使用 git 獲取不同提交之間的文件差異實(shí)現(xiàn)OTA包生成。
OtaPackageTool 工具默認(rèn)提供了一個(gè) linux-x86-64 的可執(zhí)行文件,放于開源項(xiàng)目的 bin 目錄下。該工具能夠構(gòu)建兩種類型的包: 全量包和增量包。支持 tar 和 zip 兩種文件類型的包文件。實(shí)現(xiàn) OTA 包的構(gòu)建,需要借助 git 實(shí)現(xiàn)版本文件的管理。
安裝
二進(jìn)制安裝
OtaPackageTool 工具默認(rèn)提供了一個(gè) linux-x86-64 的可執(zhí)行文件,放于開源項(xiàng)目的 bin 目錄下。只需要克隆下載下來,即可執(zhí)行:
$ git clone https://github.com/yicm/OtaPackageTool.git
$ cd OtaPackageTool/bin
$ ./ota_packer -h
源碼編譯安裝
$ git clone https://github.com/yicm/OtaPackageTool.git
$ cd OtaPackageTool
$ go build -o bin ./...
編譯完成后,生成的可執(zhí)行文件已經(jīng)輸出到 bin 目錄下。
使用
準(zhǔn)備
- 將 OtaPackageTool 添加到環(huán)境變量
$PATH(這里就不展開如何添加了) - 進(jìn)入你的軟件版本管理倉(cāng)庫(kù)根目錄
$ cd your_installation_file_version_repository
- 就可以運(yùn)行 OtaPackageTool 相關(guān)的打包功能了
示例
# -----------------------------------------------
---
# 查看工具版本
$ ota_packer version
ota_packer version 0.0.1
# --------------------------------------------------
# 查看工具幫助
$ ota_packer -h
Archive of the diff files using git on Linux system.
Usage:
ota_packer [command]
Available Commands:
gen Generate package file
help Help about any command
version Get version of ota_packer
Flags:
-c, --config string Config file (default is $HOME/.ota_packer.yaml)
-h, --help help for ota_packer
-n, --project-name string Your project name (default "OTA")
Use "ota_packer [command] --help" for more information about a command.
# --------------------------------------------------
# 查看OTA包生成幫助
$ ota_packer gen -h
Generate a specific version package by entering different configuration parameters.
Usage:
ota_packer gen [flags]
Flags:
-F, --diff-filter string git diff --diff-filter and a similar designation (default "ACMRT")
-e, --end-commit-id string End revision (default "HEAD")
-f, --format string The format of the archive, supporting zip and tar (default "tar")
-h, --help help for gen
-o, --output string Output destination path of the archive
-p, --prefix string Prefixed to the filename in the archive while project name is not set. (default "ota_packer")
-s, --start-commit-id string Start revision (default "HEAD~1")
-v, --verbose Show packaging process statistics
Global Flags:
-c, --config string Config file (default is $HOME/.ota_packer.yaml)
-n, --project-name string Your project name (default "OTA")
全量包
如果設(shè)置 --start-commit-id 與 --end-commit-id 的值一致,則會(huì)生成當(dāng)前 commit id 的全量包。如:
$ ota_packer gen -s HEAD -e HEAD
$ ota_packer gen -s HEAD~1 -e HEAD~1
$ ota_packer gen -s HEAD~3 -e HEAD~1
$ ota_packer gen -s 6bc76a1f -e 6bc76a1f
增量包生成
可以設(shè)置從某個(gè)提交版本升級(jí)/降級(jí)到指定版本,升級(jí)的化則需要 --start-commit-id 提交時(shí)間在 --end-commit-id 之前,否則的話就是生成的就是降級(jí)包。示例:
# 默認(rèn) --start-commit-id=HEAD~1, --end-commit-id=HEAD
$ ota_packer gen
$ ota_packer gen -s HEAD~2 -e HEAD~0
$ ota_packer gen -s 6bc76a1f -e 9d31d032
# Set output path as 'tmp' directory, and set project name as 'Test'
$ ./output/ota_packer gen -s HEAD~1 -e HEAD~0 -o tmp -n "Test"
-----------------------------------------------------------------
Project Name | Test
------------------+----------------------------------------------
Output Path | tmp/
------------------+----------------------------------------------
Output | Test-20200630145419-6bc76a1-to-9d31d03.tar
------------------+----------------------------------------------
Changelog | ota_info.json
------------------+----------------------------------------------
{
"project_name": "Test",
"last_ota_version": "6bc76a1",
"ota_version": "9d31d03",
"is_full_update": false,
"changes": [
{
"type": "D",
"old_path": "models/y.model",
"new_path": "models/y.model"
}
]
}
------------------+----------------------------------------------
關(guān)于OTA包版本之間文件變更類型說明
A: 新增了該文件
C: 從一個(gè)文件復(fù)制到另一個(gè)文件
D: 刪除了該文件
M: 修改了該文件
R: 重命名了該文件(可能路徑有所變化)
T: 更改該文件的類型
OtaPackageTool 使用條件
- Git v2.27.0 版本或以上
- UNIX 或類 UNIX 系統(tǒng)
- Go1.13+ (可選,源碼安裝時(shí)需要)
評(píng)論
圖片
表情
