feat(pkg): version_code 安卓式版本规则落地 (agent-190, 用户定案 APPS §3.8) — app.json 增 version_code(纯数字唯一比较依据), version 仅显示; nyai install/upgrade/list-upgradable/index 全走 code 比较(缺 code 拒装); launcher meow_pkg_install 同步门禁; 旧点分比较函数移除
nyai f2938d28→4cf5f690; launcher 24c9ee5d→ab8e610f; 宿主 9 场景全过(升/同版/降级拒/缺code拒/index/upgrade一致) 出入: 全新安装缺 code 放行(门禁仅 replacing 分支); export 保留签名的版本比对仍用显示版字符串(nyai+launcher 一致,待后续统一)
This commit is contained in:
1 parent
555c4a458e
commit
60072a08f1
5 files changed
+75
-76
No files matched your search
@@ -620,6 +620,26 @@ int meow_pkg_install(const char *mpk_path)
|
||||
logmsg("pkg_install: meow_verify unavailable rc=%d, %s unverified (3rd party)", vr, pkg);
|
||||
}
|
||||
|
||||
/* 防降级门禁(与 nyai 同规范,APPS.md §3.8):仅按 version_code 比较。
|
||||
* 新版 code < 已装 → 拒;相等 → 允许重装;任一侧缺 version_code → 拒。 */
|
||||
if (replacing) {
|
||||
char nc[32], oc[32];
|
||||
long long ncode = -1, ocode = -1;
|
||||
int nok = 0, ok2 = 0;
|
||||
if (pkg_json_field_mpk(mpk_path, "version_code", nc, sizeof nc) == 0) {
|
||||
char *ep; long long v = strtoll(nc, &ep, 10);
|
||||
if (ep != nc && *ep == '\0') { ncode = v; nok = 1; }
|
||||
}
|
||||
char instj[280];
|
||||
snprintf(instj, sizeof instj, "/usr/data/mnt/sd_0/MeowAPPs/%s/app.json", pkg);
|
||||
if (pkg_json_field(instj, "version_code", oc, sizeof oc) == 0) {
|
||||
char *ep; long long v = strtoll(oc, &ep, 10);
|
||||
if (ep != oc && *ep == '\0') { ocode = v; ok2 = 1; }
|
||||
}
|
||||
if (!nok || !ok2) { logmsg("pkg_install: %s version_code missing, reject", pkg); return -4; }
|
||||
if (ncode < ocode) { logmsg("pkg_install: downgrade %s new %lld < old %lld, reject", pkg, ncode, ocode); return -4; }
|
||||
}
|
||||
|
||||
/* BusyBox tar 无 -z:用 gzip -dc | tar -x 处理 tar.gz。 */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"rm -rf '%s' 2>/dev/null; "
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user