Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 import glob | 7 import glob |
| 8 import gsutil | 8 import gsutil |
| 9 import imp | 9 import imp |
| 10 import optparse | 10 import optparse |
| 11 import os | 11 import os |
| 12 import re | 12 import re |
| 13 import shutil | 13 import shutil |
| 14 import stat | |
| 14 import subprocess | 15 import subprocess |
| 15 import sys | 16 import sys |
| 16 import tempfile | 17 import tempfile |
| 17 import zipfile | 18 import zipfile |
| 18 import ziputils | 19 import ziputils |
| 19 | 20 |
| 20 from os.path import join | 21 from os.path import join |
| 21 | 22 |
| 22 BUILD_OS = None | 23 BUILD_OS = None |
| 23 DART_PATH = None | 24 DART_PATH = None |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 | 959 |
| 959 for zipFile in _FindRcpZipFiles(out_dir): | 960 for zipFile in _FindRcpZipFiles(out_dir): |
| 960 basename = os.path.basename(zipFile) | 961 basename = os.path.basename(zipFile) |
| 961 if renameMap[basename] != None: | 962 if renameMap[basename] != None: |
| 962 os.rename(zipFile, join(os.path.dirname(zipFile), renameMap[basename])) | 963 os.rename(zipFile, join(os.path.dirname(zipFile), renameMap[basename])) |
| 963 | 964 |
| 964 | 965 |
| 965 def PostProcessEditorBuilds(out_dir, buildos): | 966 def PostProcessEditorBuilds(out_dir, buildos): |
| 966 """Post-process the created RCP builds""" | 967 """Post-process the created RCP builds""" |
| 967 with utils.TempDir('editor_scratch') as scratch_dir: | 968 with utils.TempDir('editor_scratch') as scratch_dir: |
| 969 | |
| 970 def instantiate_download_script_template(destination, replacements): | |
|
ricow1
2013/11/05 12:59:33
please add a comment describing what this does, it
kustermann
2013/11/05 13:11:05
Done.
| |
| 971 template_location = { | |
| 972 'windows' : join( | |
| 973 DART_DIR, 'tools', 'dartium', 'download_shellscript_template.bat'), | |
| 974 'linux' : join( | |
| 975 DART_DIR, 'tools', 'dartium', 'download_shellscript_template.sh'), | |
| 976 'macos' : join( | |
| 977 DART_DIR, 'tools', 'dartium', 'download_shellscript_template.sh'), | |
| 978 }[SYSTEM] | |
| 979 | |
| 980 with open(template_location) as fd: | |
| 981 content = fd.read() | |
| 982 for key in replacements: | |
| 983 content = content.replace(key, replacements[key]) | |
| 984 with open(destination, 'w') as fd: | |
| 985 fd.write(content) | |
| 986 | |
| 987 # Make it executable if we are not on windows | |
| 988 if SYSTEM != 'windows': | |
| 989 os.chmod(destination, os.stat(destination).st_mode | stat.S_IEXEC) | |
| 990 | |
| 991 def add_download_scripts(zipFile, arch): | |
| 992 shell_ending = { | |
| 993 'windows' : '.bat', | |
| 994 'linux' : '.sh', | |
| 995 'macos' : '.sh', | |
| 996 }[SYSTEM] | |
| 997 | |
| 998 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RELEASE) | |
| 999 | |
| 1000 # We're adding download scripts to the chromium directory. | |
| 1001 # The directory tree will look like this after that: | |
| 1002 # dart/dart-sdk/bin/dart{,.exe} | |
| 1003 # /chromium/download_contentshell.{sh,bat} | |
| 1004 # /chromium/download_dartium_debug.{sh,bat} | |
| 1005 # /chromium/download_file.dart | |
| 1006 | |
| 1007 # Add download_file.dart helper utility to the zip file. | |
| 1008 f = ziputils.ZipUtil(zipFile, buildos) | |
| 1009 f.AddFile(join(DART_DIR, 'tools', 'dartium', 'download_file.dart'), | |
| 1010 'dart/chromium/download_file.dart') | |
| 1011 | |
| 1012 # Add content shell download script | |
| 1013 contentshell_name = namer.dartium_variant_zipfilename( | |
| 1014 'content_shell', SYSTEM, arch, 'release') | |
| 1015 contentshell_download_script = join(scratch_dir, 'download_contentshell') | |
| 1016 instantiate_download_script_template(contentshell_download_script, { | |
| 1017 'VAR_DESTINATION' : contentshell_name, | |
| 1018 'VAR_DOWNLOAD_URL' : | |
| 1019 ("http://dartlang.org/editor/update/channels/%s/%s/dartium/%s" | |
|
ricow1
2013/11/05 12:59:33
should we do a namer for this?
kustermann
2013/11/05 13:11:05
We can do it in another CL.
| |
| 1020 % (CHANNEL, REVISION, contentshell_name)), | |
| 1021 }) | |
| 1022 f.AddFile(contentshell_download_script, | |
| 1023 'dart/chromium/download_contentshell%s' % shell_ending) | |
| 1024 | |
| 1025 # Add dartium debug download script | |
| 1026 dartium_debug_name = namer.dartium_variant_zipfilename( | |
| 1027 'dartium', SYSTEM, arch, 'debug') | |
| 1028 dartium_download_script = join(scratch_dir, 'download_dartium_debug') | |
| 1029 instantiate_download_script_template(dartium_download_script, { | |
| 1030 'VAR_DESTINATION' : dartium_debug_name, | |
| 1031 'VAR_DOWNLOAD_URL' : | |
| 1032 ("http://dartlang.org/editor/update/channels/%s/%s/dartium/%s" | |
| 1033 % (CHANNEL, REVISION, dartium_debug_name)), | |
| 1034 }) | |
| 1035 f.AddFile(dartium_download_script, | |
| 1036 'dart/chromium/download_dartium_debug%s' % shell_ending) | |
| 1037 | |
| 968 # Create a editor.properties | 1038 # Create a editor.properties |
| 969 editor_properties = os.path.join(scratch_dir, 'editor.properties') | 1039 editor_properties = os.path.join(scratch_dir, 'editor.properties') |
| 970 with open(editor_properties, 'w') as fd: | 1040 with open(editor_properties, 'w') as fd: |
| 971 fd.write("com.dart.tools.update.core.url=http://dartlang.org" | 1041 fd.write("com.dart.tools.update.core.url=http://dartlang.org" |
| 972 "/editor/update/channels/%s/\n" % CHANNEL) | 1042 "/editor/update/channels/%s/\n" % CHANNEL) |
| 973 | 1043 |
| 974 for zipFile in _FindRcpZipFiles(out_dir): | 1044 for zipFile in _FindRcpZipFiles(out_dir): |
| 975 basename = os.path.basename(zipFile) | 1045 basename = os.path.basename(zipFile) |
| 1046 is_64bit = basename.endswith('-64.zip') | |
| 976 | 1047 |
| 977 print(' processing %s' % basename) | 1048 print(' processing %s' % basename) |
| 978 | 1049 |
| 979 readme_file = join('dart', 'README') | 1050 readme_file = join('dart', 'README') |
| 980 if (basename.startswith('darteditor-win32-')): | 1051 if (basename.startswith('darteditor-win32-')): |
| 981 seven_zip = os.path.join(DART_DIR, 'third_party', '7zip', '7za.exe') | 1052 seven_zip = os.path.join(DART_DIR, 'third_party', '7zip', '7za.exe') |
| 982 bot_utils.run([seven_zip, 'd', zipFile, readme_file], env=os.environ) | 1053 bot_utils.run([seven_zip, 'd', zipFile, readme_file], env=os.environ) |
| 983 else: | 1054 else: |
| 984 bot_utils.run(['zip', '-d', zipFile, readme_file], env=os.environ) | 1055 bot_utils.run(['zip', '-d', zipFile, readme_file], env=os.environ) |
| 985 | 1056 |
| 986 # If we're on -dev/-stable build: add an editor.properties file | 1057 # If we're on -dev/-stable build: add an editor.properties file |
| 987 # pointing to the correct update location of the editor for the channel | 1058 # pointing to the correct update location of the editor for the channel |
| 988 # we're building for. | 1059 # we're building for. |
| 989 if not TRUNK_BUILD and CHANNEL != 'be': | 1060 if not TRUNK_BUILD and CHANNEL != 'be': |
| 990 f = ziputils.ZipUtil(zipFile, buildos) | 1061 f = ziputils.ZipUtil(zipFile, buildos) |
| 991 f.AddFile(editor_properties, 'dart/editor.properties') | 1062 f.AddFile(editor_properties, 'dart/editor.properties') |
| 992 | 1063 |
| 1064 # Add a shell/bat script to download contentshell and dartium debug. | |
| 1065 # (including the necessary tools/dartium/download_file.dart helper). | |
| 1066 add_download_scripts(zipFile, '64' if is_64bit else '32') | |
| 1067 | |
| 993 # adjust memory params for 64 bit versions | 1068 # adjust memory params for 64 bit versions |
| 994 if (basename.endswith('-64.zip')): | 1069 if is_64bit: |
| 995 if (basename.startswith('darteditor-macos-')): | 1070 if (basename.startswith('darteditor-macos-')): |
| 996 inifile = join('dart', 'DartEditor.app', 'Contents', 'MacOS', | 1071 inifile = join('dart', 'DartEditor.app', 'Contents', 'MacOS', |
| 997 'DartEditor.ini') | 1072 'DartEditor.ini') |
| 998 else: | 1073 else: |
| 999 inifile = join('dart', 'DartEditor.ini') | 1074 inifile = join('dart', 'DartEditor.ini') |
| 1000 | 1075 |
| 1001 if (basename.startswith('darteditor-win32-')): | 1076 if (basename.startswith('darteditor-win32-')): |
| 1002 f = zipfile.ZipFile(zipFile) | 1077 f = zipfile.ZipFile(zipFile) |
| 1003 f.extract(inifile.replace('\\','/')) | 1078 f.extract(inifile.replace('\\','/')) |
| 1004 f.close() | 1079 f.close() |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1383 """delete the given file - do not re-throw any exceptions that occur""" | 1458 """delete the given file - do not re-throw any exceptions that occur""" |
| 1384 if os.path.exists(f): | 1459 if os.path.exists(f): |
| 1385 try: | 1460 try: |
| 1386 os.remove(f) | 1461 os.remove(f) |
| 1387 except OSError: | 1462 except OSError: |
| 1388 print 'error deleting %s' % f | 1463 print 'error deleting %s' % f |
| 1389 | 1464 |
| 1390 | 1465 |
| 1391 if __name__ == '__main__': | 1466 if __name__ == '__main__': |
| 1392 sys.exit(main()) | 1467 sys.exit(main()) |
| OLD | NEW |