app.json 二进制依赖 depends:启动前检查(launcher)+ 安装提示(nyai)
需求(用户定案):App 复杂功能若依赖现成 Linux 二进制(板载 /usr/bin 或卡上 MeowOS/opt/bin)能效更好,声明后系统启动 App 前检查依赖是否存在。 - depends 行式声明:depends=curl,jq:optional,ffmpeg:required(无标注默认 required;也接受 :opt/:req;未知修饰符按 required 处理并 WARN;空项/超量丢弃) - launch_app_chain 冷启动时按序查 /usr/bin/<name> 与 <卡>/MeowOS/opt/bin/<name> (X_OK,两类命中即满足);缺 required → 不启动(toast「缺依赖: <name>」+ 日志, 沿用 CANNOT START 风格);optional 缺失 → 仅 WARN 放行;只在启动时查,不做周期复查 - nyai install 对包内 app.json depends 同查并提示(不阻断安装,缺 required 标注 「安装后启动将失败」) - 新增 meow_dep.c(独立 TU,解析/检查/块原因),宿主测试 test_depends.c 解析矩阵 12 用例 + 假根检查路径 12 用例全 PASS;launcher/nyai mipsel 交叉 -Wall -Wextra 0 warning;launcher 现有宿主测试回归全过 - 文档:APPS.md §2.1 字段表 + docs/MEOWOS_SPEC_REF.md §5.5 同步;hello app.json 加 depends:curl:optional 示例 launcher md5 899ac22c10f596909d7f35ea685744de(fw_content.conf 已更新;/usr/bin 只读,留给主会话打包固件)
This commit is contained in:
1 parent
9e25db77cc
commit
ed2ae10320
14 files changed
+416
-12
No files matched your search
Binary file not shown.
@@ -810,6 +810,51 @@ static int export_preserve_sig(const char *pkg, const char *dst)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------- 二进制依赖检查(app.json depends,新语义) ----------------
|
||||
* app.json "depends" 现为二进制依赖声明:<name>[:<mod>][,...],<mod>=required|req(默认)/optional|opt。
|
||||
* 与 launcher meow_parse_depends 同语义;按序查 /usr/bin/<name> 与 <root>/MeowOS/opt/bin/<name>(X_OK)。
|
||||
* 安装时**不阻断**:缺 required 输出 WARN 标注「安装后启动将失败」;缺 optional 仅提示。 */
|
||||
static int bin_dep_exists(const char *name)
|
||||
{
|
||||
char p[300];
|
||||
snprintf(p, sizeof p, "/usr/bin/%s", name);
|
||||
if (access(p, X_OK) == 0) return 1;
|
||||
snprintf(p, sizeof p, "%s/MeowOS/opt/bin/%s", meow_root(), name);
|
||||
if (access(p, X_OK) == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nyai_check_bin_depends(const appmeta *m)
|
||||
{
|
||||
if (!m || !m->depends[0]) return;
|
||||
char d[256];
|
||||
snprintf(d, sizeof d, "%s", m->depends);
|
||||
char *save = NULL, *tok = strtok_r(d, ",", &save);
|
||||
while (tok) {
|
||||
tok = trim(tok);
|
||||
if (!*tok) { tok = strtok_r(NULL, ",", &save); continue; }
|
||||
char nm[64] = ""; int req = 1;
|
||||
char *colon = strchr(tok, ':');
|
||||
size_t nl = colon ? (size_t)(colon - tok) : strlen(tok);
|
||||
if (nl >= sizeof nm) nl = sizeof nm - 1;
|
||||
memcpy(nm, tok, nl); nm[nl] = 0;
|
||||
if (colon) {
|
||||
char *mod = trim(colon + 1);
|
||||
if (!strcmp(mod, "optional") || !strcmp(mod, "opt")) req = 0;
|
||||
else if (!strcmp(mod, "required") || !strcmp(mod, "req")) req = 1;
|
||||
/* 未知修饰符按 required 处理 */
|
||||
}
|
||||
if (!*nm) { tok = strtok_r(NULL, ",", &save); continue; }
|
||||
if (!bin_dep_exists(nm)) {
|
||||
if (req)
|
||||
printf("nyai: 警告: 依赖 %s 缺失(required),安装后启动将失败\n", nm);
|
||||
else
|
||||
printf("nyai: 提示: 可选依赖 %s 缺失\n", nm);
|
||||
}
|
||||
tok = strtok_r(NULL, ",", &save);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------- install(文件或名称) ---------------- */
|
||||
static int install_mpk_file(const char *mpk_path)
|
||||
{
|
||||
@@ -852,6 +897,8 @@ static int install_mpk_file(const char *mpk_path)
|
||||
fprintf(stderr,"nyai: install: app.json 不合法(缺 name 或 exec)\n");
|
||||
rm_rf(stg); return 1;
|
||||
}
|
||||
/* 二进制依赖检查(app.json depends):不阻断安装,缺 required 标注「安装后启动将失败」。 */
|
||||
nyai_check_bin_depends(&m);
|
||||
/* ①.5 签名分级 + 三重绑定(MPK_SIGNATURE_DESIGN §3.3/§5.2 失败行为表) */
|
||||
int vr = verify_mpk_signature(mpk_path, pkg, NULL, 0);
|
||||
int system_pkg = is_system_pkg(pkg);
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user