diff --git a/tools/deliver.py b/tools/deliver.py index a232deb..e76ba7a 100644 --- a/tools/deliver.py +++ b/tools/deliver.py @@ -19,10 +19,15 @@ def run(*args,log=None): with Path(log).open('w') as f:subprocess.run(args,cwd=ROOT,stdout=f,stderr=subprocess.STDOUT,check=True) return '' return subprocess.check_output(args,cwd=ROOT,text=True,stderr=subprocess.STDOUT).strip() -def hosts_closed(): - lines=run('ps','-axo','pid=,comm=').splitlines() - live=[l for l in lines if l.endswith(('/Contents/MacOS/Final Cut Pro','/Contents/MacOS/Motion'))] - if live:raise RuntimeError('请先正常退出宿主,再继续交付:'+str(live)) +def hosts_closed(wait=False): + announced=False + while True: + lines=run('ps','-axo','pid=,comm=').splitlines() + live=[l for l in lines if l.endswith(('/Contents/MacOS/Final Cut Pro','/Contents/MacOS/Motion'))] + if not live:return + if not wait:raise RuntimeError('请先正常退出宿主,再继续交付:'+str(live)) + if not announced:print('Notarized APP retained; waiting for the host to save and quit normally before replacement.',flush=True);announced=True + time.sleep(1) def identity(path,expected): p=plistlib.loads((path/'Contents/Info.plist').read_bytes()) if p['CFBundleIdentifier']!=expected:raise RuntimeError('产品身份不匹配: '+str(path)) @@ -72,7 +77,7 @@ def main(): 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,正式旧版未替换') - run('xcrun','stapler','staple',str(APP));run('xcrun','stapler','validate',str(APP));hosts_closed() + run('xcrun','stapler','staple',str(APP));run('xcrun','stapler','validate',str(APP));hosts_closed(wait=True) stage=DEST.parent/('.dayu-color-staging-'+uuid.uuid4().hex+'.app');run('ditto',str(APP),str(stage)) if DEST.exists(): identity(DEST,'com.dayu.color');old=DEST.parent/('.dayu-color-previous-'+uuid.uuid4().hex+'.app');os.replace(DEST,old)