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

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

Issue 11759011: [NaCl SDK] Update sdk_tools to 160493->174973. Also added script to make updating sdk_tools easier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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/json/naclsdk_manifest2.json ('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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 """Script that reads omahaproxy and gsutil to determine a version of the
7 sdk_tools bundle to use.
8
9 Please note the differences between this script and update_nacl_manifest.py:
10
11 update_sdktools.py is run by a SDK-team developer to assist in updating to a
12 new sdk_tools bundle. A file on the developer's hard drive is modified, and
13 must be checked in for the new sdk_tools bundle to be used.
14
15 update_nacl_manifest.py is customarily run by a cron job, and does not check in
16 any changes. Instead it modifies the manifest file in commondatastorage."""
17
18
19 import collections
20 import difflib
21 import json
22 from manifest_util import DownloadAndComputeHash
23 import optparse
24 import re
25 import sys
26 from update_nacl_manifest import RealDelegate
noelallen1 2013/01/08 23:22:57 optional seperate CL: The name RealDelegate is un
binji 2013/01/09 19:13:25 Added TODO with bug# below.
27 import urllib2
28
29
30 SDK_TOOLS_DESCRIPTION_FORMAT = 'Native Client SDK Tools, revision %d'
31 BUCKET_PATH = 'nativeclient-mirror/nacl/nacl_sdk/'
32 GS_BUCKET_PATH = 'gs://' + BUCKET_PATH
33 HTTPS_BUCKET_PATH = 'https://commondatastorage.googleapis.com/' + BUCKET_PATH
34
35
36 def GetSdkToolsUrl(revision):
37 return HTTPS_BUCKET_PATH + 'trunk.%d/sdk_tools.tgz' % revision
38
39
40 def GetTrunkRevisions(delegate):
41 urls = delegate.GsUtil_ls(GS_BUCKET_PATH)
42 revisions = []
43 for url in urls:
44 m = re.match(GS_BUCKET_PATH + 'trunk\.(\d+)', url)
45 if m:
46 revisions.append((int(m.group(1)), url))
47 return sorted(revisions)
48
49
50 def FindMostRecentSdkTools(delegate):
noelallen1 2013/01/08 23:22:57 Why is this called MostRecentSdkTools? I don't se
binji 2013/01/09 19:13:25 Done.
51 for revision, url in reversed(GetTrunkRevisions(delegate)):
52 if delegate.GsUtil_ls(url):
53 return revision, url
54 return None
55
56
57 def JsonLoadFromString(json_string):
58 if sys.version_info > (2, 7):
59 return json.loads(json_string, object_pairs_hook=collections.OrderedDict)
60 else:
61 return json.loads(json_string)
62
63
64 def GetBundleByName(bundles, name):
65 for bundle in bundles:
66 if bundle['name'] == name:
67 return bundle
68 return None
69
70
71 def UpdateSdkToolsBundle(sdk_tools_bundle, revision, url, sha1, size):
72 sdk_tools_bundle['description'] = SDK_TOOLS_DESCRIPTION_FORMAT % revision
73 sdk_tools_bundle['revision'] = revision
74 # Update archive for each OS
75 for archive in sdk_tools_bundle['archives']:
76 archive['url'] = url
77 archive['checksum']['sha1'] = sha1
78 archive['size'] = size
79
80
81 def UpdateManifest(manifest, revision):
82 sdk_tools_bundle = GetBundleByName(manifest['bundles'], 'sdk_tools')
83 url = GetSdkToolsUrl(revision)
84 sha1, size = DownloadAndComputeHash(urllib2.urlopen(url))
85 UpdateSdkToolsBundle(sdk_tools_bundle, revision, url, sha1, size)
86
87
88 def UpdateManifestFileToRevision(filename, revision):
89 with open(filename) as stream:
90 manifest_string = stream.read()
91
92 manifest = JsonLoadFromString(manifest_string)
93 UpdateManifest(manifest, revision)
94 new_manifest_string = json.dumps(manifest, indent=2)
95
96 diff_string = ''.join(difflib.unified_diff(manifest_string.splitlines(1),
97 new_manifest_string.splitlines(1)))
98
99 print 'diff %s' % filename
noelallen1 2013/01/08 23:22:57 Did you mean to print this, or is this just diagno
binji 2013/01/09 19:13:25 I think it is useful output, but I can hide it beh
100 print diff_string
101 print
102
103 with open(filename, 'w') as stream:
104 stream.write(new_manifest_string)
105
106
107 def main(args):
108 parser = optparse.OptionParser()
109 parser.add_option('-r', '--revision',
110 help='set revision manually, rather than using the latest version')
111 options, _ = parser.parse_args(args[1:])
112
noelallen1 2013/01/08 23:22:57 nit: assert args = 0 instead of silently dropping
binji 2013/01/09 19:13:25 Done.
113 delegate = RealDelegate()
114 if not options.revision:
115 revision, _ = FindMostRecentSdkTools(delegate)
116 else:
117 revision = int(options.revision)
118
119 UpdateManifestFileToRevision('json/naclsdk_manifest0.json', revision)
120 UpdateManifestFileToRevision('json/naclsdk_manifest2.json', revision)
121
122
123 if __name__ == '__main__':
124 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/json/naclsdk_manifest2.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698