build(packaging): retain qualified payloads through verified owner archives
This commit is contained in:
@@ -62,6 +62,9 @@ def build(report, original=None):
|
||||
"build_owner_release.py",
|
||||
)
|
||||
}
|
||||
files['qualified_payloads.py'] = (
|
||||
ROOT.parents[1] / 'scripts/packaging/qualified_payloads.py'
|
||||
).read_bytes()
|
||||
manifest = {
|
||||
"schema": "missioncore.insta360.owner-wrapper-build/v1",
|
||||
"qualified": json.loads(report.read_text()),
|
||||
|
||||
@@ -4,19 +4,30 @@ import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import zipfile
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
REPO = ROOT.parents[1]
|
||||
# The isolated Ubuntu wrapper carries the exact same helper beside this script.
|
||||
sys.path.insert(0, str(REPO / 'scripts/packaging'))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from qualified_payloads import QualifiedPayloads # noqa: E402
|
||||
|
||||
|
||||
def build(qualified, capture_stitch_input=False, verify_original=None):
|
||||
expected = json.loads((qualified / "package-result.json").read_text())
|
||||
with QualifiedPayloads(qualified, ROOT / 'build', REPO).locked() as store:
|
||||
return _build(store, capture_stitch_input, verify_original)
|
||||
|
||||
|
||||
def _build(store, capture_stitch_input, verify_original):
|
||||
raw_evidence = (store.qualified / "package-result.json").read_bytes()
|
||||
expected = json.loads(raw_evidence)
|
||||
version = expected["version"]
|
||||
if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+(?:-[1-9][0-9]*)?", version):
|
||||
raise ValueError("Invalid qualified version")
|
||||
package_name = "mission-core-insta360-x4_" + version + "_amd64.deb"
|
||||
package = (qualified / package_name).read_bytes()
|
||||
package = store.read(package_name)
|
||||
if (
|
||||
len(package) != expected["bytes"]
|
||||
or hashlib.sha256(package).hexdigest() != expected["sha256"]
|
||||
@@ -49,17 +60,15 @@ def build(qualified, capture_stitch_input=False, verify_original=None):
|
||||
raw = json.dumps(manifest, sort_keys=True, indent=2).encode() + b"\n"
|
||||
ident = hashlib.sha256(raw).hexdigest()[:24]
|
||||
output = ROOT / "build" / ("mission-core-x4-install-" + ident + ".pyz")
|
||||
with output.open("xb") as stream, zipfile.ZipFile(stream, "w") as archive:
|
||||
for name, data in {"__main__.py": entrypoint, "release.json": raw, **files}.items():
|
||||
info = zipfile.ZipInfo(name, date_time=(2026, 9, 8, 0, 0, 0))
|
||||
info.external_attr = 0o600 << 16
|
||||
archive.writestr(info, data)
|
||||
output.chmod(0o600)
|
||||
published = store.publish(output, {"__main__.py": entrypoint, "release.json": raw, **files})
|
||||
store.register(published, {package_name: package}, 'package-result.json', raw_evidence)
|
||||
cleanup = store.closeout()
|
||||
return {
|
||||
"artifact": str(output),
|
||||
"release_id": ident,
|
||||
"bytes": output.stat().st_size,
|
||||
"sha256": hashlib.sha256(output.read_bytes()).hexdigest(),
|
||||
"sha256": published['sha256'],
|
||||
"payload_cleanup": cleanup,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user