Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Side by Side Diff: dart/tools/signing_script.py

Issue 68633002: Version 1.0.0.2 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/tools/bots/bot_utils.py ('k') | dart/utils/compiler/compiler.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 hashlib 7 import hashlib
8 import imp 8 import imp
9 import optparse 9 import optparse
10 import os 10 import os
11 import subprocess 11 import subprocess
12 import sys 12 import sys
13 13
14 DART_DIR = os.path.dirname(os.path.dirname(__file__)) 14 DART_DIR = os.path.dirname(os.path.dirname(__file__))
15 GSUTIL = os.path.join(DART_DIR, 'third_party', 'gsutil', 'gsutil') 15 GSUTIL = os.path.join(DART_DIR, 'third_party', 'gsutil', 'gsutil')
16 BOT_UTILS = os.path.join(DART_DIR, 'tools', 'bots', 'bot_utils.py') 16 BOT_UTILS = os.path.join(DART_DIR, 'tools', 'bots', 'bot_utils.py')
17 BASENAME_PATTERN = 'darteditor-%(system)s-%(bits)s' 17 BASENAME_PATTERN = 'darteditor-%(system)s-%(bits)s'
18 FILENAME_PATTERN = BASENAME_PATTERN + '.zip' 18 FILENAME_PATTERN = BASENAME_PATTERN + '.zip'
19 BUCKET_PATTERN = (
20 'gs://dart-editor-archive-trunk/%(revision)s/' + FILENAME_PATTERN)
21 19
22 DRY_RUN = False 20 DRY_RUN = False
23 21
24 bot_utils = imp.load_source('bot_utils', BOT_UTILS) 22 bot_utils = imp.load_source('bot_utils', BOT_UTILS)
25 23
26 class ChangedWorkingDirectory(object): 24 class ChangedWorkingDirectory(object):
27 def __init__(self, working_directory): 25 def __init__(self, working_directory):
28 self._working_directory = working_directory 26 self._working_directory = working_directory
29 27
30 def __enter__(self): 28 def __enter__(self):
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 with ChangedWorkingDirectory(os.path.dirname(to_dir)): 105 with ChangedWorkingDirectory(os.path.dirname(to_dir)):
108 run(['zip', '-r9', dirname + '.zip', dirname]) 106 run(['zip', '-r9', dirname + '.zip', dirname])
109 107
110 def unzip_and_copy(extracted_zipfiledir, to_dir): 108 def unzip_and_copy(extracted_zipfiledir, to_dir):
111 rm_tree(extracted_zipfiledir) 109 rm_tree(extracted_zipfiledir)
112 run(['unzip', extracted_zipfiledir + '.zip', '-d', 110 run(['unzip', extracted_zipfiledir + '.zip', '-d',
113 os.path.dirname(extracted_zipfiledir)]) 111 os.path.dirname(extracted_zipfiledir)])
114 rm_tree(to_dir) 112 rm_tree(to_dir)
115 copy_tree(extracted_zipfiledir, to_dir) 113 copy_tree(extracted_zipfiledir, to_dir)
116 114
117 def download_from_old_location(config, destination):
118 bucket = BUCKET_PATTERN % config
119 run([GSUTIL, 'cp', bucket, destination])
120
121 def upload_to_old_location(config, source_zip):
122 if not DRY_RUN:
123 bot_utils.CreateChecksumFile(
124 source_zip, mangled_filename=os.path.basename(source_zip))
125 md5_zip_file = source_zip + '.md5sum'
126
127 bucket = BUCKET_PATTERN % config
128 run([GSUTIL, 'cp', source_zip, bucket])
129 run([GSUTIL, 'cp', md5_zip_file, bucket + '.md5sum'])
130 run([GSUTIL, 'setacl', 'public-read', bucket])
131 run([GSUTIL, 'setacl', 'public-read', bucket + '.md5sum'])
132
133 def download_from_new_location(channel, config, destination): 115 def download_from_new_location(channel, config, destination):
134 namer = bot_utils.GCSNamer(channel, 116 namer = bot_utils.GCSNamer(channel,
135 bot_utils.ReleaseType.RAW) 117 bot_utils.ReleaseType.RAW)
136 bucket = namer.editor_zipfilepath(config['revision'], config['system'], 118 bucket = namer.editor_zipfilepath(config['revision'], config['system'],
137 config['bits']) 119 config['bits'])
138 run([GSUTIL, 'cp', bucket, destination]) 120 run([GSUTIL, 'cp', bucket, destination])
139 121
140 def upload_to_new_location(channel, config, source_zip): 122 def upload_to_new_location(channel, config, source_zip):
141 namer = bot_utils.GCSNamer(channel, 123 namer = bot_utils.GCSNamer(channel,
142 bot_utils.ReleaseType.SIGNED) 124 bot_utils.ReleaseType.SIGNED)
143 zipfilename = namer.editor_zipfilename(config['system'], config['bits']) 125 zipfilename = namer.editor_zipfilename(config['system'], config['bits'])
144 bucket = namer.editor_zipfilepath(config['revision'], config['system'], 126 bucket = namer.editor_zipfilepath(config['revision'], config['system'],
145 config['bits']) 127 config['bits'])
146 128
147 if not DRY_RUN: 129 if not DRY_RUN:
148 bot_utils.CreateChecksumFile(source_zip, mangled_filename=zipfilename) 130 bot_utils.CreateChecksumFile(source_zip, mangled_filename=zipfilename)
149 md5_zip_file = source_zip + '.md5sum' 131 md5_zip_file = source_zip + '.md5sum'
150 132
151 run([GSUTIL, 'cp', source_zip, bucket]) 133 run([GSUTIL, 'cp', source_zip, bucket])
152 run([GSUTIL, 'cp', md5_zip_file, bucket + '.md5sum']) 134 run([GSUTIL, 'cp', md5_zip_file, bucket + '.md5sum'])
153 run([GSUTIL, 'setacl', 'public-read', bucket]) 135 run([GSUTIL, 'setacl', 'public-read', bucket])
154 run([GSUTIL, 'setacl', 'public-read', bucket + '.md5sum']) 136 run([GSUTIL, 'setacl', 'public-read', bucket + '.md5sum'])
155 137
156 def main(): 138 def main():
157 if sys.platform != 'linux2': 139 if sys.platform != 'linux2':
158 print "This script was only tested on linux. Please run it on linux!" 140 print "This script was only tested on linux. Please run it on linux!"
159 sys.exit(1) 141 sys.exit(1)
160 142
161 parser = GetOptionsParser() 143 parser = GetOptionsParser()
162 (options, args) = parser.parse_args() 144 (options, args) = parser.parse_args()
163 145
164 if not options.scratch_dir: 146 if not options.scratch_dir:
165 die("No scratch directory given.") 147 die("No scratch directory given.")
166 if not options.revision: 148 if not options.revision:
167 die("No revision given.") 149 die("No revision given.")
168 if not options.prepare and not options.deploy: 150 if not options.prepare and not options.deploy:
169 die("No prepare/deploy parameter given.") 151 die("No prepare/deploy parameter given.")
170 if options.prepare and options.deploy: 152 if options.prepare and options.deploy:
171 die("Can't have prepare and deploy parameters at the same time.") 153 die("Can't have prepare and deploy parameters at the same time.")
172 if len(args) > 0: 154 if len(args) > 0:
173 die("Invalid additional arguments: %s." % args) 155 die("Invalid additional arguments: %s." % args)
174 156
175 if options.channel: 157 if not options.channel:
176 assert options.channel in bot_utils.Channel.ALL_CHANNELS 158 die("You need to specify a channel with --channel.")
177 159
178 global DRY_RUN 160 global DRY_RUN
179 DRY_RUN = options.dry_run 161 DRY_RUN = options.dry_run
180 162
181 downloads_dir = os.path.join(options.scratch_dir, 'downloads') 163 downloads_dir = os.path.join(options.scratch_dir, 'downloads')
182 presign_dir = os.path.join(options.scratch_dir, 'presign') 164 presign_dir = os.path.join(options.scratch_dir, 'presign')
183 postsign_dir = os.path.join(options.scratch_dir, 'postsign') 165 postsign_dir = os.path.join(options.scratch_dir, 'postsign')
184 uploads_dir = os.path.join(options.scratch_dir, 'uploads') 166 uploads_dir = os.path.join(options.scratch_dir, 'uploads')
185 167
186 if options.prepare: 168 if options.prepare:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 213 }
232 214
233 destination = os.path.join(downloads_dir, FILENAME_PATTERN % config) 215 destination = os.path.join(downloads_dir, FILENAME_PATTERN % config)
234 destination_dir = os.path.join(downloads_dir, BASENAME_PATTERN % config) 216 destination_dir = os.path.join(downloads_dir, BASENAME_PATTERN % config)
235 217
236 deploy = os.path.join(uploads_dir, FILENAME_PATTERN % config) 218 deploy = os.path.join(uploads_dir, FILENAME_PATTERN % config)
237 deploy_dir = os.path.join(uploads_dir, BASENAME_PATTERN % config) 219 deploy_dir = os.path.join(uploads_dir, BASENAME_PATTERN % config)
238 220
239 if options.prepare: 221 if options.prepare:
240 # Download *.zip files from GCS buckets 222 # Download *.zip files from GCS buckets
241 if options.channel: 223 download_from_new_location(options.channel, config, destination)
242 download_from_new_location(options.channel, config, destination)
243 else:
244 download_from_old_location(config, destination)
245 224
246 run(['unzip', destination, '-d', destination_dir]) 225 run(['unzip', destination, '-d', destination_dir])
247 226
248 for name in ['editor', 'chrome', 'content_shell']: 227 for name in ['editor', 'chrome', 'content_shell']:
249 from_path = os.path.join(destination_dir, locations[system][name]) 228 from_path = os.path.join(destination_dir, locations[system][name])
250 to_path = os.path.join( 229 to_path = os.path.join(
251 presign_dir, locations[system]['%s_scratch' % name] % config) 230 presign_dir, locations[system]['%s_scratch' % name] % config)
252 231
253 if locations[system]['zip']: 232 if locations[system]['zip']:
254 # We copy a .app directory directory and zip it 233 # We copy a .app directory directory and zip it
(...skipping 14 matching lines...) Expand all
269 unzip_and_copy(from_path, to_path) 248 unzip_and_copy(from_path, to_path)
270 else: 249 else:
271 # We copy the signed .exe file 250 # We copy the signed .exe file
272 copy_file(from_path, to_path) 251 copy_file(from_path, to_path)
273 252
274 deploy_zip_file = os.path.abspath(deploy) 253 deploy_zip_file = os.path.abspath(deploy)
275 with ChangedWorkingDirectory(deploy_dir): 254 with ChangedWorkingDirectory(deploy_dir):
276 run(['zip', '-r9', deploy_zip_file, 'dart']) 255 run(['zip', '-r9', deploy_zip_file, 'dart'])
277 256
278 # Upload *.zip/*.zip.md5sum and set 'public-read' ACL 257 # Upload *.zip/*.zip.md5sum and set 'public-read' ACL
279 if options.channel: 258 upload_to_new_location(options.channel, config, deploy_zip_file)
280 upload_to_new_location(options.channel, config, deploy_zip_file)
281 else:
282 upload_to_old_location(config, deploy_zip_file)
283 259
284 if __name__ == '__main__': 260 if __name__ == '__main__':
285 main() 261 main()
286 262
OLDNEW
« no previous file with comments | « dart/tools/bots/bot_utils.py ('k') | dart/utils/compiler/compiler.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698