37 lines
2.6 KiB
Python
37 lines
2.6 KiB
Python
"""Re-bake (owner #10, 2026-11-23) on content fe8cc5d8: the client's full hotfix cache from a fresh LOCAL
|
|
session (codec with Meditation push 371195158) baked into native DB2s. Only tables whose bytes changed are pinned."""
|
|
import json, hashlib, struct, sys
|
|
from pathlib import Path
|
|
H = Path(__file__).resolve().parent; sys.path.insert(0, str(H))
|
|
import frozen_store as fs
|
|
md5 = lambda b: hashlib.md5(b).hexdigest(); sha = lambda b: hashlib.sha256(b).hexdigest()
|
|
keys = json.load(open(H / 'base-keys.json'))
|
|
# only tables with row changes; the writer re-encodes unchanged tables to different bytes
|
|
rowchg = {l.split('\t')[0] for l in open(H / 'bake.tsv') if any(f'{k}=0' not in l for k in ('added', 'changed', 'removed'))}
|
|
WHY = 'Native DB2 bake of the current hotfix pushes so login sends no AvailableHotfixes for baked pushes (owner #10)'
|
|
store = fs.Store(); root = store.root; lay = store.layout; assert lay['root_md5'] == fs.ROOT
|
|
patched = bytearray(root); pins = []
|
|
for table, k in keys.items():
|
|
old = (H / 'base' / f'{table}.db2').read_bytes(); new = (H / 'baked' / f'{table}.db2').read_bytes()
|
|
if old == new or table not in rowchg: continue
|
|
fid = k['fdid']; cells = []
|
|
for g in lay['groups']:
|
|
f = 0
|
|
for i, (d,) in enumerate(struct.iter_unpack('<I', memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
|
|
f += d
|
|
if f == fid: cells.append((g, g['ckeys_offset'] + i * 16))
|
|
f += 1
|
|
en = [(g, at) for g, at in cells if g['locale'] & 2 and not g.get('flags1')]; assert len(en) == 1, (fid, len(en))
|
|
g, at = en[0]; assert root[at:at + 16].hex() == k['content_key']
|
|
patched[at:at + 16] = bytes.fromhex(md5(new))
|
|
d = H / 'pins' / str(fid); d.mkdir(parents=True, exist_ok=True)
|
|
(d / 'before.bin').write_bytes(old); (d / 'after.bin').write_bytes(new)
|
|
pin = dict(fdid=fid, table=f'dbfilesclient/{table.lower()}.db2', parent_root=fs.ROOT, selected_group={},
|
|
original_decoded=dict(file='before.bin', md5=k['content_key'], sha256=sha(old)), encrypted_original=False,
|
|
after_decoded=dict(file='after.bin', md5=md5(new), sha256=sha(new)), reason=WHY)
|
|
(d / 'pin.json').write_text(json.dumps(pin, indent=1) + '\n')
|
|
pins.append(dict(file=str(d / 'pin.json'), sha256=sha((d / 'pin.json').read_bytes()), type='wdc_enus'))
|
|
(H / 'components.json').write_text(json.dumps(pins, indent=2) + '\n')
|
|
(H / 'selected-root.json').write_text(json.dumps(dict(parent_build=fs.BUILD, parent_root=fs.ROOT, decoded_root_sha256=sha(bytes(patched)), parent_root_sha256=sha(root)), indent=2) + '\n')
|
|
print('pins', len(pins))
|