|
@@ -1,5 +1,6 @@
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
+import argparse
|
|
|
import errno
|
|
|
import glob
|
|
|
import os
|
|
@@ -10,29 +11,41 @@ import tempfile
|
|
|
from lib.util import *
|
|
|
|
|
|
|
|
|
+TARGET_PLATFORM = {
|
|
|
+ 'cygwin': 'win32',
|
|
|
+ 'darwin': 'darwin',
|
|
|
+ 'linux2': 'linux',
|
|
|
+ 'win32': 'win32',
|
|
|
+}[sys.platform]
|
|
|
+
|
|
|
+ATOM_SHELL_VRESION = get_atom_shell_version()
|
|
|
+NODE_VERSION = 'v0.10.15'
|
|
|
+
|
|
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
|
|
+OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'Release')
|
|
|
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
|
|
|
+DIST_NAME = 'atom-shell-{0}-{1}.zip'.format(ATOM_SHELL_VRESION, TARGET_PLATFORM)
|
|
|
|
|
|
|
|
|
def main():
|
|
|
- try:
|
|
|
- ensure_s3put()
|
|
|
- if not dist_newer_than_head():
|
|
|
- create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
|
|
|
- subprocess.check_call([sys.executable, create_dist])
|
|
|
- upload()
|
|
|
- except AssertionError as e:
|
|
|
- return e.message
|
|
|
-
|
|
|
-
|
|
|
-def ensure_s3put():
|
|
|
- output = ''
|
|
|
- try:
|
|
|
- output = subprocess.check_output(['s3put', '--help'])
|
|
|
- except OSError as e:
|
|
|
- if e.errno != errno.ENOENT:
|
|
|
- raise
|
|
|
- assert 'multipart' in output, 'Error: Please install boto and filechunkio'
|
|
|
+ args = parse_args()
|
|
|
+
|
|
|
+ if not dist_newer_than_head():
|
|
|
+ create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
|
|
|
+ subprocess.check_call([sys.executable, create_dist])
|
|
|
+
|
|
|
+ bucket, access_key, secret_key = s3_config()
|
|
|
+ upload(bucket, access_key, secret_key)
|
|
|
+ if not args.no_update_version:
|
|
|
+ update_version(bucket, access_key, secret_key)
|
|
|
+
|
|
|
+
|
|
|
+def parse_args():
|
|
|
+ parser = argparse.ArgumentParser(description='upload distribution file')
|
|
|
+ parser.add_argument('-n', '--no-update-version',
|
|
|
+ help='Do not update the latest version file',
|
|
|
+ action='store_false')
|
|
|
+ return parser.parse_args()
|
|
|
|
|
|
|
|
|
def dist_newer_than_head():
|
|
@@ -40,7 +53,7 @@ def dist_newer_than_head():
|
|
|
try:
|
|
|
head_time = subprocess.check_output(['git', 'log', '--pretty=format:%at',
|
|
|
'-n', '1']).strip()
|
|
|
- dist_time = os.path.getmtime(os.path.join(DIST_DIR, 'atom-shell.zip'))
|
|
|
+ dist_time = os.path.getmtime(os.path.join(DIST_DIR, DIST_NAME))
|
|
|
except OSError as e:
|
|
|
if e.errno != errno.ENOENT:
|
|
|
raise
|
|
@@ -49,17 +62,36 @@ def dist_newer_than_head():
|
|
|
return dist_time > int(head_time)
|
|
|
|
|
|
|
|
|
-def upload():
|
|
|
+def upload(bucket, access_key, secret_key, version=ATOM_SHELL_VRESION):
|
|
|
os.chdir(DIST_DIR)
|
|
|
- bucket, access_key, secret_key = s3_config()
|
|
|
|
|
|
- version = get_atom_shell_version()
|
|
|
s3put(bucket, access_key, secret_key, DIST_DIR,
|
|
|
- 'atom-shell/{0}'.format(version), ['atom-shell.zip'])
|
|
|
+ 'atom-shell/{0}'.format(version), [DIST_NAME])
|
|
|
s3put(bucket, access_key, secret_key, DIST_DIR,
|
|
|
- 'atom-shell/dist/{0}'.format(version), glob.glob('node-*.tar.gz'))
|
|
|
+ 'atom-shell/dist/{0}'.format(NODE_VERSION), glob.glob('node-*.tar.gz'))
|
|
|
+
|
|
|
+ if TARGET_PLATFORM == 'win32':
|
|
|
+ # Generate the node.lib.
|
|
|
+ build = os.path.join(SOURCE_ROOT, 'script', 'build.py')
|
|
|
+ subprocess.check_call([sys.executable, build, '-c', 'Release',
|
|
|
+ '-t', 'generate_node_lib'])
|
|
|
+
|
|
|
+ # Upload the 32bit node.lib.
|
|
|
+ node_lib = os.path.join(OUT_DIR, 'node.lib')
|
|
|
+ s3put(bucket, access_key, secret_key, OUT_DIR,
|
|
|
+ 'atom-shell/dist/{0}'.format(NODE_VERSION), [node_lib])
|
|
|
+
|
|
|
+ # Upload the fake 64bit node.lib.
|
|
|
+ touch_x64_node_lib()
|
|
|
+ node_lib = os.path.join(OUT_DIR, 'x64', 'node.lib')
|
|
|
+ s3put(bucket, access_key, secret_key, OUT_DIR,
|
|
|
+ 'atom-shell/dist/{0}'.format(NODE_VERSION), [node_lib])
|
|
|
|
|
|
- update_version(bucket, access_key, secret_key)
|
|
|
+
|
|
|
+def update_version(bucket, access_key, secret_key):
|
|
|
+ prefix = os.path.join(SOURCE_ROOT, 'dist')
|
|
|
+ version = os.path.join(prefix, 'version')
|
|
|
+ s3put(bucket, access_key, secret_key, prefix, 'atom-shell', [version])
|
|
|
|
|
|
|
|
|
def s3_config():
|
|
@@ -73,12 +105,6 @@ def s3_config():
|
|
|
return config
|
|
|
|
|
|
|
|
|
-def update_version(bucket, access_key, secret_key):
|
|
|
- prefix = os.path.join(SOURCE_ROOT, 'dist')
|
|
|
- version = os.path.join(prefix, 'version')
|
|
|
- s3put(bucket, access_key, secret_key, prefix, 'atom-shell', [ version ])
|
|
|
-
|
|
|
-
|
|
|
def s3put(bucket, access_key, secret_key, prefix, key_prefix, files):
|
|
|
args = [
|
|
|
's3put',
|
|
@@ -93,6 +119,13 @@ def s3put(bucket, access_key, secret_key, prefix, key_prefix, files):
|
|
|
subprocess.check_call(args)
|
|
|
|
|
|
|
|
|
+def touch_x64_node_lib():
|
|
|
+ x64_dir = os.path.join(OUT_DIR, 'x64')
|
|
|
+ safe_mkdir(x64_dir)
|
|
|
+ with open(os.path.join(x64_dir, 'node.lib'), 'w+') as node_lib:
|
|
|
+ node_lib.write('Invalid library')
|
|
|
+
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
import sys
|
|
|
sys.exit(main())
|