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

Side by Side Diff: native_client_sdk/src/build_tools/update_nacl_manifest.py

Issue 10414011: [NaCl SDK] Some fixes to update_nacl_manifest.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months 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 | « native_client_sdk/src/build_tools/tests/test_update_manifest.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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Script that reads omahaproxy and gsutil to determine version of SDK to put 6 """Script that reads omahaproxy and gsutil to determine version of SDK to put
7 in manifest. 7 in manifest.
8 """ 8 """
9 9
10 import buildbot_common 10 import buildbot_common
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 Returns: 112 Returns:
113 A list where each element is a line from the document, represented as a 113 A list where each element is a line from the document, represented as a
114 tuple.""" 114 tuple."""
115 raise NotImplementedError() 115 raise NotImplementedError()
116 116
117 def GsUtil_ls(self, url): 117 def GsUtil_ls(self, url):
118 """Runs gsutil ls |url| 118 """Runs gsutil ls |url|
119 119
120 Args: 120 Args:
121 url: The commondatastorage url to list.""" 121 url: The commondatastorage url to list.
122 Returns:
123 A list of URLs, all with the gs:// schema."""
122 raise NotImplementedError() 124 raise NotImplementedError()
123 125
124 def GsUtil_cat(self, url): 126 def GsUtil_cat(self, url):
125 """Runs gsutil cat |url| 127 """Runs gsutil cat |url|
126 128
127 Args: 129 Args:
128 url: The commondatastorage url to read from.""" 130 url: The commondatastorage url to read from.
131 Returns:
132 A string with the contents of the file at |url|."""
129 raise NotImplementedError() 133 raise NotImplementedError()
130 134
131 def GsUtil_cp(self, src, dest, stdin=None): 135 def GsUtil_cp(self, src, dest, stdin=None):
132 """Runs gsutil cp |src| |dest| 136 """Runs gsutil cp |src| |dest|
133 137
134 Args: 138 Args:
135 src: The file path or url to copy from. 139 src: The file path or url to copy from.
136 dest: The file path or url to copy to. 140 dest: The file path or url to copy to.
137 stdin: If src is '-', this is used as the stdin to give to gsutil. The 141 stdin: If src is '-', this is used as the stdin to give to gsutil. The
138 effect is that text in stdin is copied to |dest|.""" 142 effect is that text in stdin is copied to |dest|."""
(...skipping 30 matching lines...) Expand all
169 173
170 # filter out empty lines 174 # filter out empty lines
171 return filter(None, stdout.split('\n')) 175 return filter(None, stdout.split('\n'))
172 176
173 def GsUtil_cat(self, url): 177 def GsUtil_cat(self, url):
174 """See Delegate.GsUtil_cat""" 178 """See Delegate.GsUtil_cat"""
175 return self._RunGsUtil(None, 'cat', url) 179 return self._RunGsUtil(None, 'cat', url)
176 180
177 def GsUtil_cp(self, src, dest, stdin=None): 181 def GsUtil_cp(self, src, dest, stdin=None):
178 """See Delegate.GsUtil_cp""" 182 """See Delegate.GsUtil_cp"""
179 return self._RunGsUtil(stdin, 'cp', '-a', 'public-read', src, dest) 183 # -p ensures we keep permissions when copying "in-the-cloud".
184 return self._RunGsUtil(stdin, 'cp', '-p', '-a', 'public-read', src, dest)
180 185
181 def Print(self, *args): 186 def Print(self, *args):
182 sys.stdout.write(' '.join(map(str, args)) + '\n') 187 sys.stdout.write(' '.join(map(str, args)) + '\n')
183 188
184 def _RunGsUtil(self, stdin, *args): 189 def _RunGsUtil(self, stdin, *args):
185 """Run gsutil as a subprocess. 190 """Run gsutil as a subprocess.
186 191
187 Args: 192 Args:
188 stdin: If non-None, used as input to the process. 193 stdin: If non-None, used as input to the process.
189 *args: Arguments to pass to gsutil. The first argument should be an 194 *args: Arguments to pass to gsutil. The first argument should be an
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 # force increment to next version for all platforms 304 # force increment to next version for all platforms
300 shared_version = None 305 shared_version = None
301 306
302 def _GetAvailableNaClSDKArchivesFor(self, version_string): 307 def _GetAvailableNaClSDKArchivesFor(self, version_string):
303 """Downloads a list of all available archives for a given version. 308 """Downloads a list of all available archives for a given version.
304 309
305 Args: 310 Args:
306 version_string: The version to find archives for. (e.g. "18.0.1025.164") 311 version_string: The version to find archives for. (e.g. "18.0.1025.164")
307 Returns: 312 Returns:
308 A list of strings, each of which is a platform-specific archive URL. (e.g. 313 A list of strings, each of which is a platform-specific archive URL. (e.g.
309 "https://commondatastorage.googleapis.com/nativeclient_mirror/nacl/" 314 "gs://nativeclient_mirror/nacl/nacl_sdk/18.0.1025.164/naclsdk_linux.bz2").
310 "nacl_sdk/18.0.1025.164/naclsdk_linux.bz2". 315
311 """ 316 All returned URLs will use the gs:// schema."""
312 files = self.delegate.GsUtil_ls(GS_BUCKET_PATH + version_string) 317 files = self.delegate.GsUtil_ls(GS_BUCKET_PATH + version_string)
318 assert all(file.startswith('gs://') for file in files)
319
313 archives = [file for file in files if not file.endswith('.json')] 320 archives = [file for file in files if not file.endswith('.json')]
314 manifests = [file for file in files if file.endswith('.json')] 321 manifests = [file for file in files if file.endswith('.json')]
315 322
316 # don't include any archives that don't have an associated manifest. 323 # don't include any archives that don't have an associated manifest.
317 return filter(lambda a: a + '.json' in manifests, archives) 324 return filter(lambda a: a + '.json' in manifests, archives)
318 325
319 326
320 class Updater(object): 327 class Updater(object):
321 def __init__(self, delegate): 328 def __init__(self, delegate):
322 self.delegate = delegate 329 self.delegate = delegate
(...skipping 26 matching lines...) Expand all
349 bundle.recommended = bundle_recommended 356 bundle.recommended = bundle_recommended
350 manifest.MergeBundle(bundle) 357 manifest.MergeBundle(bundle)
351 self._UploadManifest(manifest) 358 self._UploadManifest(manifest)
352 self.delegate.Print('Done.') 359 self.delegate.Print('Done.')
353 360
354 def _GetPlatformArchiveBundle(self, archive): 361 def _GetPlatformArchiveBundle(self, archive):
355 """Downloads the manifest "snippet" for an archive, and reads it as a 362 """Downloads the manifest "snippet" for an archive, and reads it as a
356 Bundle. 363 Bundle.
357 364
358 Args: 365 Args:
359 archive: The URL of a platform-specific archive. 366 archive: A full URL of a platform-specific archive, using the gs schema.
360 Returns: 367 Returns:
361 An object of type manifest_util.Bundle, read from a JSON file storing 368 An object of type manifest_util.Bundle, read from a JSON file storing
362 metadata for this archive. 369 metadata for this archive.
363 """ 370 """
364 stdout = self.delegate.GsUtil_cat(GS_BUCKET_PATH + archive + '.json') 371 stdout = self.delegate.GsUtil_cat(archive + '.json')
365 bundle = manifest_util.Bundle('') 372 bundle = manifest_util.Bundle('')
366 bundle.LoadDataFromString(stdout) 373 bundle.LoadDataFromString(stdout)
374 # Some snippets were uploaded with revisions and versions as strings. Fix
375 # those here.
376 bundle.revision = int(bundle.revision)
377 bundle.version = int(bundle.version)
367 return bundle 378 return bundle
368 379
369 def _UploadManifest(self, manifest): 380 def _UploadManifest(self, manifest):
370 """Upload a serialized manifest_util.SDKManifest object. 381 """Upload a serialized manifest_util.SDKManifest object.
371 382
372 Upload one copy to gs://<BUCKET_PATH>/naclsdk_manifest2.json, and a copy to 383 Upload one copy to gs://<BUCKET_PATH>/naclsdk_manifest2.json, and a copy to
373 gs://<BUCKET_PATH>/manifest_backups/naclsdk_manifest2.<TIMESTAMP>.json. 384 gs://<BUCKET_PATH>/manifest_backups/naclsdk_manifest2.<TIMESTAMP>.json.
374 385
375 Args: 386 Args:
376 manifest: The new manifest to upload. 387 manifest: The new manifest to upload.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 updater.Update(manifest) 422 updater.Update(manifest)
412 423
413 424
414 def main(args): 425 def main(args):
415 delegate = RealDelegate() 426 delegate = RealDelegate()
416 Run(delegate, ('mac', 'win', 'linux')) 427 Run(delegate, ('mac', 'win', 'linux'))
417 428
418 429
419 if __name__ == '__main__': 430 if __name__ == '__main__':
420 sys.exit(main(sys.argv)) 431 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/tests/test_update_manifest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698