electron/script/release/uploaders/upload-symbols.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

94 lines
2.5 KiB
Python
Raw Normal View History

2014-11-07 12:19:26 +00:00
#!/usr/bin/env python
2014-11-07 12:51:25 +00:00
import glob
import os
import shutil
import subprocess
import sys
import tempfile
def is_fs_case_sensitive():
with tempfile.NamedTemporaryFile(prefix='TmP') as tmp_file:
return(not os.path.exists(tmp_file.name.lower()))
2014-11-07 12:19:26 +00:00
sys.path.append(
os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../.."))
from lib.config import PLATFORM, s3_config
from lib.util import get_electron_branding, execute, s3put, \
get_out_dir, ELECTRON_DIR
2014-11-07 12:19:26 +00:00
RELEASE_DIR = get_out_dir()
PROJECT_NAME = get_electron_branding()['project_name']
PRODUCT_NAME = get_electron_branding()['product_name']
SYMBOLS_DIR = os.path.join(RELEASE_DIR, 'breakpad_symbols')
2018-05-23 19:53:48 +00:00
2014-11-07 12:19:26 +00:00
PDB_LIST = [
os.path.join(RELEASE_DIR, '{0}.exe.pdb'.format(PROJECT_NAME))
2014-11-07 12:19:26 +00:00
]
PDB_LIST += glob.glob(os.path.join(RELEASE_DIR, '*.dll.pdb'))
NPX_CMD = "npx"
if sys.platform == "win32":
NPX_CMD += ".cmd"
2014-11-07 12:19:26 +00:00
def main():
os.chdir(ELECTRON_DIR)
files = []
2018-05-23 19:53:48 +00:00
if PLATFORM == 'win32':
for pdb in PDB_LIST:
run_symstore(pdb, SYMBOLS_DIR, PRODUCT_NAME)
files = glob.glob(SYMBOLS_DIR + '/*.pdb/*/*.pdb')
files += glob.glob(SYMBOLS_DIR + '/*/*/*.sym')
for symbol_file in files:
print("Generating Sentry src bundle for: " + symbol_file)
npx_env = os.environ.copy()
npx_env['npm_config_yes'] = 'true'
2020-10-19 11:55:27 +00:00
subprocess.check_output([
NPX_CMD, '@sentry/cli@1.51.1', 'difutil', 'bundle-sources',
symbol_file], env=npx_env)
files += glob.glob(SYMBOLS_DIR + '/*/*/*.src.zip')
# The file upload needs to be atom-shell/symbols/:symbol_name/:hash/:symbol
os.chdir(SYMBOLS_DIR)
files = [os.path.relpath(f, os.getcwd()) for f in files]
# The symbol server needs lowercase paths, it will fail otherwise
# So lowercase all the file paths here
if is_fs_case_sensitive():
for f in files:
lower_f = f.lower()
if lower_f != f:
if os.path.exists(lower_f):
shutil.rmtree(lower_f)
lower_dir = os.path.dirname(lower_f)
if not os.path.exists(lower_dir):
os.makedirs(lower_dir)
shutil.copy2(f, lower_f)
files = [f.lower() for f in files]
for f in files:
assert os.path.exists(f)
2014-11-07 12:19:26 +00:00
2014-11-07 12:51:25 +00:00
bucket, access_key, secret_key = s3_config()
upload_symbols(bucket, access_key, secret_key, files)
2014-11-07 12:19:26 +00:00
def run_symstore(pdb, dest, product):
execute(['symstore', 'add', '/r', '/f', pdb, '/s', dest, '/t', product])
2014-11-07 12:51:25 +00:00
def upload_symbols(bucket, access_key, secret_key, files):
2014-11-10 15:33:56 +00:00
s3put(bucket, access_key, secret_key, SYMBOLS_DIR, 'atom-shell/symbols',
files)
2014-11-07 12:51:25 +00:00
2014-11-07 12:19:26 +00:00
if __name__ == '__main__':
sys.exit(main())