679 lines
48 KiB
Python
679 lines
48 KiB
Python
#!/usr/bin/env python3
|
|
"""Stage a fresh Linux client bundle; never alter an existing installation.
|
|
|
|
The staged launcher needs Wine/Python prerequisites, not a source checkout or
|
|
compiler. Credentials are entered only in Forever. A full stage is explicit;
|
|
unit tests exercise only isolated planning, sanitization and binding contracts.
|
|
"""
|
|
import argparse,ast,hashlib,importlib.util,json,os,re,shutil,subprocess,sys,time,uuid
|
|
from copy import deepcopy
|
|
from pathlib import Path
|
|
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
EXE_SHA='c49ce22c3e0aaeb7a7007a5c5cb792e4c3e6cdecc55a1145a5933fc113e3e57f'
|
|
DXGI_SHA='17cb4fac0e840ac3ae6049c01bfefdc077f4023b24cb985faf282c5b93f455c4'
|
|
MODULES={'wire_unix':'build/libgateway_wine_wire.so','core':'build/libgateway_native.so','source_codec':'build/forever-schema/libforever_codec.so'}
|
|
PRODUCT_FILES=('.build.info','.product.db','Launcher.db')
|
|
DATA_TREES=('config','data','indices','wow_classic_beta')
|
|
GAME_FILES=('.flavor.info','WowB.exe','WowB_loader.dll','icudt78l.dat','BlizzardError.exe','GFSDK_Aftermath_Lib.x64.dll','libxell.dll')
|
|
GAME_TREES=('D3D12','Fonts','Interface','Item','Speech','Utils')
|
|
PROOFS=('docs/evidence/gameplay/native-lifecycle-static-contract.json','docs/evidence/gameplay/reference-instance-deferred-buffer-contract.json')
|
|
FIXED_CODE_DATA=('ops/data/c49-original-function-chain-index.json.zlib',)
|
|
PYTHON_MODULES=('capstone','pefile','Xlib','PIL','evdev')
|
|
PROGRAMS=('python3','wine','wineboot','wineserver','getent','tesseract','cp','kdialog')
|
|
SEEDS=('forever_launcher_backend','start_native_client','debug_client_owner','linux_client_package')
|
|
# The packaged entry invokes --launch-root or --direct-launch-root. These
|
|
# builder-only functions are never reached by either launcher branch, so their
|
|
# imports stay in the source checkout.
|
|
STAGE_ONLY_IMPORT_FUNCTIONS=frozenset({'stage','copy_client_subset','package_warrior_action_bar','package_profession_icon_addon'})
|
|
SAFE_CONFIG={'GxMaximize':'1','GxWindow':'1','gxApi':'D3D11','portal':'127.0.0.1','textLocale':'enUS','audioLocale':'enUS','UnitNameNPC':'1'}
|
|
CONFIG_COPY={'gxWindowedResolution':r'\d{3,5}x\d{3,5}','gxResolution':r'\d{3,5}x\d{3,5}',
|
|
'uiScale':r'(?:0?\.\d{1,6}|1(?:\.0{1,6})?)','useUiScale':r'[01]','UnitNameNPC':r'[01]',
|
|
'masterVolume':r'(?:0?\.\d{1,6}|[01](?:\.0{1,6})?)','Sound_EnableAllSound':r'[01]',
|
|
# Preserve reviewed presentation/accessibility preferences. Omitting these
|
|
# replayed the source's already-viewed intro and reopened narration setup,
|
|
# keeping a fresh bundle away from the original login readiness boundary.
|
|
'playIntroMovie':r'[01]','showPhotosensitivityWarning':r'[01]',
|
|
'showScreenNarrationDialog':r'[01]','accessibilityScreenNarrationEnabled':r'[01]'}
|
|
|
|
def sha(path):
|
|
h=hashlib.sha256()
|
|
with Path(path).open('rb')as f:
|
|
for b in iter(lambda:f.read(1048576),b''):h.update(b)
|
|
return h.hexdigest()
|
|
def read_json(path):
|
|
p=Path(path)
|
|
if p.is_symlink()or not p.is_file()or p.stat().st_size>33554432:raise ValueError('Owned bounded JSON required: '+str(p))
|
|
return json.loads(p.read_text())
|
|
def write_json(path,value):
|
|
path=Path(path);path.parent.mkdir(parents=True,exist_ok=True);tmp=path.with_name(path.name+'.new')
|
|
if tmp.exists()or tmp.is_symlink():raise ValueError('Existing journal partial preserved')
|
|
with tmp.open('x')as f:json.dump(value,f,indent=2,sort_keys=True);f.write('\n');f.flush();os.fsync(f.fileno())
|
|
tmp.chmod(0o600);tmp.replace(path)
|
|
def safe_config(text,*,renderer='D3D11'):
|
|
"""Generate a small public display/language config; never copy account fields."""
|
|
if renderer not in ('D3D11','D3D12'):raise ValueError('Unreviewed release renderer')
|
|
values=dict(SAFE_CONFIG)
|
|
values['gxApi']=renderer
|
|
for key,pattern in CONFIG_COPY.items():
|
|
matches=re.findall(r'^SET '+re.escape(key)+r' "([^"\r\n]*)"\s*$',text,re.M)
|
|
if len(matches)==1 and re.fullmatch(pattern,matches[0]):values[key]=matches[0]
|
|
return ''.join('SET '+k+' "'+v+'"\n'for k,v in sorted(values.items()))
|
|
def owned_regular(path):
|
|
p=Path(path)
|
|
if p.is_symlink()or not p.is_file():raise ValueError('Regular owned source file required: '+str(p))
|
|
return p
|
|
def copy_file(source,target,*,cow=False,require_cow=True):
|
|
source=owned_regular(source);target=Path(target);target.parent.mkdir(parents=True,exist_ok=True)
|
|
if target.exists()or target.is_symlink():raise ValueError('Existing target preserved: '+str(target))
|
|
before=source.stat();token=(before.st_ino,before.st_size,before.st_mtime_ns)
|
|
same_fs=source.stat().st_dev==target.parent.stat().st_dev
|
|
cow_required=cow and same_fs and require_cow
|
|
if cow:subprocess.run(['cp','--reflink=always' if cow_required else '--reflink=auto' if same_fs else '--reflink=never','--preserve=mode,timestamps','--',str(source),str(target)],check=True)
|
|
else:shutil.copy2(source,target)
|
|
after=source.stat()
|
|
if token!=(after.st_ino,after.st_size,after.st_mtime_ns)or target.stat().st_size!=before.st_size:raise ValueError('Source changed during copy')
|
|
if target.stat().st_dev==before.st_dev and target.stat().st_ino==before.st_ino:raise ValueError('Hardlinked release file rejected')
|
|
return dict(bytes=before.st_size,independent_inode=True,cow_required=cow_required)
|
|
def copy_tree(source,target,*,require_cow=True):
|
|
source=Path(source);target=Path(target)
|
|
if source.is_symlink()or not source.is_dir()or target.exists():raise ValueError('Fresh regular source tree required')
|
|
target.parent.mkdir(parents=True,exist_ok=True);inventory={};total=0
|
|
for p in sorted(source.rglob('*')):
|
|
if p.is_symlink():raise ValueError('Source tree link rejected: '+str(p))
|
|
if p.is_file():
|
|
st=p.stat();inventory[p.relative_to(source)]=(st.st_dev,st.st_ino,st.st_size,st.st_mtime_ns);total+=st.st_size
|
|
elif p.is_dir():pass
|
|
else:raise ValueError('Nonregular source tree entry')
|
|
same_fs=source.stat().st_dev==target.parent.stat().st_dev
|
|
cow_required=same_fs and require_cow
|
|
subprocess.run(['cp','--reflink=always' if cow_required else '--reflink=auto' if same_fs else '--reflink=never','--preserve=mode,timestamps','--recursive','--',str(source),str(target)],check=True)
|
|
for relative,token in inventory.items():
|
|
st=(source/relative).stat();copy=(target/relative).stat()
|
|
if(st.st_dev,st.st_ino,st.st_size,st.st_mtime_ns)!=token or copy.st_size!=token[2]or(copy.st_dev,copy.st_ino)==token[:2]:raise ValueError('CASC/resource copy identity or source stability differs')
|
|
return dict(files=len(inventory),bytes=total,independent_files=True,independent_cow_files=cow_required)
|
|
def ops_closure(source_root):
|
|
"""Bounded local Python imports, including fixed dynamic observer profiles."""
|
|
folder=Path(source_root)/'ops';pending=list(SEEDS);seen=set()
|
|
while pending:
|
|
name=pending.pop()
|
|
if name in seen:continue
|
|
path=folder/(name+'.py');owned_regular(path);seen.add(name);tree=ast.parse(path.read_text())
|
|
candidates=[]
|
|
for top in tree.body:
|
|
if name=='linux_client_package' and isinstance(top,(ast.FunctionDef,ast.AsyncFunctionDef)) and top.name in STAGE_ONLY_IMPORT_FUNCTIONS:continue
|
|
for n in ast.walk(top):
|
|
if isinstance(n,ast.Import):candidates.extend(a.name.split('.')[0]for a in n.names)
|
|
elif isinstance(n,ast.ImportFrom)and n.module:candidates.append(n.module.split('.')[0])
|
|
# Fixed dynamic observers in engine_boundary_catalog.PROFILES.
|
|
elif isinstance(n,ast.Constant)and isinstance(n.value,str)and re.fullmatch(r'engine_[a-z_]+',n.value):candidates.append(n.value)
|
|
pending.extend(n for n in candidates if n not in seen and(folder/(n+'.py')).is_file())
|
|
if len(seen)>400:raise ValueError('Unexpected Python runtime dependency expansion')
|
|
return sorted('ops/'+n+'.py'for n in seen)
|
|
def lifecycle_pages(source_root):
|
|
source_root=Path(source_root);tree=ast.parse((source_root/'ops/native_lifecycle_audit.py').read_text());specs=[]
|
|
for n in ast.walk(tree):
|
|
if isinstance(n,ast.For)and isinstance(n.target,ast.Name)and n.target.id=='spec':specs.extend(ast.literal_eval(n.iter))
|
|
pages=sorted({r[0]&~4095 for r in specs})
|
|
if len(pages)!=31:raise ValueError('Reviewed lifecycle page scope changed')
|
|
paths=[]
|
|
for page in pages:
|
|
p=source_root/'runtime/native-handler-code'/f'{page:x}.bin'
|
|
if not p.exists():p=source_root/'runtime/native-netclient'/f'live-{page-0x140000000:x}.bin'
|
|
if owned_regular(p).stat().st_size!=4096:raise ValueError('Complete captured code page required')
|
|
paths.append(p.relative_to(source_root))
|
|
return paths
|
|
def client_running(client):
|
|
expected=str(Path(client).resolve()/'_classic_beta_/WowB.exe');argvs=(expected.encode(),('Z:'+expected.replace('/','\\')).encode())
|
|
for p in Path('/proc').iterdir():
|
|
if not p.name.isdigit():continue
|
|
try:
|
|
args=(p/'cmdline').read_bytes().split(b'\0')
|
|
if any(v in args for v in argvs):return True
|
|
if (p/'comm').read_text().strip()=='WowB.exe' and (p/'cwd').resolve()==Path(expected).parent:return True
|
|
except OSError:pass
|
|
return False
|
|
|
|
def inprocess_startup_state(text):
|
|
"""The carrier's event1 follows successful Bridge init and hook creation.
|
|
|
|
Login-site event5 requires real user input and is deliberately not a launch
|
|
health check. This contract is shared by the accepted D3D11/D3D12 wrappers.
|
|
"""
|
|
for line in text.splitlines():
|
|
if not line.startswith('GW_LOGIN_SITE event=1 '):continue
|
|
fields=dict(re.findall(r'\b([a-z_]+)=(\d+)\b',line))
|
|
if not {'query','error','pid','tid'}<=fields.keys():continue
|
|
if int(fields['error']):return 'failed'
|
|
if int(fields['query']) and int(fields['pid']) and int(fields['tid']):return 'ready'
|
|
return 'pending'
|
|
|
|
def wait_inprocess_startup(process,journal,timeout):
|
|
deadline=time.monotonic()+timeout
|
|
while True:
|
|
try:state=inprocess_startup_state(Path(journal).read_text(errors='replace'))
|
|
except FileNotFoundError:state='pending'
|
|
if state=='failed':raise RuntimeError('The client gateway could not initialise. See the private startup log.')
|
|
if process.poll() is not None:raise RuntimeError('The client closed before its gateway was ready. See runtime/play-last.log.')
|
|
if state=='ready':return
|
|
if time.monotonic()>=deadline:raise TimeoutError('The client gateway did not initialise in time. See the private startup log.')
|
|
time.sleep(.1)
|
|
|
|
def launch_inprocess(root,*,startup_timeout=120):
|
|
"""Launch the reviewed in-process bundle directly; own only this child.
|
|
|
|
This route does not start or stop an external gateway. The carrier initialises
|
|
the gateway inside WowB; process shutdown owns its lifetime. It never reads
|
|
account fields or injects input.
|
|
"""
|
|
import fcntl
|
|
import signal
|
|
root=Path(root).resolve();runtime=root/'runtime'
|
|
bootstrap_path=owned_regular(runtime/'native-dx12-bootstrap.json')
|
|
manifest=read_json(bootstrap_path)
|
|
if manifest.get('kind')!='native-inprocess-dx12-v1':raise ValueError('A verified direct DX12 installation is required')
|
|
release_path=root/'linux-release.json'
|
|
if release_path.exists():
|
|
release=read_json(release_path)
|
|
if release.get('dx12_public_bundle'):
|
|
if (release.get('runtime_file_sha256',{}).get('runtime/native-dx12-bootstrap.json')!=sha(bootstrap_path)
|
|
or manifest.get('source_profile')!=2
|
|
or manifest.get('public_authentication_tested') is not False):
|
|
raise ValueError('Public DX12 profile-2 release receipt differs')
|
|
required={'runtime/native-client/_classic_beta_/WowB.exe',
|
|
'runtime/native-wine-prefix/drive_c/windows/system32/d3d12.dll',
|
|
'runtime/native-wine-prefix/drive_c/windows/system32/d3d12core.dll',
|
|
'runtime/native-wine-prefix/drive_c/windows/system32/dxgi.dll',
|
|
'runtime/native-wine-prefix/drive_c/windows/system32/GWNativeBridge.dll',
|
|
'runtime/native-wine-prefix/drive_c/windows/system32/GWNativeWire.dll',
|
|
*MODULES.values()}
|
|
files=manifest.get('runtime_file_sha256',{})
|
|
if not required<=files.keys():raise ValueError('The direct DX12 installation record is incomplete')
|
|
for relative,digest in files.items():
|
|
path=root/relative
|
|
if Path(relative).is_absolute()or not path.resolve().is_relative_to(root)or sha(owned_regular(path))!=digest:
|
|
raise ValueError('Direct DX12 runtime identity differs: '+relative)
|
|
client=runtime/'native-client'
|
|
if client_running(client):raise ValueError('This client is already running')
|
|
lock=owned_regular(runtime/'native-launcher.lock') if (runtime/'native-launcher.lock').exists() else runtime/'native-launcher.lock'
|
|
with lock.open('a+') as lease:
|
|
os.chmod(lock,0o600)
|
|
try:fcntl.flock(lease.fileno(),fcntl.LOCK_EX|fcntl.LOCK_NB)
|
|
except BlockingIOError:raise ValueError('This client is already starting or running')from None
|
|
env=dict(os.environ,WINEARCH='win64',WINEPREFIX=str(runtime/'native-wine-prefix'),WINEDEBUG='-all')
|
|
for name in ('LD_PRELOAD','GW_NATIVE_BOOTSTRAP','GW_NATIVE_EXPECTED_EXE','GW_NATIVE_REGISTER','GAMESCOPE_DISPLAY','GAMESCOPE_WAYLAND_DISPLAY'):
|
|
env.pop(name,None)
|
|
requested=env.get('GW_NATIVE_STARTUP_LOG')
|
|
if requested:
|
|
if not requested.startswith('Z:'):raise ValueError('Startup log must use the owned runtime')
|
|
journal=Path(requested[2:].replace('\\','/')).resolve()
|
|
if not journal.is_relative_to(runtime):raise ValueError('Startup log escaped the owned runtime')
|
|
else:
|
|
folder=runtime/'launch-logs';folder.mkdir(exist_ok=True)
|
|
journal=folder/(time.strftime('%Y%m%d-%H%M%S')+'-'+uuid.uuid4().hex+'.private.log')
|
|
env['GW_NATIVE_STARTUP_LOG']='Z:'+str(journal).replace('/','\\')
|
|
fd=os.open(journal,os.O_WRONLY|os.O_CREAT|os.O_EXCL,0o600);os.close(fd)
|
|
command=['wine',str(client/'_classic_beta_/WowB.exe'),'-console','-d3d12']
|
|
process=None;handlers={}
|
|
try:
|
|
with (runtime/'play-last.log').open('wb') as log:
|
|
os.chmod(log.name,0o600)
|
|
process=subprocess.Popen(command,cwd=client/'_classic_beta_',env=env,stdout=log,stderr=subprocess.STDOUT)
|
|
def forward(signum,_frame):
|
|
if process.poll() is None:process.send_signal(signum)
|
|
for signum in (signal.SIGTERM,signal.SIGINT):
|
|
handlers[signum]=signal.signal(signum,forward)
|
|
wait_inprocess_startup(process,journal,startup_timeout)
|
|
write_json(runtime/'native-launcher-status.json',dict(state='ready',gateway='in-process',renderer='D3D12',client_pid=process.pid,startup_log=str(journal)))
|
|
print('Client gateway ready; direct DX12.',flush=True)
|
|
result=process.wait()
|
|
write_json(runtime/'native-launcher-status.json',dict(state='closed',gateway='in-process',renderer='D3D12',client_pid=process.pid,exit_code=result,startup_log=str(journal)))
|
|
return result
|
|
except BaseException:
|
|
if process is not None and process.poll() is None:
|
|
process.terminate()
|
|
try:process.wait(timeout=10)
|
|
except subprocess.TimeoutExpired:process.kill();process.wait(timeout=5)
|
|
raise
|
|
finally:
|
|
for signum,handler in handlers.items():signal.signal(signum,handler)
|
|
def prerequisites():
|
|
missing=[x for x in PROGRAMS if not shutil.which(x)]
|
|
qdbus=shutil.which('qdbus6')or shutil.which('qdbus')
|
|
if not qdbus:missing.append('qdbus6 or qdbus (visible login readiness)')
|
|
code='import importlib,json\nr={}\nfor n in '+repr(PYTHON_MODULES)+':\n try: importlib.import_module(n);r[n]=True\n except (ImportError,OSError): r[n]=False\nprint(json.dumps(r))'
|
|
result=subprocess.run([sys.executable,'-c',code],capture_output=True,text=True,timeout=10,check=True)
|
|
modules=json.loads(result.stdout);missing+=['python:'+k for k,v in modules.items()if not v]
|
|
if missing:raise ValueError('Linux runtime prerequisites missing: '+', '.join(missing))
|
|
wine=subprocess.run(['wine','--version'],capture_output=True,text=True,timeout=10,check=True).stdout.strip()
|
|
return dict(programs=list(PROGRAMS),readiness_dbus_program=Path(qdbus).name,python_modules=list(PYTHON_MODULES),wine_version=wine,display_required_at_launch='X11 or XWayland DISPLAY',ptrace_required='same-user child ptrace and /proc access',system_libraries=['libcrypto.so.3','libz.so.1','libstdc++.so.6','libgcc_s.so.1','libm.so.6','libc.so.6'])
|
|
def elf_requirements(path):
|
|
"""Packaging-time readelf only; the final launcher uses the host ELF loader."""
|
|
result=subprocess.run(['readelf','--version-info','--wide',str(path)],env=dict(os.environ,LC_ALL='C'),capture_output=True,text=True,timeout=30,check=True)
|
|
in_needs=False;library=None;requires={}
|
|
for line in result.stdout.splitlines():
|
|
if line.startswith('Version needs section'):in_needs=True;continue
|
|
if line.startswith('Version ')and not line.startswith('Version needs section'):in_needs=False
|
|
if not in_needs:continue
|
|
match=re.search(r'\bFile:\s+(\S+)',line)
|
|
if match:library=match[1];requires.setdefault(library,[])
|
|
match=re.search(r'\bName:\s+(\S+)',line)
|
|
if match:
|
|
if library is None:raise ValueError('ELF version requirement lacks library identity')
|
|
requires[library].append(match[1])
|
|
if not requires:raise ValueError('Selected native module has no reviewed ELF dependency requirements')
|
|
return {k:sorted(set(v))for k,v in sorted(requires.items())}
|
|
def source_git_revision(source_root):
|
|
"""Capture release provenance during staging; packaged runtime never needs git."""
|
|
result=subprocess.run(['git','rev-parse','HEAD'],cwd=Path(source_root),capture_output=True,text=True,timeout=10,check=True)
|
|
revision=result.stdout.strip()
|
|
if not re.fullmatch(r'[0-9a-f]{40}',revision):raise ValueError('Exact source Git revision required for release provenance')
|
|
return revision
|
|
def validate_elf_loader(root):
|
|
"""Fail before Wine/login if this host cannot load the exact packaged modules."""
|
|
command='import ctypes,os,sys; handles=[ctypes.CDLL(p,mode=os.RTLD_NOW|os.RTLD_LOCAL) for p in sys.argv[1:]]'
|
|
files=[str(Path(root)/relative)for relative in MODULES.values()]
|
|
r=subprocess.run([sys.executable,'-c',command,*files],capture_output=True,text=True,timeout=20)
|
|
if r.returncode:raise ValueError('This Linux host cannot load the packaged ELF ABI dependencies; see linux-release.json abi_requirements (glibc/libstdc++/OpenSSL/zlib).')
|
|
def verified_bindings(source_root):
|
|
root=Path(source_root).resolve();meta=read_json(root/'runtime/native-engine-pe.json')
|
|
if meta.get('restored')or meta.get('original_sha256')!=EXE_SHA or meta.get('patched_sha256')!=EXE_SHA:raise ValueError('Exact unchanged source client/native host required')
|
|
source=root/'runtime/native-wine-prefix/drive_c/windows/system32';aux=meta.get('auxiliary_dependencies')
|
|
if not isinstance(aux,list)or len(aux)!=1 or aux[0].get('file')!='GWNativeWire.dll':raise ValueError('Exact auxiliary wire dependency required')
|
|
dlls={'d3d11.dll':meta['dependency_patched_sha256'],'dxgi.dll':DXGI_SHA,'GWNativeBridge.dll':meta['dll_sha256'],'GWNativeWire.dll':aux[0]['sha256']}
|
|
for name,digest in dlls.items():
|
|
if sha(owned_regular(source/name))!=digest:raise ValueError('Source native DLL hash differs: '+name)
|
|
peer=meta['wire_unix_library']
|
|
for role,relative in MODULES.items():
|
|
path=root/relative
|
|
if Path(peer[role+'_path']).resolve()!=path.resolve() or sha(owned_regular(path))!=peer[role+'_sha256']:raise ValueError('Source Unix module identity differs: '+role)
|
|
template=deepcopy(meta);template.pop('wine_prefix',None)
|
|
for role,relative in MODULES.items():template['wire_unix_library'][role+'_path']=relative
|
|
template['rollback']='Preserve this bundle or remove its whole fresh output folder after closing its client; original installations are unchanged.'
|
|
return template,dlls
|
|
def rebased_journal(template,root):
|
|
root=Path(root).resolve();meta=deepcopy(template);meta['wine_prefix']=str(root/'runtime/native-wine-prefix')
|
|
for role,relative in MODULES.items():
|
|
if meta['wire_unix_library'][role+'_path']!=relative:raise ValueError('Only fixed relative module template paths allowed')
|
|
meta['wire_unix_library'][role+'_path']=str(root/relative)
|
|
return meta
|
|
def initialize_prefix(prefix):
|
|
prefix=Path(prefix)
|
|
if prefix.exists()or prefix.is_symlink():raise ValueError('Wine prefix must be newly generated')
|
|
env=dict(os.environ,WINEPREFIX=str(prefix),WINEARCH='win64',WINEDEBUG='-all',WINEDLLOVERRIDES='winemenubuilder.exe=d;mscoree,mshtml=')
|
|
for key in('LD_PRELOAD','GW_NATIVE_BOOTSTRAP','GW_NATIVE_EXPECTED_EXE'):env.pop(key,None)
|
|
try:
|
|
subprocess.run(['wineboot','--init'],env=env,capture_output=True,check=True,timeout=120)
|
|
except subprocess.CalledProcessError as e:
|
|
diagnostic=prefix.parent/'wine-prefix-init-failure.log'
|
|
diagnostic.write_bytes((e.stdout or b'')+(e.stderr or b''));diagnostic.chmod(0o600)
|
|
raise
|
|
subprocess.run(['wineserver','-w'],env=env,capture_output=True,check=True,timeout=60)
|
|
system=prefix/'drive_c/windows/system32'
|
|
if not system.is_dir()or not system.resolve().is_relative_to(prefix.resolve()):raise ValueError('Fresh Wine system directory escaped prefix')
|
|
return env
|
|
def install_prefix_dlls(source_root,prefix,dlls,env,*,public_sources=None,overrides=('d3d11','dxgi')):
|
|
prefix=Path(prefix);system=prefix/'drive_c/windows/system32'
|
|
if prefix.is_symlink()or not system.is_dir()or not system.resolve().is_relative_to(prefix.resolve()):raise ValueError('Fresh Wine system directory escaped prefix')
|
|
for name,digest in dlls.items():
|
|
p=(Path(public_sources[name]) if public_sources is not None else
|
|
Path(source_root)/'runtime/native-wine-prefix/drive_c/windows/system32'/name)
|
|
if sha(owned_regular(p))!=digest:raise ValueError('Native DLL source changed')
|
|
target=system/name
|
|
# Fresh Wine builtins may be symlinks; unlink only that newly created leaf.
|
|
# Never follow it into the host Wine installation when replacing the DLL.
|
|
if target.is_symlink()or target.is_file():target.unlink()
|
|
copy_file(p,target)
|
|
if sha(target)!=digest:raise ValueError('Fresh prefix native DLL readback differs')
|
|
for name in overrides:
|
|
subprocess.run(['wine','reg','add','HKCU\\Software\\Wine\\DllOverrides','/v',name,'/t','REG_SZ','/d','native','/f'],env=env,capture_output=True,check=True,timeout=30)
|
|
subprocess.run(['wineserver','-w'],env=env,capture_output=True,check=True,timeout=60)
|
|
write_json(prefix/'gateway-private-prefix.json',dict(kind='fresh-release-wine-prefix',copied_registry=False,copied_user_profile=False,native_dlls=dlls))
|
|
def package_warrior_action_bar(source_root, client_target, asset_output, *, compacted_content=None):
|
|
from published_client_assets import retained_bar_package
|
|
retained=retained_bar_package(source_root,client_target,compacted_content=compacted_content)
|
|
if retained is not None:return retained
|
|
# Operate only on the already verified fresh CoW copy; original UI FDID is kept.
|
|
from warrior_action_bar_ui import stage_ui_assets,apply_to_fresh_client,FID,SOURCE_SHA,PATCH_SHA
|
|
staged=stage_ui_assets(source_root,asset_output)
|
|
applied=apply_to_fresh_client(source_root,client_target,asset_output,running_check=client_running)
|
|
files={'runtime/native-client/'+name:digest for name,digest in applied['published_files_sha256'].items()}
|
|
report=Path(client_target)/'warrior-action-bar-casc.json'
|
|
files['runtime/native-client/warrior-action-bar-casc.json']=sha(report)
|
|
return dict(kind='original-controller-warrior-stance-page-policy-v1',file_data_id=FID,source_sha256=SOURCE_SHA,patched_source_sha256=PATCH_SHA,original_branch_only=True,old_registered_asset_count=6760,all_old_tvfs_paths_and_spans_preserved=staged['all_old_tvfs_paths_and_spans_preserved'],root_audit=staged['root_audit'],native_engine_acceptance_verified=False,files=files,new_build_config=applied['new_build_config'])
|
|
|
|
def launcher_profile(root):
|
|
return dict(schema=1,runtime_root='..',platforms=dict(linux=dict(status='available',backend='ops/forever_launcher_backend.py',sha256=sha(Path(root)/'ops/forever_launcher_backend.py'),python='python3'),windows=dict(status='blocked-native-runtime-port',backend='bin/ForeverBootstrap.exe')))
|
|
|
|
def package_profession_icon_addon(source_root, client_target, *, include_talents=False, discard_copied=False, ui_base=None):
|
|
"""Stage the canonical UI addon and its optional source-bound talent closure."""
|
|
from published_client_assets import ui_load_entries,discard_copied_packaged_addons
|
|
import weapon_presentation_dependency as weapon
|
|
source_root=Path(source_root).resolve();client_target=Path(client_target)
|
|
if type(include_talents)is not bool:raise ValueError('Explicit talent component selection required')
|
|
source=source_root/'client_addons/WoWHybridUI'
|
|
manifest=owned_regular(source/weapon.TOC)
|
|
source_toc=manifest.read_bytes();toc=source_toc
|
|
entries=ui_load_entries(source_toc)
|
|
inputs={weapon.TOC:manifest, **{entry:source/entry for entry in entries}}
|
|
diagnostics=source_root/'client_addons/GatewayDiagnostics'
|
|
relative=Path('_classic_beta_/Interface/AddOns/WoWHybridUI')
|
|
accepted_root=Path(ui_base or source_root.parent/'builds/Forever-Base-20261118').resolve()
|
|
accepted_addon=accepted_root/'native-client'/relative
|
|
weapon_entries={weapon.DATA,weapon.PROVIDER}.intersection(entries)
|
|
if weapon_entries and len(weapon_entries)!=2:raise ValueError('Incomplete Source weapon presentation in native UI manifest')
|
|
talents=('TurtleData.lua','TurtleTalentProvider.lua','TurtleTalents.lua')
|
|
canonical_talents=set(entries).intersection(talents)
|
|
if canonical_talents:
|
|
ordered=[entries.index(name) for name in talents if name in entries]
|
|
dependency=any(line.startswith('## Dependencies:') and
|
|
'Blizzard_SharedTalentUI' in line.partition(':')[2].replace(',',' ').split()
|
|
for line in source_toc.decode('utf-8').splitlines())
|
|
if len(canonical_talents)!=3 or ordered!=sorted(ordered) or not dependency:
|
|
raise ValueError('Incomplete or unordered canonical talent closure/dependency')
|
|
# Current canonical manifests already own their talent data and providers.
|
|
# Optional generation is only for older manifests which have no such closure.
|
|
append_talents=include_talents and not canonical_talents
|
|
talents_included=bool(canonical_talents or include_talents)
|
|
local_talents=source_root/'build/turtle-data/TurtleData.lua'
|
|
base_manifest={}
|
|
if weapon_entries or (append_talents and not local_talents.exists() and accepted_addon.is_dir()):
|
|
base_manifest=read_json(accepted_root/'base-manifest.json')
|
|
if append_talents:
|
|
inputs.update({'TurtleData.lua':local_talents,
|
|
'TurtleTalentProvider.lua':diagnostics/'TurtleTalentProvider.lua',
|
|
'TurtleTalents.lua':diagnostics/'TurtleTalents.lua'})
|
|
if not inputs['TurtleData.lua'].exists():
|
|
packaged=accepted_addon/'TurtleData.lua'
|
|
pins=[r for r in base_manifest.get('selected_files',[]) if r['path']==str(Path('native-client')/relative/packaged.name)]
|
|
if len(pins)!=1 or not packaged.is_file():raise ValueError('Required generated talent prerequisite missing: '+str(inputs['TurtleData.lua']))
|
|
if sha(owned_regular(packaged))!=pins[0]['sha256']:raise ValueError('Generated talent prerequisite differs from accepted package')
|
|
inputs['TurtleData.lua']=packaged
|
|
toc=toc.replace(b'equipment appearance uses server-confirmed compatibility state.',
|
|
b'equipment appearance and source-bound talents use authenticated compatibility-session state.')
|
|
toc+=b'\n## Dependencies: Blizzard_SharedTalentUI\nTurtleData.lua\nTurtleTalentProvider.lua\nTurtleTalents.lua\n'
|
|
# This generated dataset and its consumer were qualified together in the portable base.
|
|
if weapon_entries:
|
|
pins=base_manifest['source_weapon_presentation']
|
|
proof=weapon.verify(accepted_addon,provider_sha256=pins['provider_sha256'],
|
|
data_sha256=pins['data_sha256'],toc_bytes=toc)
|
|
inputs[weapon.DATA]=accepted_addon/weapon.DATA
|
|
inputs[weapon.PROVIDER]=diagnostics/weapon.PROVIDER
|
|
if sha(owned_regular(inputs[weapon.PROVIDER]))!=proof['provider_sha256']:
|
|
raise ValueError('Source weapon presentation provider differs from accepted package')
|
|
for name,item in inputs.items():
|
|
owned_regular(item)
|
|
allowed=accepted_root if item.parent==accepted_addon else source_root
|
|
if not item.resolve().is_relative_to(allowed):raise ValueError('UI component source escapes package root')
|
|
names=(weapon.TOC,*ui_load_entries(toc))
|
|
expected={name:(toc if name==weapon.TOC else inputs[name].read_bytes()) for name in names}
|
|
if weapon_entries:
|
|
for name,pin in ((weapon.DATA,proof['data_sha256']),(weapon.PROVIDER,proof['provider_sha256'])):
|
|
if hashlib.sha256(expected[name]).hexdigest()!=pin:raise ValueError('Source weapon dependency changed before staging: '+name)
|
|
if discard_copied:discard_copied_packaged_addons(client_target,ui_toc=source_toc)
|
|
destination=client_target/relative
|
|
for parent in (client_target,*[client_target/Path(*relative.parts[:i]) for i in range(1,len(relative.parts))]):
|
|
if parent.is_symlink():raise ValueError('Profession icon destination contains symlink')
|
|
legacy=client_target/'_classic_beta_/Interface/AddOns/WoWHybridProfessionIcons'
|
|
if legacy.exists()or legacy.is_symlink():raise ValueError('Duplicate profession icon addon remains in release copy')
|
|
if destination.is_symlink()or(destination.exists() and not destination.is_dir()):raise ValueError('Profession UI addon destination is not a regular directory')
|
|
if destination.exists():
|
|
if any(p.is_symlink()or not p.is_file()for p in destination.iterdir()):raise ValueError('Profession UI addon contains non-file entry')
|
|
if {p.name for p in destination.iterdir()}-set(names):raise ValueError('Profession UI addon has undeclared files')
|
|
for name in names:
|
|
target=destination/name
|
|
if target.exists():
|
|
current=target.read_bytes()
|
|
if current!=expected[name] and not (name==weapon.TOC and include_talents and current==source_toc):
|
|
raise ValueError('Copied profession UI file differs from source: '+name)
|
|
destination.mkdir(parents=True,exist_ok=True)
|
|
files={};source_files={}
|
|
for name in names:
|
|
target=destination/name
|
|
source_files[str(relative/name)]=dict(path=str(inputs[name]),sha256=hashlib.sha256(source_toc if name==weapon.TOC else expected[name]).hexdigest())
|
|
if not target.exists() or target.read_bytes()!=expected[name]:target.write_bytes(expected[name])
|
|
files[str(relative/name)]=sha(target)
|
|
if weapon_entries:weapon.verify(destination,provider_sha256=proof['provider_sha256'],data_sha256=proof['data_sha256'])
|
|
entries=ui_load_entries((destination/weapon.TOC).read_bytes())
|
|
if entries!=list(names[1:]):raise ValueError('Profession UI load order differs')
|
|
return dict(addon='WoWHybridUI',files=files,source_files=source_files,load_order=entries,
|
|
talents_included=talents_included,native_dependencies=['Blizzard_SharedTalentUI']if talents_included else [],
|
|
duplicate_profession_addon_published=False,exact_border_override_scope='white',
|
|
nonwhite_live_acceptance_verified=False)
|
|
|
|
def package_warrior_stance_addon(source_root, client_target):
|
|
"""Package the source-bound single-press Warrior stance addon."""
|
|
source_root=Path(source_root).resolve();client_target=Path(client_target)
|
|
source=source_root/'client_addons/WoWHybridWarriorStance'
|
|
names=('WoWHybridWarriorStance.toc','SourcePolicies.lua','WarriorStance.lua')
|
|
for name in names:
|
|
item=source/name;owned_regular(item)
|
|
if not item.resolve().is_relative_to(source_root):raise ValueError('Warrior stance source escapes checkout')
|
|
relative=Path('_classic_beta_/Interface/AddOns/WoWHybridWarriorStance')
|
|
destination=client_target/relative
|
|
if destination.exists()or destination.is_symlink():raise ValueError('Warrior stance addon destination already exists')
|
|
for parent in (client_target,*[client_target/Path(*relative.parts[:i])for i in range(1,len(relative.parts))]):
|
|
if parent.is_symlink():raise ValueError('Warrior stance destination contains symlink')
|
|
destination.mkdir(parents=True)
|
|
files={}
|
|
for name in names:
|
|
copy_file(source/name,destination/name);files[str(relative/name)]=sha(destination/name)
|
|
return dict(addon='WoWHybridWarriorStance',files=files,source_bound_policies=True,single_press_stance_action_requested=True,native_engine_acceptance_verified=False)
|
|
|
|
def copy_client_subset(client,target,*,compacted_content=None,renderer='D3D11'):
|
|
"""Explicit product/content resource allowlist; never copy account state."""
|
|
client=Path(client);target=Path(target);copied={};trees={}
|
|
if target.exists()or target.is_symlink():raise ValueError('Fresh client destination required')
|
|
compact_files={}if compacted_content is None else{r['relative']:r for r in compacted_content['generated_files']}
|
|
for relative in PRODUCT_FILES:
|
|
source=Path(compact_files[relative]['source'])if relative in compact_files else client/relative
|
|
copied[relative]=copy_file(source,target/relative)
|
|
for name in DATA_TREES:
|
|
if name=='data'and compacted_content is not None:
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
selected=compacted_content['base_files']+[r for r in compacted_content['generated_files']if r['relative'].startswith('Data/data/')]
|
|
(target/'Data/data').mkdir(parents=True)
|
|
def transfer(row):return copy_file(Path(row['source']),target/row['relative'],cow=True,require_cow=False)
|
|
with ThreadPoolExecutor(max_workers=4)as pool:list(pool.map(transfer,selected))
|
|
trees['Data/data']=dict(files=len(selected),bytes=sum(r['bytes']for r in selected),independent_files=True,independent_cow_files=False,compacted_current_root=True)
|
|
else:trees['Data/'+name]=copy_tree(client/'Data'/name,target/'Data'/name,require_cow=compacted_content is None)
|
|
if compacted_content is not None:
|
|
for relative,row in compact_files.items():
|
|
if relative.startswith('Data/config/'):
|
|
destination=target/relative
|
|
if destination.exists():
|
|
if destination.read_bytes()!=Path(row['source']).read_bytes():raise ValueError('Generated configuration hash-name collision')
|
|
else:copy_file(Path(row['source']),destination)
|
|
|
|
for name in GAME_FILES:
|
|
relative='_classic_beta_/'+name;copied[relative]=copy_file(client/relative,target/relative,cow=True,require_cow=compacted_content is None)
|
|
for name in GAME_TREES:
|
|
p=client/'_classic_beta_'/name
|
|
if p.exists():trees['_classic_beta_/'+name]=copy_tree(p,target/'_classic_beta_'/name,require_cow=compacted_content is None)
|
|
config_source=client/'_classic_beta_/WTF/Config.wtf';text=''
|
|
if config_source.is_file()and not config_source.is_symlink():
|
|
if config_source.stat().st_size>65536:raise ValueError('Source display configuration exceeds public allowlist bound')
|
|
text=config_source.read_text()
|
|
config=target/'_classic_beta_/WTF/Config.wtf';config.parent.mkdir();config.write_text(safe_config(text,renderer=renderer))
|
|
return copied,trees
|
|
def prepare_runtime(root,*,check_only=False,check_prerequisites=True):
|
|
"""Verify immutable release files, then rebase only its generated host journal."""
|
|
root=Path(root).resolve();manifest=read_json(root/'linux-release.json')
|
|
if manifest.get('kind')!='linux-forever-client-folder-package-v1':raise ValueError('Prepared Linux client bundle required')
|
|
if check_prerequisites:prerequisites()
|
|
for relative,digest in manifest['runtime_file_sha256'].items():
|
|
p=root/relative
|
|
if Path(relative).is_absolute()or not p.resolve().is_relative_to(root)or sha(owned_regular(p))!=digest:raise ValueError('Release runtime identity differs: '+relative)
|
|
if check_prerequisites:validate_elf_loader(root)
|
|
if manifest.get('dx12_public_bundle'):
|
|
bootstrap=read_json(root/'runtime/native-dx12-bootstrap.json')
|
|
if (bootstrap.get('kind')!='native-inprocess-dx12-v1'
|
|
or bootstrap.get('source_profile')!=2
|
|
or bootstrap.get('public_authentication_tested') is not False
|
|
or bootstrap.get('runtime_file_sha256') is None):
|
|
raise ValueError('Public DX12 direct launch receipt differs')
|
|
for relative,digest in bootstrap['runtime_file_sha256'].items():
|
|
path=root/relative
|
|
if Path(relative).is_absolute()or not path.resolve().is_relative_to(root)or sha(owned_regular(path))!=digest:
|
|
raise ValueError('Public DX12 direct launch identity differs: '+relative)
|
|
return dict(ready=True,direct_inprocess_dx12=True,source_profile=2,
|
|
public_authentication_tested=False,credentials_included=False,
|
|
source_checkout_required=False,launch_performed=False)
|
|
template=read_json(root/'compat/native-engine-template.json');expected=rebased_journal(template,root)
|
|
journal=root/'runtime/native-engine-pe.json'
|
|
same=journal.exists()and read_json(journal)==expected
|
|
if not same and not check_only:
|
|
if client_running(root/'runtime/native-client'):raise ValueError('Close bundle client before rebasing its runtime journal')
|
|
write_json(journal,expected)
|
|
return dict(ready=True,journal_rebase_needed=not same,credentials_included=False,source_checkout_required=False,launch_performed=False)
|
|
def frontend(root):
|
|
root=Path(root).resolve();path=owned_regular(root/'launcher/launcher.py');manifest=read_json(root/'linux-release.json')
|
|
if sha(path)!=manifest['runtime_file_sha256'].get('launcher/launcher.py'):raise ValueError('Launcher identity differs')
|
|
spec=importlib.util.spec_from_file_location('packaged_launcher',path);m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);return m
|
|
def visible_error(message,launcher=None):
|
|
if launcher is not None:
|
|
launcher.notify_error(message);return
|
|
# If the launcher itself is missing/corrupt, use the same fixed OS dialog
|
|
# fallback without importing an unverified file or executing a shell.
|
|
for program,args in [('kdialog',['--error',message,'--title','WoW-Hybrid launcher']),('zenity',['--error','--title=WoW-Hybrid launcher','--text='+message])]:
|
|
if shutil.which(program):subprocess.run([program,*args],check=False);return
|
|
print(message,file=sys.stderr)
|
|
def stage(source_root,output,protocol_directory,*,prefix_initializer=initialize_prefix,check_prerequisites=True,allow_running_published_source=False,compacted_content=None,dx12_public_bundle=None):
|
|
if Path(output).exists()or Path(output).is_symlink():raise ValueError('Fresh output folder required; existing output preserved')
|
|
source_root=Path(source_root).resolve();output=Path(output).resolve()
|
|
for relative in('compat/octowow/version-hash.bin','compat/octowow/addon-tail.bin'):
|
|
try:encoded=str(output/relative).encode('ascii')
|
|
except UnicodeEncodeError:raise ValueError('Current native protocol path ABI requires an ASCII bundle location')
|
|
if len(encoded)>=512:raise ValueError('Bundle protocol path exceeds native512-byte field')
|
|
if output.exists()or output.is_symlink()or not output.parent.is_dir():raise ValueError('Fresh output folder required; existing output preserved')
|
|
if output.is_relative_to(source_root/'runtime/native-client')or source_root.is_relative_to(output):raise ValueError('Release output cannot contain or overwrite source installation')
|
|
from published_client_assets import published_source
|
|
retained_source=published_source(source_root)
|
|
compact=None
|
|
if compacted_content is not None:
|
|
from published_client_assets import reviewed_compacted_client
|
|
compact=reviewed_compacted_client(source_root,compacted_content,source_publication=retained_source)
|
|
if allow_running_published_source and retained_source is None:raise ValueError('Running-source copy requires reviewed publication')
|
|
if client_running(source_root/'runtime/native-client') and not allow_running_published_source:raise ValueError('Close source private client before full CoW release stage')
|
|
requirement=prerequisites()if check_prerequisites else dict(prerequisites_checked=False)
|
|
revision=source_git_revision(source_root)
|
|
public=None;public_sources=None
|
|
if dx12_public_bundle is not None:
|
|
if __package__:
|
|
from .dx12_public_bundle import verify_bundle
|
|
else:
|
|
from dx12_public_bundle import verify_bundle
|
|
bundle_root=Path(dx12_public_bundle)
|
|
if bundle_root.is_symlink()or not bundle_root.is_dir():raise ValueError('Owned public DX12 bundle directory required')
|
|
public=verify_bundle(bundle_root)
|
|
if sha(owned_regular(source_root/MODULES['core']))!=public['accepted_native_core_sha256']:
|
|
raise ValueError('Public DX12 bundle core differs from selected source runtime')
|
|
dlls={name:public['files'][name]['sha256']for name in
|
|
('d3d12.dll','d3d12core.dll','dxgi.dll','GWNativeBridge.dll','GWNativeWire.dll')}
|
|
public_sources={name:bundle_root/name for name in dlls}
|
|
template=None
|
|
else:template,dlls=verified_bindings(source_root)
|
|
abi={relative:elf_requirements(source_root/relative)for relative in MODULES.values()}
|
|
from client_installation import inspect_installation
|
|
client=source_root/'runtime/native-client';source_identity=inspect_installation(client);identity=deepcopy(source_identity)
|
|
if compact is not None:
|
|
identity['build_key']=compact['new_build_config']
|
|
identity['files']['.build.info']=dict(bytes=next(r['bytes']for r in compact['generated_files']if r['relative']=='.build.info'),sha256=compact['build_info_sha256'])
|
|
if identity['files']['_classic_beta_/WowB.exe']['sha256']!=EXE_SHA:raise ValueError('Pinned source client image required')
|
|
work=output.with_name(output.name+'.partial-'+uuid.uuid4().hex[:12]);work.mkdir(mode=0o700);copied={};trees={}
|
|
# Failure preserves this fresh partial for diagnosis; no existing folder is removed.
|
|
if public:
|
|
copied,trees=copy_client_subset(client,work/'runtime/native-client',
|
|
compacted_content=compact,renderer='D3D12')
|
|
else:copied,trees=copy_client_subset(client,work/'runtime/native-client',
|
|
compacted_content=compact)
|
|
profession_icons=package_profession_icon_addon(source_root,work/'runtime/native-client',include_talents=True,discard_copied=True)
|
|
warrior_stance=package_warrior_stance_addon(source_root,work/'runtime/native-client')
|
|
for relative in ops_closure(source_root)+['launcher/launcher.py',*MODULES.values(),'build/native-ptrace-abi',*PROOFS,*FIXED_CODE_DATA,*map(str,lifecycle_pages(source_root))]:copy_file(source_root/relative,work/relative)
|
|
from package_octo_protocol import package_protocol
|
|
protocol=package_protocol(protocol_directory,work/'compat')
|
|
if template is not None:write_json(work/'compat/native-engine-template.json',template)
|
|
write_json(work/'compat/launcher.json',launcher_profile(work))
|
|
if public:
|
|
write_json(work/'compat/dx12-public-bundle.json',dict(
|
|
kind=public['kind'],profile=public['profile'],pair=public['pair'],files=public['files'],
|
|
manifest_sha256=sha(bundle_root/'manifest.json'),public_authentication_tested=False))
|
|
wrapper=work/'Play-OctoWoW'
|
|
launch_switch='--direct-launch-root' if public else '--launch-root'
|
|
wrapper.write_text('#!/bin/bash\nset -eu\nHERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)\nexec python3 "$HERE/ops/linux_client_package.py" '+launch_switch+' "$HERE" "$@"\n');wrapper.chmod(0o755)
|
|
# Publish the identical shell entry with a suffix for desktop MIME detection.
|
|
shell_wrapper = wrapper.with_suffix(".sh")
|
|
shell_wrapper.write_bytes(wrapper.read_bytes())
|
|
shell_wrapper.chmod(0o755)
|
|
prefix=work/'runtime/native-wine-prefix';env=prefix_initializer(prefix)
|
|
if public:
|
|
install_prefix_dlls(source_root,prefix,dlls,env,public_sources=public_sources,
|
|
overrides=('d3d12','d3d12core','dxgi'))
|
|
direct_files=['runtime/native-client/_classic_beta_/WowB.exe',
|
|
'runtime/native-client/.build.info',
|
|
*('runtime/native-wine-prefix/drive_c/windows/system32/'+name for name in dlls),
|
|
*MODULES.values()]
|
|
write_json(work/'runtime/native-dx12-bootstrap.json',dict(
|
|
kind='native-inprocess-dx12-v1',source_profile=2,
|
|
public_profile_bundle_sha256=sha(bundle_root/'manifest.json'),
|
|
public_authentication_tested=False,
|
|
runtime_file_sha256={relative:sha(work/relative)for relative in direct_files}))
|
|
else:install_prefix_dlls(source_root,prefix,dlls,env)
|
|
if client_running(client) and not allow_running_published_source:raise ValueError('Source client started during package stage; candidate not published')
|
|
if retained_source is not None and published_source(source_root)!=retained_source:raise ValueError('Published source changed during read-only CoW copy')
|
|
if inspect_installation(work/'runtime/native-client')!=identity or inspect_installation(client)!=source_identity:raise ValueError('Client product/image identity changed during release copy')
|
|
warrior_bar=package_warrior_action_bar(source_root,work/'runtime/native-client',work/'compat/warrior-action-bar-casc',compacted_content=compact)
|
|
# Check the final selected UI bodies once so older valid roots cannot silently
|
|
# discard already qualified reporter and Skyborne fixes.
|
|
from ui_release_guard import verify_ui_lineage
|
|
ui_fix_lineage=verify_ui_lineage(work/'runtime/native-client',ROOT.parent/'tools/casc-tool/build/casc-tool',scratch=work/'compat')
|
|
# The source product identity stays exact; the fresh copy has an explicit CASC content derivative.
|
|
if inspect_installation(client)!=source_identity:raise ValueError('Source client identity changed during Warrior UI publication')
|
|
hashed=[p for folder in('ops','launcher','compat','build')for p in(work/folder).rglob('*')if p.is_file()and p.suffix!='.pyc']
|
|
if public:hashed.append(work/'runtime/native-dx12-bootstrap.json')
|
|
hashed+=[work/p for p in PROOFS]+[work/p for p in lifecycle_pages(source_root)]+[wrapper]+[prefix/'drive_c/windows/system32'/name for name in dlls]
|
|
hashed += [work/'runtime/native-client'/name for name in profession_icons['files']]
|
|
hashed += [work/'runtime/native-client'/name for name in warrior_stance['files']]
|
|
hashed += [work/name for name in warrior_bar['files']]
|
|
manifest=dict(kind='linux-forever-client-folder-package-v1',schema_version=1,fixed_endpoint='play.octowow.st',credentials_included=False,copied_account_store=False,copied_client_cache=False,copied_logs=False,copied_wine_registry=False,source_checkout_required=False,compiler_required=False,source_client_unchanged=True,client_engine_acceptance_verified=False,full_cow_client_trees=trees,product_and_game_files=copied,runtime_file_sha256={str(p.relative_to(work)):sha(p)for p in sorted(set(hashed))},prerequisites=requirement,abi_requirements=abi,universal_linux_distribution_compatibility_claimed=False,protocol_profile_sha256=protocol['profile_sha256'],native_dlls=dlls,source_image_sha256=EXE_SHA,autopatch_helper_required=False,source_asset_build_key=identity['build_key'])
|
|
if public:manifest['dx12_public_bundle']=dict(profile=2,public_authentication_tested=False,
|
|
manifest_sha256=sha(bundle_root/'manifest.json'),
|
|
carrier_sha256=dlls['d3d12.dll'],
|
|
bridge_sha256=dlls['GWNativeBridge.dll'],
|
|
wire_sha256=dlls['GWNativeWire.dll'])
|
|
manifest['ui_fix_lineage']=ui_fix_lineage
|
|
manifest['profession_icon_addon']=profession_icons
|
|
manifest['warrior_stance_addon']=warrior_stance
|
|
manifest['warrior_action_bar']=warrior_bar
|
|
manifest['candidate_asset_build_key']=warrior_bar['new_build_config']
|
|
manifest['source_git_revision']=revision
|
|
manifest['source_git_revision_is_complete_source_identity']=False
|
|
manifest['packaging_input_sha256']={'packager':sha(Path(__file__).resolve()),'publication_consumer':sha(Path(__file__).resolve().parent/'published_client_assets.py'),'source_runtime_packager':sha(source_root/'ops/linux_client_package.py'),'codec':sha(source_root/MODULES['source_codec'])}
|
|
if compact is not None:manifest['compacted_CASC']=dict(composed_root=compact['composed_root'],registered_assets=compact['registered_assets'],source_build_key=source_identity['build_key'],new_build_key=compact['new_build_config'],owning_validation_sha256=compact['owning_validation_sha256'],historical_overlay_metadata_omitted=True,original_content_preserved=True)
|
|
write_json(work/'linux-release.json',manifest)
|
|
# Relative template survives relocation. Only the generated journal is rebound
|
|
# by the launcher after the final directory is known.
|
|
work.rename(output);prepare_runtime(output,check_prerequisites=False)
|
|
return manifest
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--source-root',type=Path,default=ROOT);p.add_argument('--output',type=Path);p.add_argument('--protocol-directory',type=Path);p.add_argument('--launch-root',type=Path);p.add_argument('--direct-launch-root',type=Path);p.add_argument('--dx12-public-bundle',type=Path);p.add_argument('--check',action='store_true');p.add_argument('--allow-running-published-source',action='store_true');p.add_argument('--compacted-content',type=Path);a=p.parse_args()
|
|
if a.direct_launch_root:
|
|
try:return launch_inprocess(a.direct_launch_root)
|
|
except Exception as e:
|
|
visible_error('Client startup stopped: '+str(e));return 2
|
|
if a.launch_root:
|
|
m=None
|
|
try:
|
|
if not a.check:m=frontend(a.launch_root)
|
|
result=prepare_runtime(a.launch_root,check_only=a.check)
|
|
if a.check:print(json.dumps(result,indent=2));return 0
|
|
sys.argv=[str(a.launch_root/'launcher/launcher.py'),'--profile',str(a.launch_root/'compat/launcher.json')];return m.main()
|
|
except Exception as e:
|
|
message='Linux client startup stopped: '+str(e)
|
|
if a.check:print(json.dumps(dict(ready=False,reason=message,launch_performed=False),indent=2))
|
|
else:visible_error(message,m)
|
|
return 2
|
|
if a.output is None or a.protocol_directory is None:p.error('--output and --protocol-directory are required for staging')
|
|
print(json.dumps(stage(a.source_root,a.output,a.protocol_directory,allow_running_published_source=a.allow_running_published_source,compacted_content=a.compacted_content,dx12_public_bundle=a.dx12_public_bundle),indent=2));return 0
|
|
if __name__=='__main__':raise SystemExit(main())
|