fix(chv-guest): 客机镜像构建缺口补齐(B-02/B-03/B-04/B-05/B-06/B-07/B-08/B-09/B-10/B-13/B-15)
- B-10(实测):virt-customize chroot 里 sshd -t 必败,双因: 无 host key(exit 1)+ 缺 /run/sshd(exit 255);修为 mkdir -p /run/sshd + ssh-keygen -A 临时生成,断言通过后 立删临时 key,镜像仍不带 host key(已在 WSL 真机预演验证) - B-08:Playwright 装在第二次定制,须重写 pip freeze 否则 BUILDINFO 里无 playwright;Chromium 以 ms-playwright 缓存 目录名记录进 guest-versions-chromium.txt - B-09:codex --version 须含 CODEX_VERSION;REPO_COMMIT 须 等于 HEAD 短 hash;工作树脏即拒绝构建 - B-02/B-13:BUILDINFO 生成抽成 buildinfo.py(可单元测试), 补 disk.raw/vmlinux sha256+大小、ubuntu 镜像 sha、cmdline、 playwright 开关、image_sha256 字段 - generate_lockfile.py 改写:版本唯一来源改为 BUILDINFO.versions(客机读回),codex 三件套取 codex_version、/app/host.py 取 repo_commit、chromium 取 versions.chromium;不再查构建宿主 dpkg/pip(旧方法不成立) - check_lockfile.py 补强:条目格式、contents 全覆盖、冻结 清单双向比对 - B-03/B-04 输入格式校验、B-05 curl 重试、B-06 哈希不符 删文件重下、B-07 磁盘预检、B-15 set -euo pipefail - 同步改 test_chv_to10.py:generate 不再查宿主,改断言客机 版本来源 + 不回落宿主
This commit is contained in:
1 parent
8c8d62f70d
commit
7f18c2d13b
5 files changed
+372
-96
No files matched your search
@@ -5,9 +5,9 @@
|
||||
宿主上解析、pip 版本在客机里解析,没有构建宿主就编不出
|
||||
版本号——本脚本绝不编造。构建时 build.sh 已从客机读回
|
||||
dpkg + pip freeze 写进 BUILDINFO.versions(事后 lockfile),
|
||||
本脚本校验它:versions 非空、tag 与预期一致、可选的冻结
|
||||
清单(--frozen JSON,形如 {"dpkg": ["pkg version", ...]})
|
||||
逐项比对,漂移即退出非 0。
|
||||
本脚本校验它:versions 非空、每条有版本、contents 全覆盖、
|
||||
tag 与预期一致、可选的冻结清单(--frozen JSON,形如
|
||||
{"dpkg": ["pkg version", ...]})双向比对,漂移即退出非 0。
|
||||
|
||||
用法:
|
||||
python3 check_lockfile.py out/BUILDINFO.json [--tag TAG]
|
||||
@@ -16,6 +16,47 @@ dpkg + pip freeze 写进 BUILDINFO.versions(事后 lockfile),
|
||||
import json
|
||||
import sys
|
||||
|
||||
# 非包名的内容项:版本来自 BUILDINFO 的声明字段,不是 versions 列表。
|
||||
DECLARED_SOURCES = {
|
||||
"codex": "codex_version",
|
||||
"codex-code-mode-host": "codex_version",
|
||||
"codex-resources/bwrap": "codex_version",
|
||||
"/app/host.py": "repo_commit",
|
||||
}
|
||||
|
||||
|
||||
def _names(entries, pip_style=False):
|
||||
"""versions 条目 → 小写名集合。dpkg 行是 "name version",
|
||||
pip freeze 行是 "name==version"。"""
|
||||
names = set()
|
||||
for entry in entries or []:
|
||||
text = str(entry)
|
||||
if pip_style and "==" in text:
|
||||
names.add(text.split("==", 1)[0].lower())
|
||||
else:
|
||||
parts = text.split(None, 1)
|
||||
if parts:
|
||||
names.add(parts[0].lower())
|
||||
return names
|
||||
|
||||
|
||||
def _check_format(kind, entries):
|
||||
"""每条须带非空版本:dpkg "name version",pip "name==version"。"""
|
||||
for entry in entries or []:
|
||||
text = str(entry)
|
||||
if kind == "pip" and "==" in text:
|
||||
if not text.split("==", 1)[1].strip():
|
||||
print("版本为空的条目:%s %r" % (kind, entry),
|
||||
file=sys.stderr)
|
||||
return False
|
||||
else:
|
||||
parts = text.split()
|
||||
if len(parts) < 2 or not parts[1]:
|
||||
print("版本为空的条目:%s %r" % (kind, entry),
|
||||
file=sys.stderr)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 2:
|
||||
@@ -47,20 +88,46 @@ def main(argv):
|
||||
print("BUILDINFO.versions.dpkg/pip 为空,供应链清单缺失",
|
||||
file=sys.stderr)
|
||||
return 1
|
||||
if not _check_format("dpkg", versions.get("dpkg")):
|
||||
return 1
|
||||
if not _check_format("pip", versions.get("pip")):
|
||||
return 1
|
||||
# contents 全覆盖:每项须在 dpkg/pip 名单里,或有声明字段版本。
|
||||
covered = _names(versions.get("dpkg")) | _names(
|
||||
versions.get("pip"), pip_style=True)
|
||||
missing = []
|
||||
for name in data.get("contents") or []:
|
||||
if name.lower() in covered:
|
||||
continue
|
||||
source = DECLARED_SOURCES.get(name)
|
||||
if source and data.get(source):
|
||||
continue
|
||||
if name.lower() == "chromium" and versions.get("chromium"):
|
||||
continue
|
||||
missing.append(name)
|
||||
if missing:
|
||||
print("contents 未覆盖:%s" % sorted(missing), file=sys.stderr)
|
||||
return 1
|
||||
if frozen_path:
|
||||
with open(frozen_path) as fh:
|
||||
frozen = json.load(fh)
|
||||
for kind in ("dpkg", "pip"):
|
||||
want = set(frozen.get(kind) or [])
|
||||
got = set(versions.get(kind) or [])
|
||||
missing = want - got
|
||||
if missing:
|
||||
absent = want - got
|
||||
if absent:
|
||||
print("%s 漂移:冻结清单里有、构建产物里无:%s"
|
||||
% (kind, sorted(missing)), file=sys.stderr)
|
||||
% (kind, sorted(absent)), file=sys.stderr)
|
||||
return 1
|
||||
print("lockfile 校验通过:tag=%s dpkg=%d pip=%d"
|
||||
extra = got - want
|
||||
if extra:
|
||||
print("%s 漂移:构建产物里有、冻结清单里无:%s"
|
||||
% (kind, sorted(extra)), file=sys.stderr)
|
||||
return 1
|
||||
print("lockfile 校验通过:tag=%s dpkg=%d pip=%d contents=%d"
|
||||
% (data.get("tag"), len(versions["dpkg"]),
|
||||
len(versions["pip"])))
|
||||
len(versions["pip"]),
|
||||
len(data.get("contents") or [])))
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user