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

Side by Side Diff: tools/signing_script.py

Issue 61893007: Cleanup of scripts after removal of trunk builders. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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
« editor/build/promote.py ('K') | « editor/build/promote.py ('k') | no next file » | 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 imp 7 import imp
8 import optparse 8 import optparse
9 import os 9 import os
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 12
13 DART_DIR = os.path.dirname(os.path.dirname(__file__)) 13 DART_DIR = os.path.dirname(os.path.dirname(__file__))
14 GSUTIL = os.path.join(DART_DIR, 'third_party', 'gsutil', 'gsutil') 14 GSUTIL = os.path.join(DART_DIR, 'third_party', 'gsutil', 'gsutil')
15 BOT_UTILS = os.path.join(DART_DIR, 'tools', 'bots', 'bot_utils.py') 15 BOT_UTILS = os.path.join(DART_DIR, 'tools', 'bots', 'bot_utils.py')
16 BASENAME_PATTERN = 'darteditor-%(system)s-%(bits)s' 16 BASENAME_PATTERN = 'darteditor-%(system)s-%(bits)s'
17 FILENAME_PATTERN = BASENAME_PATTERN + '.zip' 17 FILENAME_PATTERN = BASENAME_PATTERN + '.zip'
18 BUCKET_PATTERN = (
19 'gs://dart-editor-archive-trunk/%(revision)s/' + FILENAME_PATTERN)
20 18
21 DRY_RUN = False 19 DRY_RUN = False
22 20
23 bot_utils = imp.load_source('bot_utils', BOT_UTILS) 21 bot_utils = imp.load_source('bot_utils', BOT_UTILS)
24 22
25 class ChangedWorkingDirectory(object): 23 class ChangedWorkingDirectory(object):
26 def __init__(self, working_directory): 24 def __init__(self, working_directory):
27 self._working_directory = working_directory 25 self._working_directory = working_directory
28 26
29 def __enter__(self): 27 def __enter__(self):
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 with ChangedWorkingDirectory(os.path.dirname(to_dir)): 104 with ChangedWorkingDirectory(os.path.dirname(to_dir)):
107 run(['zip', '-r9', dirname + '.zip', dirname]) 105 run(['zip', '-r9', dirname + '.zip', dirname])
108 106
109 def unzip_and_copy(extracted_zipfiledir, to_dir): 107 def unzip_and_copy(extracted_zipfiledir, to_dir):
110 rm_tree(extracted_zipfiledir) 108 rm_tree(extracted_zipfiledir)
111 run(['unzip', extracted_zipfiledir + '.zip', '-d', 109 run(['unzip', extracted_zipfiledir + '.zip', '-d',
112 os.path.dirname(extracted_zipfiledir)]) 110 os.path.dirname(extracted_zipfiledir)])
113 rm_tree(to_dir) 111 rm_tree(to_dir)
114 copy_tree(extracted_zipfiledir, to_dir) 112 copy_tree(extracted_zipfiledir, to_dir)
115 113
116 def download_from_old_location(config, destination):
117 bucket = BUCKET_PATTERN % config
118 run([GSUTIL, 'cp', bucket, destination])
119
120 def upload_to_old_location(config, source_zip):
121 if not DRY_RUN:
122 bot_utils.CreateChecksumFile(
123 source_zip, mangled_filename=os.path.basename(source_zip))
124 md5_zip_file = source_zip + '.md5sum'
125
126 bucket = BUCKET_PATTERN % config
127 run([GSUTIL, 'cp', source_zip, bucket])
128 run([GSUTIL, 'cp', md5_zip_file, bucket + '.md5sum'])
129 run([GSUTIL, 'setacl', 'public-read', bucket])
130 run([GSUTIL, 'setacl', 'public-read', bucket + '.md5sum'])
131
132 def download_from_new_location(channel, config, destination): 114 def download_from_new_location(channel, config, destination):
133 namer = bot_utils.GCSNamer(channel, 115 namer = bot_utils.GCSNamer(channel,
134 bot_utils.ReleaseType.RAW) 116 bot_utils.ReleaseType.RAW)
135 bucket = namer.editor_zipfilepath(config['revision'], config['system'], 117 bucket = namer.editor_zipfilepath(config['revision'], config['system'],
136 config['bits']) 118 config['bits'])
137 run([GSUTIL, 'cp', bucket, destination]) 119 run([GSUTIL, 'cp', bucket, destination])
138 120
139 def download_msi_installer_from_new_location(channel, config, destination): 121 def download_msi_installer_from_new_location(channel, config, destination):
140 namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RAW) 122 namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RAW)
141 bucket = namer.editor_installer_filepath( 123 bucket = namer.editor_installer_filepath(
142 config['revision'], config['system'], config['bits'], 'msi') 124 config['revision'], config['system'], config['bits'], 'msi')
143 run([GSUTIL, 'cp', bucket, destination]) 125 run([GSUTIL, 'cp', bucket, destination])
144 126
145 def upload_to_new_location(channel, config, source_zip): 127 def upload_to_new_location(channel, config, source_zip):
146 namer = bot_utils.GCSNamer(channel, 128 namer = bot_utils.GCSNamer(channel,
147 bot_utils.ReleaseType.SIGNED) 129 bot_utils.ReleaseType.SIGNED)
148 zipfilename = namer.editor_zipfilename(config['system'], config['bits']) 130 zipfilename = namer.editor_zipfilename(config['system'], config['bits'])
149 bucket = namer.editor_zipfilepath(config['revision'], config['system'], 131 bucket = namer.editor_zipfilepath(config['revision'], config['system'],
150 config['bits']) 132 config['bits'])
151 133
152 if not DRY_RUN: 134 if not DRY_RUN:
153 bot_utils.CreateChecksumFile(source_zip, mangled_filename=zipfilename) 135 bot_utils.CreateChecksumFile(source_zip, mangled_filename=zipfilename)
154 md5_zip_file = source_zip + '.md5sum' 136 md5_zip_file = source_zip + '.md5sum'
155 137
156 run([GSUTIL, 'cp', source_zip, bucket]) 138 run([GSUTIL, 'cp', source_zip, bucket])
157 run([GSUTIL, 'cp', md5_zip_file, bucket + '.md5sum']) 139 run([GSUTIL, 'cp', md5_zip_file, bucket + '.md5sum'])
158 run([GSUTIL, 'setacl', 'public-read', bucket]) 140 run([GSUTIL, 'setacl', 'public-read', bucket])
159 run([GSUTIL, 'setacl', 'public-read', bucket + '.md5sum']) 141 run([GSUTIL, 'setacl', 'public-read', bucket + '.md5sum'])
160 142
161 def upload_msi_installer_to_new_location(channel, config, signed_msi): 143 def upload_msi_installer_to_new_location(channel, config, signed_msi):
162 namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.SIGNED) 144 namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.SIGNED)
163 bucket = namer.editor_installer_filepath( 145 bucket = namer.editor_installer_filepath(
164 config['revision'], config['system'], config['bits'], 'msi') 146 config['revision'], config['system'], config['bits'], 'msi')
165 run([GSUTIL, 'cp', '-a', 'public-read', signed_msi, bucket]) 147 run([GSUTIL, 'cp', '-a', 'public-read', signed_msi, bucket])
(...skipping 10 matching lines...) Expand all
176 die("No scratch directory given.") 158 die("No scratch directory given.")
177 if not options.revision: 159 if not options.revision:
178 die("No revision given.") 160 die("No revision given.")
179 if not options.prepare and not options.deploy: 161 if not options.prepare and not options.deploy:
180 die("No prepare/deploy parameter given.") 162 die("No prepare/deploy parameter given.")
181 if options.prepare and options.deploy: 163 if options.prepare and options.deploy:
182 die("Can't have prepare and deploy parameters at the same time.") 164 die("Can't have prepare and deploy parameters at the same time.")
183 if len(args) > 0: 165 if len(args) > 0:
184 die("Invalid additional arguments: %s." % args) 166 die("Invalid additional arguments: %s." % args)
185 167
186 if options.channel: 168 if not options.channel:
187 assert options.channel in bot_utils.Channel.ALL_CHANNELS 169 die("You need to specify a channel with --channel.")
188 170
189 global DRY_RUN 171 global DRY_RUN
190 DRY_RUN = options.dry_run 172 DRY_RUN = options.dry_run
191 173
192 downloads_dir = os.path.join(options.scratch_dir, 'downloads') 174 downloads_dir = os.path.join(options.scratch_dir, 'downloads')
193 presign_dir = os.path.join(options.scratch_dir, 'presign') 175 presign_dir = os.path.join(options.scratch_dir, 'presign')
194 postsign_dir = os.path.join(options.scratch_dir, 'postsign') 176 postsign_dir = os.path.join(options.scratch_dir, 'postsign')
195 uploads_dir = os.path.join(options.scratch_dir, 'uploads') 177 uploads_dir = os.path.join(options.scratch_dir, 'uploads')
196 178
197 if options.prepare: 179 if options.prepare:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 225 }
244 226
245 destination = os.path.join(downloads_dir, FILENAME_PATTERN % config) 227 destination = os.path.join(downloads_dir, FILENAME_PATTERN % config)
246 destination_dir = os.path.join(downloads_dir, BASENAME_PATTERN % config) 228 destination_dir = os.path.join(downloads_dir, BASENAME_PATTERN % config)
247 229
248 deploy = os.path.join(uploads_dir, FILENAME_PATTERN % config) 230 deploy = os.path.join(uploads_dir, FILENAME_PATTERN % config)
249 deploy_dir = os.path.join(uploads_dir, BASENAME_PATTERN % config) 231 deploy_dir = os.path.join(uploads_dir, BASENAME_PATTERN % config)
250 232
251 if options.prepare: 233 if options.prepare:
252 # Download *.zip files from GCS buckets 234 # Download *.zip files from GCS buckets
253 if options.channel: 235 download_from_new_location(options.channel, config, destination)
254 download_from_new_location(options.channel, config, destination)
255 else:
256 download_from_old_location(config, destination)
257 236
258 run(['unzip', destination, '-d', destination_dir]) 237 run(['unzip', destination, '-d', destination_dir])
259 238
260 for name in ['editor', 'chrome', 'content_shell']: 239 for name in ['editor', 'chrome', 'content_shell']:
261 from_path = os.path.join(destination_dir, locations[system][name]) 240 from_path = os.path.join(destination_dir, locations[system][name])
262 to_path = os.path.join( 241 to_path = os.path.join(
263 presign_dir, locations[system]['%s_scratch' % name] % config) 242 presign_dir, locations[system]['%s_scratch' % name] % config)
264 243
265 if locations[system]['zip']: 244 if locations[system]['zip']:
266 # We copy a .app directory directory and zip it 245 # We copy a .app directory directory and zip it
(...skipping 21 matching lines...) Expand all
288 unzip_and_copy(from_path, to_path) 267 unzip_and_copy(from_path, to_path)
289 else: 268 else:
290 # We copy the signed .exe file 269 # We copy the signed .exe file
291 copy_file(from_path, to_path) 270 copy_file(from_path, to_path)
292 271
293 deploy_zip_file = os.path.abspath(deploy) 272 deploy_zip_file = os.path.abspath(deploy)
294 with ChangedWorkingDirectory(deploy_dir): 273 with ChangedWorkingDirectory(deploy_dir):
295 run(['zip', '-r9', deploy_zip_file, 'dart']) 274 run(['zip', '-r9', deploy_zip_file, 'dart'])
296 275
297 # Upload *.zip/*.zip.md5sum and set 'public-read' ACL 276 # Upload *.zip/*.zip.md5sum and set 'public-read' ACL
298 if options.channel: 277 upload_to_new_location(options.channel, config, deploy_zip_file)
299 upload_to_new_location(options.channel, config, deploy_zip_file)
300 else:
301 upload_to_old_location(config, deploy_zip_file)
302 278
303 # Upload *.msi installer and set 'public-read ACL 279 # Upload *.msi installer and set 'public-read ACL
304 if system == 'win32': 280 if system == 'win32':
305 postsign_msi = os.path.join( 281 postsign_msi = os.path.join(
306 postsign_dir, locations[system]['msi_scratch'] % config) 282 postsign_dir, locations[system]['msi_scratch'] % config)
307 upload_msi_installer_to_new_location( 283 upload_msi_installer_to_new_location(
308 options.channel, config, postsign_msi) 284 options.channel, config, postsign_msi)
309 285
310 if __name__ == '__main__': 286 if __name__ == '__main__':
311 main() 287 main()
312 288
OLDNEW
« editor/build/promote.py ('K') | « editor/build/promote.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698