Files
dj/model-bridge/build_upgrade.py
T
Codex c151a056de Merge remote-tracking branch 'origin/main'
# Conflicts:
#	huobao-source/backend/src/db/sqlite-schema.ts
2026-11-12 10:40:50 +08:00

38 lines
2.5 KiB
Python

"""Package locally built additions into the verified official 4.0.11 runtime."""
from pathlib import Path
import json,struct,hashlib,shutil
root=Path(__file__).resolve().parent.parent
stage=root/'integration-work/stage-4.0.11/app'
archive=stage/'resources/app.asar'
baseline=archive.with_name('app.official-4.0.11.asar')
if not baseline.exists(): shutil.copy2(archive,baseline)
raw=baseline.read_bytes()
_,header_size,_,json_size=struct.unpack('<4I',raw[:16])
header=json.loads(raw[16:16+json_size]); data=raw[8+header_size:]
replacements={'build/backend.mjs':root/'huobao-source/desktop/build/backend.mjs',
'dist/main.js':root/'huobao-source/desktop/dist/main.js',
'dist/preload.js':root/'huobao-source/desktop/dist/preload.js'}
for target,source in replacements.items():
node=header
for part in target.split('/'): node=node['files'][part]
content=source.read_bytes()
node['size']=len(content); node['offset']=str(len(data))
block_size=4194304
node['integrity']={'algorithm':'SHA256','hash':hashlib.sha256(content).hexdigest(),'blockSize':block_size,
'blocks':[hashlib.sha256(content[i:i+block_size]).hexdigest() for i in range(0,len(content),block_size)]}
data+=content
encoded=json.dumps(header,separators=(',',':')).encode()
padding=b'\0'*((-len(encoded))%4)
size=8+len(encoded)+len(padding)
archive.write_bytes(struct.pack('<4I',4,size,size-4,len(encoded))+encoded+padding+data)
frontend=root/'huobao-source/frontend/.output/public'
shutil.copytree(frontend,stage/'resources/frontend',dirs_exist_ok=True)
for directory in ('prompts', 'skills'):
shutil.copytree(root/'huobao-source/backend/workspace'/directory,
stage/'resources/workspace-template'/directory,dirs_exist_ok=True)
manifest={'upstream_version':'4.0.11','source_commit':'b48e6b2312166e25b1ff141832d2e82e5d63c142',
'custom_features':['persistent-data','local-video-pool','multi-gpu-images','vdn-hd-versions','per-model-gpu-selection','fixed-gpu-models','cancel-and-regenerate','per-shot-routing','direct-comfy-panels','confirmed-worker-labels','asset-image-references','durable-local-task-tracking','cross-episode-continuity','tail-frame-dependency-queue','storyboard-timeline-validation'],
'archive_sha256':hashlib.sha256(archive.read_bytes()).hexdigest()}
(stage/'resources/huobao-local-build.json').write_text(json.dumps(manifest,indent=2))
print('Staged 4.0.11 with persistent data and VDN HD:',manifest['archive_sha256'])