2023-11-11 06:02:05 +03:00
|
|
|
#!/usr/bin/env python
|
2017-10-24 07:38:03 +03:00
|
|
|
# vim:fileencoding=utf-8
|
|
|
|
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
|
|
|
|
2023-04-16 13:01:03 +03:00
|
|
|
import atexit
|
2017-12-11 20:41:34 +03:00
|
|
|
import glob
|
2017-10-24 07:38:03 +03:00
|
|
|
import os
|
|
|
|
import shlex
|
2017-12-11 20:41:34 +03:00
|
|
|
import shutil
|
2017-10-24 07:38:03 +03:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2017-12-11 20:41:34 +03:00
|
|
|
import tempfile
|
|
|
|
|
|
|
|
if False:
|
|
|
|
dmg = sys.argv[-1]
|
|
|
|
mp = tempfile.mkdtemp()
|
|
|
|
atexit.register(os.rmdir, mp)
|
2022-01-28 14:34:13 +03:00
|
|
|
subprocess.check_call(f'hdiutil attach {dmg} -mountpoint {mp}'.split())
|
2017-12-11 20:41:34 +03:00
|
|
|
try:
|
|
|
|
os.chdir(mp)
|
|
|
|
for app in glob.glob('*.app'):
|
|
|
|
d = os.path.join('/Applications', app)
|
|
|
|
if os.path.exists(d):
|
|
|
|
shutil.rmtree(d)
|
2022-01-28 14:34:13 +03:00
|
|
|
subprocess.check_call(f'ditto -v {app} {d}'.split())
|
2017-12-11 20:41:34 +03:00
|
|
|
finally:
|
|
|
|
os.chdir('/')
|
2022-01-28 14:34:13 +03:00
|
|
|
subprocess.check_call(f'hdiutil detach {mp}'.split())
|
2017-12-11 20:41:34 +03:00
|
|
|
|
|
|
|
# EOF_REMOTE
|
|
|
|
|
2017-12-12 19:53:09 +03:00
|
|
|
HOST = 'ox'
|
2017-10-24 07:38:03 +03:00
|
|
|
|
|
|
|
base = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
if True:
|
|
|
|
sys.path.insert(0, base)
|
|
|
|
from kitty.constants import str_version
|
|
|
|
|
|
|
|
dmg = f'kitty-{str_version}.dmg'
|
|
|
|
|
|
|
|
|
|
|
|
def run(what):
|
|
|
|
ret = subprocess.run(shlex.split(what))
|
|
|
|
if ret.returncode != 0:
|
|
|
|
raise SystemExit(ret.returncode)
|
|
|
|
|
|
|
|
|
2019-08-01 21:21:26 +03:00
|
|
|
with open(__file__, 'rb') as f:
|
|
|
|
script = f.read().decode('utf-8')
|
2017-12-11 20:41:34 +03:00
|
|
|
script = script[:script.find('# EOF_REMOTE')].replace('if False:', 'if True:', 1)
|
|
|
|
with tempfile.NamedTemporaryFile(prefix='install-dmg-', suffix='.py') as f:
|
2024-08-18 13:00:38 +03:00
|
|
|
cmd = 'python ../bypy macos program'
|
2024-07-25 13:58:14 +03:00
|
|
|
if 'dont_sign' not in sys.argv:
|
|
|
|
cmd += ' --sign-installers'
|
2024-08-18 13:00:38 +03:00
|
|
|
if 'strip' not in sys.argv:
|
|
|
|
cmd += ' --dont-strip'
|
2024-07-25 13:58:14 +03:00
|
|
|
if 'tests' not in sys.argv:
|
2022-07-09 07:12:06 +03:00
|
|
|
cmd += ' --skip-tests'
|
2024-08-18 13:00:38 +03:00
|
|
|
if 'notarize' in sys.argv:
|
|
|
|
cmd += ' --sign-installers --notarize'
|
2020-08-19 17:38:34 +03:00
|
|
|
run(cmd)
|
2017-12-11 20:41:34 +03:00
|
|
|
f.write(script.encode('utf-8'))
|
|
|
|
f.flush()
|
2020-06-06 06:41:50 +03:00
|
|
|
run(f'scp bypy/b/macos/dist/{dmg} {f.name} {HOST}:/tmp')
|
2022-02-04 08:49:51 +03:00
|
|
|
run(f'ssh {HOST} python3 /tmp/{os.path.basename(f.name)} /tmp/{dmg}')
|