Get the FREE Ultimate OpenClaw Setup Guide →

porting-diagnostics

npx machina-cli add skill Jiusi-pys/agent-plugins/porting-diagnostics --openclaw
Files (1)
SKILL.md
2.1 KB

Porting Diagnostics Skill

概述

提供 Linux 软件到 OpenHarmony 移植的可行性诊断能力,包括:

  • 平台特定 API 检测
  • 依赖库兼容性分析
  • 移植难度评估
  • 风险识别

诊断命令

快速扫描

# 使用 scripts/quick_scan.sh
./scripts/quick_scan.sh /path/to/source

详细分析

# 使用 scripts/full_analysis.py
python3 scripts/full_analysis.py /path/to/source --output report.json

API 兼容性速查

完全兼容 (绿灯)

pthread_create, pthread_join, pthread_mutex_*
socket, bind, listen, accept, connect, send, recv
open, read, write, close, lseek, fstat
malloc, free, realloc, calloc
memcpy, memset, strcmp, strlen
printf, fprintf, sprintf, snprintf

需要适配 (黄灯)

epoll_create, epoll_ctl, epoll_wait     → poll() 或 select()
inotify_init, inotify_add_watch         → OHOS FileWatcher API
eventfd, timerfd_create                  → pipe() + timer
signalfd                                 → signal() handler
getauxval                                → 直接读取 /proc/self/auxv (受限)

不可移植 (红灯)

io_uring_*                               → 重写为同步/线程池
clone() with CLONE_NEWNS/NEWPID          → 不支持
unshare(), setns()                       → 不支持
perf_event_open()                        → 不支持
bpf()                                    → 不支持

难度评级标准

等级红灯 API黄灯 API依赖状态工时估计
A00-5全部可用< 1天
B05-20大部分可用1-3天
C1-520+部分需移植1-2周
D5+-核心依赖不可用放弃

参考文档

Source

git clone https://github.com/Jiusi-pys/agent-plugins/blob/main/plugins/ohos-porting/skills/porting-diagnostics/SKILL.mdView on GitHub

Overview

Porting Diagnostics Skill 提供 Linux 软件到 OpenHarmony 的可行性诊断能力。它自动分析源码的平台特定 API、依赖库兼容性与移植难度,并在移植前进行风险识别。

How This Skill Works

通过快速扫描和详细分析两种诊断模式实现。快速扫描使用 scripts/quick_scan.sh 对源代码路径进行初步依赖与 API 检测,详细分析使用 python3 scripts/full_analysis.py 生成 report.json,输出包含兼容性与移植难点的报告。

When to Use It

  • 在决定是否迁移 Linux 应用到 OHOS 之前评估可行性
  • 需要评估平台特定 API 的兼容性与替代方案时
  • 评估移植工作量、工时和风险时
  • 获得移植报告以供团队或客户评审时
  • 遇到不兼容的 API,想快速定位替代实现时

Quick Start

  1. Step 1: Run quick scan ./scripts/quick_scan.sh /path/to/source
  2. Step 2: Run full analysis python3 scripts/full_analysis.py /path/to/source --output report.json
  3. Step 3: Review report.json for compatibility, dependencies and migration effort

Best Practices

  • 先用快速扫描锁定潜在兼容性问题
  • 对黄灯 API 优先规划替代方案
  • 在版本控制中保留分析报告和假设
  • 结合参考文档 references/linux-api-mapping.md 进行对照
  • 在实际移植前完成详细分析并更新风险清单

Example Use Cases

  • 分析一个 Linux 网络服务迁移到 OHOS,定位需要替换的 socket、epoll、inotify 等 API
  • 评估多线程应用的 pthread API 兼容性和注意点
  • 将应用中的 getauxval 使用重构为 OHOS 方式读取
  • 利用 full_analysis.py 生成 report.json,并提交给架构评审
  • 发现 io_uring_* 不可移植,需要重写为同步/线程池方案

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers