367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
118 lines
9.2 KiB
Python
118 lines
9.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Create/verify a private CoW development build; never installs or launches it.
|
|
|
|
Freezes the verified on-disk client and native modules. Account configurations,
|
|
credentials, Wine registries, caches, logs and process state are excluded. This
|
|
is a same-workspace recovery build, not a portable Windows/beta distribution.
|
|
"""
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import time
|
|
|
|
from client_installation import ROOT,COPY,inspect_installation
|
|
|
|
def digest(path):
|
|
value=hashlib.sha256()
|
|
with path.open('rb') as source:
|
|
while block:=source.read(8*1024*1024):value.update(block)
|
|
return value.hexdigest()
|
|
|
|
def inventory(paths):
|
|
result={}
|
|
for path in paths:
|
|
if path.is_symlink():raise ValueError('Linked build input is unsupported')
|
|
entries=[path] if path.is_file() else sorted(path.rglob('*'))
|
|
for entry in entries:
|
|
if entry.is_symlink():raise ValueError('Nested build input link is unsupported')
|
|
if entry.is_dir():continue
|
|
if not entry.is_file():raise ValueError('Nonregular build input')
|
|
stat=entry.stat();result[entry]=(stat.st_size,stat.st_mtime_ns,stat.st_ino)
|
|
return result
|
|
|
|
def verify(directory):
|
|
manifest=json.loads((directory/'manifest.json').read_text())
|
|
if manifest.get('kind')!='private-forever-development-build' or manifest.get('status')!='COMPLETE':raise ValueError('Incomplete/unrecognized build preserved')
|
|
for row in manifest['files']:
|
|
relative=Path(row['path'])
|
|
if relative.is_absolute() or '..' in relative.parts:raise ValueError('Invalid build-relative path')
|
|
path=directory/relative
|
|
if path.is_symlink() or not path.is_file() or path.stat().st_size!=row['bytes'] or digest(path)!=row['sha256']:raise ValueError('Build file differs: '+str(relative))
|
|
if inspect_installation(directory/'client')!=manifest['installation']:raise ValueError('Startup/build identity differs')
|
|
return dict(verified_files=len(manifest['files']),logical_bytes=sum(r['bytes']for r in manifest['files']),status='HASHES_VERIFIED',launched=False)
|
|
|
|
def create(output,revision):
|
|
output=output.absolute()
|
|
if output.exists() or output.is_symlink() or not output.resolve().is_relative_to(ROOT/'runtime/development-builds'):raise ValueError('New owned runtime/development-builds destination required')
|
|
revision=subprocess.run(['git','rev-parse','--verify',revision+'^{commit}'],cwd=ROOT,capture_output=True,text=True,check=True).stdout.strip()
|
|
installed=inspect_installation(COPY)
|
|
host=json.loads((ROOT/'runtime/native-wire-host.json').read_text())
|
|
engine=json.loads((ROOT/'runtime/native-engine-pe.json').read_text())
|
|
for key in('core','wire_unix','source_codec'):
|
|
if digest(Path(host[key+'_path']))!=host[key+'_sha256']:raise ValueError('Installed native dependency differs from verified journal')
|
|
system=ROOT/'runtime/native-wine-prefix/drive_c/windows/system32'
|
|
for name,expected in [('d3d11.dll',engine['dependency_patched_sha256']),('GWNativeBridge.dll',engine['dll_sha256']),('GWNativeWire.dll',host['wire_dll_sha256'])]:
|
|
if digest(system/name)!=expected:raise ValueError('Installed PE dependency differs from journal')
|
|
package=ROOT/'docs/evidence/data/item-sparse-compat/package.json'
|
|
content=json.loads(package.read_text())
|
|
provenance=json.loads((ROOT/'build/forever-schema/provenance.json').read_text())
|
|
if provenance['item_package_sha256']!=digest(package):raise ValueError('Installed codec/content provenance differs')
|
|
# Only immutable client data/code/assets. No WTF, Cache, Errors, Logs,
|
|
# Screenshots, user registries, account directories or process journals.
|
|
client_paths=[COPY/name for name in('.build.info','.product.db','Launcher.db','native-complete-installation.json','Data')]
|
|
game=COPY/'_classic_beta_'
|
|
client_paths += [p for p in sorted(game.iterdir()) if p.is_file() and p.suffix.lower()in('.exe','.dll','.dat','.info')]
|
|
client_paths += [game/name for name in('Interface','Item','Fonts','D3D12','Utils')if (game/name).is_dir()]
|
|
modules=[ROOT/name for name in('build/libgateway_native.so','build/libgateway_wine_wire.so','build/libgateway_native_bootstrap.so',
|
|
'build/forever-schema/libforever_codec.so','build/forever-schema/forever-create-codec','build/forever-schema/provenance.json',
|
|
'runtime/native-engine-pe.json','runtime/native-wire-host.json','docs/evidence/data/item-sparse-compat/package.json','include/gateway/item_sparse_compat.hpp')]
|
|
modules += [system/name for name in('d3d11.dll','GWNativeBridge.dll','GWNativeWire.dll')]
|
|
inputs=inventory(client_paths+modules)
|
|
output.mkdir(parents=True,mode=0o700)
|
|
started=time.monotonic()
|
|
(output/'INCOMPLETE').write_text('Preserve this directory if interrupted. No installation or source files were modified.\n')
|
|
for path in client_paths+modules:
|
|
relative=Path('client')/path.relative_to(COPY) if path in client_paths else Path('workspace-overlay')/path.relative_to(ROOT)
|
|
target=output/relative;target.parent.mkdir(parents=True,exist_ok=True)
|
|
subprocess.run(['cp','--archive','--reflink=always','--',str(path),str(target)],check=True)
|
|
if inventory(client_paths+modules)!=inputs:raise RuntimeError('Live static inputs changed; incomplete build preserved for inspection')
|
|
print('Private CoW copy complete; hashing frozen files. No credentials, registries, caches or logs copied.',flush=True)
|
|
subprocess.run(['git','archive','--format=tar','--output='+str(output/'source.tar'),revision],cwd=ROOT,check=True)
|
|
(output/'build-tools').mkdir()
|
|
shutil.copy2(Path(__file__),output/'build-tools/development_client_build.py')
|
|
rows=[]
|
|
for path in sorted(output.rglob('*')):
|
|
if path.is_dir() or path.name=='INCOMPLETE':continue
|
|
if path.is_symlink():raise RuntimeError('Unexpected build link')
|
|
rows.append(dict(path=str(path.relative_to(output)),bytes=path.stat().st_size,sha256=digest(path)))
|
|
if len(rows)%250==0:print('Hashed',len(rows),'frozen files',flush=True)
|
|
if inspect_installation(output/'client')!=installed:raise RuntimeError('Copied startup identity differs')
|
|
manifest=dict(kind='private-forever-development-build',status='COMPLETE',build='1.60.1.70334',source_commit=revision,
|
|
installation=installed,item_rows=len(content['rows']),files=rows,reflink_required=True,
|
|
elapsed_seconds=round(time.monotonic()-started,3),launched=False,portable_release=False,
|
|
excluded=['credentials/account configuration','Wine registry/prefix state except three pinned PE modules','ADB/WDB caches','logs/crashes/screenshots','uncommitted source','undeployed item-instance-flags codec','Turtle/Octo client or server/database state'],
|
|
dependencies=['Existing private Wine prefix and native owner/bootstrap/trust-key helper','Existing private account/endpoint configuration under secrets, deliberately not bundled','Pinned local Tortoise services for local tests; no external gateway required'],
|
|
rollback='Do not restore over a running client. Normally close it first; preserve its current installation/modules/configuration, then restore the client tree and workspace-overlay paths together. Keep private credentials and endpoint configuration outside this build. No automatic installation is performed.')
|
|
(output/'manifest.json').write_text(json.dumps(manifest,indent=2)+'\n')
|
|
(output/'README.txt').write_text('WoW-Hybrid verified development checkpoint, not a portable distribution.\n'
|
|
'Client and installed modules are frozen; source.tar contains only committed source at the manifest revision.\n'
|
|
'Verify: python3 ops/development_client_build.py --verify '+str(output)+'\n'
|
|
'Current workspace launch (when client interaction resumes): python3 ops/start_native_client.py --endpoint-profile local\n'
|
|
'This command uses the installed workspace, not a separately launched snapshot. Restore only while the client is closed.\n'
|
|
'See manifest rollback/dependencies; secrets and Wine registry are intentionally excluded. Never launch the snapshot by double-clicking WowB.exe: native setup is required.\n')
|
|
# Include README in the checked payload; manifest deliberately excludes itself.
|
|
path=output/'README.txt';manifest['files'].append(dict(path='README.txt',bytes=path.stat().st_size,sha256=digest(path)))
|
|
(output/'manifest.json').write_text(json.dumps(manifest,indent=2)+'\n');(output/'INCOMPLETE').unlink()
|
|
return dict(output=str(output),status='COMPLETE',files=len(manifest['files']),item_rows=len(content['rows']),logical_bytes=sum(r['bytes']for r in manifest['files']),elapsed_seconds=manifest['elapsed_seconds'],launched=False)
|
|
|
|
if __name__=='__main__':
|
|
parser=argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--output',type=Path);parser.add_argument('--source-commit');parser.add_argument('--verify',type=Path)
|
|
args=parser.parse_args();os.umask(0o077)
|
|
if bool(args.verify)==bool(args.output) or (args.output and not args.source_commit):parser.error('Choose --verify BUILD or --output NEW_BUILD --source-commit VERIFIED_COMMIT')
|
|
print(json.dumps(verify(args.verify.resolve())if args.verify else create(args.output,args.source_commit),indent=2))
|