补齐公证等待中断后的原产物安全恢复入口
这个提交包含在:
1 父节点
6bc086ade0
当前提交
158829a418
3 个文件已更改
+82
-28
没有与搜索条件相匹配的文件
+68
-27
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Single-install Release delivery; keeps a product lock through host acceptance."""
|
||||
from pathlib import Path
|
||||
import subprocess,os,json,shutil,plistlib,uuid,sys,datetime,hashlib,time
|
||||
import subprocess,os,json,shutil,plistlib,uuid,sys,datetime,hashlib,time,argparse,tempfile,re
|
||||
from template_payload import template_files
|
||||
ROOT=Path(__file__).resolve().parent.parent
|
||||
CACHE=Path('/Users/mac/Library/Caches/CodexBuilds/com.dayu.color')
|
||||
@@ -84,7 +84,43 @@ def write_template_file(target,data,mode,flags):
|
||||
finally:
|
||||
temp.unlink(missing_ok=True)
|
||||
|
||||
def resume_notary(submission,archive,expected_hash,source):
|
||||
if not re.fullmatch(r'[0-9a-f]{40}',source or ''):raise RuntimeError('恢复须提供原始完整编译提交')
|
||||
if not re.fullmatch(r'[0-9a-f]{64}',expected_hash or '') or hashlib.sha256(archive.read_bytes()).hexdigest()!=expected_hash:raise RuntimeError('公证提交 ZIP 摘要不匹配,停止恢复')
|
||||
run('git','cat-file','-e',source+'^{commit}');identity(APP,'com.dayu.color');run('codesign','--verify','--deep','--strict',str(APP))
|
||||
# Validate the exact submitted bundle, including symlinks; never rebuild or re-sign.
|
||||
with tempfile.TemporaryDirectory(prefix='notary-resume-',dir=CACHE) as scratch:
|
||||
run('ditto','-x','-k',str(archive),scratch)
|
||||
submitted=Path(scratch)/APP.name;identity(submitted,'com.dayu.color')
|
||||
live={str(p.relative_to(APP)) for p in APP.rglob('*')};saved={str(p.relative_to(submitted)) for p in submitted.rglob('*')}
|
||||
if live!=saved:raise RuntimeError('待安装 APP 与已提交 ZIP 内容清单不同')
|
||||
for relative in live:
|
||||
a=APP/relative;b=submitted/relative
|
||||
if a.is_symlink() or b.is_symlink():same=a.is_symlink() and b.is_symlink() and os.readlink(a)==os.readlink(b)
|
||||
elif a.is_dir() or b.is_dir():same=a.is_dir() and b.is_dir()
|
||||
else:same=a.read_bytes()==b.read_bytes()
|
||||
if not same:raise RuntimeError('待安装 APP 与已提交 ZIP 不一致:'+relative)
|
||||
unregister(submitted/PLUGIN)
|
||||
preflight=json.loads((CACHE/'release-preflight.json').read_text())
|
||||
if not preflight.get('pass'):raise RuntimeError('缺少通过的原始发布前检查')
|
||||
print('Exact submitted APP verified; querying original Apple submission '+submission,flush=True)
|
||||
failures=0
|
||||
while True:
|
||||
try:
|
||||
result=json.loads(run('xcrun','notarytool','info',submission,'--keychain-profile',PROFILE,'--keychain',KEYCHAIN,'--output-format','json'));failures=0
|
||||
except subprocess.CalledProcessError:
|
||||
failures+=1
|
||||
if failures>=3:raise RuntimeError('连续三次无法读取 Apple 公证状态;产物保留,可继续原提交恢复')
|
||||
time.sleep(15);continue
|
||||
if result.get('id')!=submission:raise RuntimeError('公证编号不匹配')
|
||||
if result.get('status')!='In Progress':return result
|
||||
time.sleep(15)
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--resume-notary');parser.add_argument('--submitted-zip-sha256');parser.add_argument('--compiled-source')
|
||||
args=parser.parse_args()
|
||||
if not args.resume_notary and (args.submitted_zip_sha256 or args.compiled_source):parser.error('摘要与编译提交仅用于恢复原公证提交')
|
||||
hosts_closed();CACHE.mkdir(parents=True,exist_ok=True);LOCK.parent.mkdir(parents=True,exist_ok=True);LOCK.mkdir()
|
||||
(LOCK/'owner.json').write_text(json.dumps(dict(PID=os.getpid(),cwd=str(ROOT),product='大鱼调色',started=datetime.datetime.now(datetime.timezone.utc).isoformat())))
|
||||
old=None;stage=None
|
||||
@@ -92,32 +128,37 @@ def main():
|
||||
ids=run('security','find-identity','-v','-p','codesigning')
|
||||
if IDENTITY not in ids:raise RuntimeError('有效发布证书或私钥不可用')
|
||||
if any(l.endswith('/Contents/MacOS/大鱼调色') for l in run('ps','-axo','comm=').splitlines()):raise RuntimeError('请先正常退出当前大鱼调色窗口')
|
||||
print('Building final Release',flush=True)
|
||||
run('xcodebuild','-project','大鱼调色.xcodeproj','-scheme','Wrapper Application','-configuration','Release','-enableAddressSanitizer','NO','-derivedDataPath',str(CACHE/'DerivedData'),'clean','build',log=CACHE/'release-build.log')
|
||||
for source,bundled,_ in template_files():
|
||||
target=APP/BUNDLED_TEMPLATES/bundled
|
||||
target.parent.mkdir(parents=True,exist_ok=True)
|
||||
shutil.copyfile(ROOT/'template'/source,target)
|
||||
target.chmod(0o644)
|
||||
# Sources on exFAT can be exposed as owner-only. Installer changes ownership to root.
|
||||
(APP/'Contents/Resources/Basis_balanceWheel.png').chmod(0o644)
|
||||
identity(APP,'com.dayu.color');plugin=APP/PLUGIN;identity(plugin,'com.dayu.color.XPC')
|
||||
# Xcode registers its build product with Launch Services. Keep the host from
|
||||
# discovering this generated copy while signing/notarization are pending.
|
||||
unregister(plugin);unregister(LOOSE)
|
||||
for name in ['FxPlug','PluginManager']:run('codesign','--force','--timestamp','--options','runtime','--sign',IDENTITY,str(plugin/'Contents/Frameworks'/(name+'.framework')))
|
||||
run('codesign','--force','--timestamp','--options','runtime','--sign',IDENTITY,str(plugin))
|
||||
run('codesign','--force','--timestamp','--options','runtime','--entitlements',str(ROOT/'大鱼调色/Wrapper Application/SandboxEntitlements.entitlements'),'--sign',IDENTITY,str(APP))
|
||||
run('codesign','--verify','--deep','--strict',str(APP))
|
||||
details=run('codesign','-dvvv',str(APP))
|
||||
if 'TeamIdentifier=B3W25FX5H5' not in details or 'Timestamp=' not in details or 'runtime' not in details:raise RuntimeError('签名身份/时间戳/runtime未通过')
|
||||
preflight=self_test(plugin/'Contents/MacOS/大鱼调色 XPC Service',CACHE/'release-preflight.json')
|
||||
(CACHE/'release-preflight.json').write_text(json.dumps(preflight,ensure_ascii=False,indent=2)+'\n')
|
||||
if not preflight.get('pass'):raise RuntimeError('Release集成自检失败,正式旧版未替换')
|
||||
archive=CACHE/'notarization-submission.zip'
|
||||
if archive.exists():archive.unlink()
|
||||
run('ditto','-c','-k','--keepParent',str(APP),str(archive));print('Submitting signed Release to Apple',flush=True)
|
||||
result=json.loads(run('xcrun','notarytool','submit',str(archive),'--keychain-profile',PROFILE,'--keychain',KEYCHAIN,'--wait','--output-format','json'));(CACHE/'notary-result.json').write_text(json.dumps(result,indent=2))
|
||||
if args.resume_notary:
|
||||
result=resume_notary(args.resume_notary,archive,args.submitted_zip_sha256,args.compiled_source)
|
||||
(CACHE/'notary-result.json').write_text(json.dumps(result,indent=2))
|
||||
else:
|
||||
print('Building final Release',flush=True)
|
||||
run('xcodebuild','-project','大鱼调色.xcodeproj','-scheme','Wrapper Application','-configuration','Release','-enableAddressSanitizer','NO','-derivedDataPath',str(CACHE/'DerivedData'),'clean','build',log=CACHE/'release-build.log')
|
||||
for source,bundled,_ in template_files():
|
||||
target=APP/BUNDLED_TEMPLATES/bundled
|
||||
target.parent.mkdir(parents=True,exist_ok=True)
|
||||
shutil.copyfile(ROOT/'template'/source,target)
|
||||
target.chmod(0o644)
|
||||
# Sources on exFAT can be exposed as owner-only. Installer changes ownership to root.
|
||||
(APP/'Contents/Resources/Basis_balanceWheel.png').chmod(0o644)
|
||||
identity(APP,'com.dayu.color');plugin=APP/PLUGIN;identity(plugin,'com.dayu.color.XPC')
|
||||
# Xcode registers its build product with Launch Services. Keep the host from
|
||||
# discovering this generated copy while signing/notarization are pending.
|
||||
unregister(plugin);unregister(LOOSE)
|
||||
for name in ['FxPlug','PluginManager']:run('codesign','--force','--timestamp','--options','runtime','--sign',IDENTITY,str(plugin/'Contents/Frameworks'/(name+'.framework')))
|
||||
run('codesign','--force','--timestamp','--options','runtime','--sign',IDENTITY,str(plugin))
|
||||
run('codesign','--force','--timestamp','--options','runtime','--entitlements',str(ROOT/'大鱼调色/Wrapper Application/SandboxEntitlements.entitlements'),'--sign',IDENTITY,str(APP))
|
||||
run('codesign','--verify','--deep','--strict',str(APP))
|
||||
details=run('codesign','-dvvv',str(APP))
|
||||
if 'TeamIdentifier=B3W25FX5H5' not in details or 'Timestamp=' not in details or 'runtime' not in details:raise RuntimeError('签名身份/时间戳/runtime未通过')
|
||||
preflight=self_test(plugin/'Contents/MacOS/大鱼调色 XPC Service',CACHE/'release-preflight.json')
|
||||
(CACHE/'release-preflight.json').write_text(json.dumps(preflight,ensure_ascii=False,indent=2)+'\n')
|
||||
if not preflight.get('pass'):raise RuntimeError('Release集成自检失败,正式旧版未替换')
|
||||
archive=CACHE/'notarization-submission.zip'
|
||||
if archive.exists():archive.unlink()
|
||||
run('ditto','-c','-k','--keepParent',str(APP),str(archive));print('Submitting signed Release to Apple',flush=True)
|
||||
result=json.loads(run('xcrun','notarytool','submit',str(archive),'--keychain-profile',PROFILE,'--keychain',KEYCHAIN,'--wait','--output-format','json'));(CACHE/'notary-result.json').write_text(json.dumps(result,indent=2))
|
||||
if result.get('status')!='Accepted':
|
||||
if result.get('id'):run('xcrun','notarytool','log',result['id'],'--keychain-profile',PROFILE,'--keychain',KEYCHAIN,str(CACHE/'notary-rejection.json'))
|
||||
raise RuntimeError('Apple未Accepted,正式旧版未替换')
|
||||
@@ -154,7 +195,7 @@ def main():
|
||||
if entries:break
|
||||
time.sleep(.5)
|
||||
if len(entries)!=1 or not entries[0].rstrip().endswith('\t'+str(DEST/PLUGIN)):raise RuntimeError('PluginKit发现多份/错误版本: '+registry)
|
||||
record=dict(status='installed-awaiting-host-verification',path=str(DEST),bundleID='com.dayu.color',version=plistlib.loads((DEST/'Contents/Info.plist').read_bytes())['CFBundleShortVersionString'],build=plistlib.loads((DEST/'Contents/Info.plist').read_bytes())['CFBundleVersion'],team='B3W25FX5H5',notaryID=result['id'],notaryStatus=result['status'],gatekeeper=gate,sourceCommit=run('git','rev-parse','HEAD'),templatePath=str(TEMPLATE),templateSHA256=template_hashes[str(TEMPLATE.relative_to(TEMPLATE_ROOT))],installedTemplateSHA256=template_hashes,shaderSHA256=hashlib.sha256((DEST/PLUGIN/'Contents/Resources/default.metallib').read_bytes()).hexdigest())
|
||||
record=dict(status='installed-awaiting-host-verification',path=str(DEST),bundleID='com.dayu.color',version=plistlib.loads((DEST/'Contents/Info.plist').read_bytes())['CFBundleShortVersionString'],build=plistlib.loads((DEST/'Contents/Info.plist').read_bytes())['CFBundleVersion'],team='B3W25FX5H5',notaryID=result['id'],notaryStatus=result['status'],gatekeeper=gate,sourceCommit=args.compiled_source or run('git','rev-parse','HEAD'),deliveryToolCommit=run('git','rev-parse','HEAD'),templatePath=str(TEMPLATE),templateSHA256=template_hashes[str(TEMPLATE.relative_to(TEMPLATE_ROOT))],installedTemplateSHA256=template_hashes,shaderSHA256=hashlib.sha256((DEST/PLUGIN/'Contents/Resources/default.metallib').read_bytes()).hexdigest())
|
||||
if old:record['previousInstallBackup']=str(old)
|
||||
output=ROOT/'verification/Delivery.json';output.write_text(json.dumps(record,ensure_ascii=False,indent=2)+'\n')
|
||||
run('open',str(DEST));print('FORMAL_INSTALLED. Run installed self-test and host verification; type complete only after success. Type leave to preserve pending state.',flush=True)
|
||||
|
||||
在新工单中引用
屏蔽一个用户