UniOHOS Builder 工具链与存储打包(UniOHOS/builder)
UniOHOS/builder(Apache-2.0)提供声明式 device.yaml 校验器、方式 A 规格查询 CLI、方式 B 五步本地合成规划器、通用 64KB PTE_CONT EROFS 存储工具(fs-tools/)以及单文件热挂载工装(harness/)。
1. 安装方式
bash
git clone https://github.com/UniOHOS/builder.git
cd builder
pip install -e .也可不安装直接通过 python3 -m uniohos_builder 调用。
2. 子命令参考(uniohos-builder)
validate-device
对照 schemas/device.schema.json 校验 device.yaml,强制核对必填字段、枚举范围、zero_remote_blobs == true 与 zero_neverallow == true。
bash
uniohos-builder validate-device examples/dijun-reference.yaml
uniohos-builder validate-device examples/dijun-reference.yaml --schema schemas/device.schema.json --jsonopen-base-info
查看 方式 A 纯开源 Apache-2.0 OpenHarmony 基座根文件系统目标规格(uniohos-open-base-<arch>.erofs)。
bash
uniohos-builder open-base-info --arch arm64
uniohos-builder open-base-info --arch x86_64 --jsonbyof-plan
校验机型清单并生成可复现的 方式 B 五步纯离线本地合成规划(remote_blob_downloads: 0)。
bash
uniohos-builder byof-plan --device examples/dijun-reference.yaml --dry-run
uniohos-builder byof-plan --device examples/dijun-reference.yaml --dry-run --json| 子命令 | 必填参数 | 可选参数 |
|---|---|---|
validate-device | <device_yaml> | --schema <路径>、--json |
open-base-info | (无) | `--arch arm64 |
byof-plan | --device <device_yaml> | --schema <路径>、--dry-run(默认开启)、--json |
3. 存储工具(fs-tools/)与热挂载工装(harness/)
fs-tools/tools/erofs_v2_64k_packer.py:分层打包只读 EROFS 镜像(Tier-0免压64KB PTE_CONT对齐FLAT_PLAIN+Tier-1lz4hc+Tier-2zstd),校验phys_blkaddr % 16 == 0、原版fsck.erofs --extract逐字节 SHA-256 还原一致以及双遍可复现(R1 == R2)。fs-tools/tools/hmfs_ioctl_compat.h:与内核原生 F2FS 兼容层配套的用户态HMFSioctl头文件。fs-tools/configs/:通用erofs_tier_rules_super_v21.json与erofs_compress_hints_super_v21.txt规则模板。harness/hotbind_test_harness.sh:单文件MS_BIND内环调试工装,详见 单文件热挂载高效调试。
4. 运行自测与卫生门禁
bash
python3 -m unittest discover -s tests -v
python3 scripts/check_hygiene.py