OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, 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 # Dart Editor promote tools. | 7 # Dart Editor promote tools. |
8 | 8 |
9 import imp | 9 import imp |
10 import optparse | 10 import optparse |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 def _PromoteDartArchiveBuild(channel, revision): | 97 def _PromoteDartArchiveBuild(channel, revision): |
98 # These namer objects will be used to create GCS object URIs. For the | 98 # These namer objects will be used to create GCS object URIs. For the |
99 # structure we use, please see tools/bots/bot_utils.py:GCSNamer | 99 # structure we use, please see tools/bots/bot_utils.py:GCSNamer |
100 raw_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RAW) | 100 raw_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RAW) |
101 signed_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.SIGNED) | 101 signed_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.SIGNED) |
102 release_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RELEASE) | 102 release_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RELEASE) |
103 | 103 |
104 def promote(to_revision): | 104 def promote(to_revision): |
105 def safety_check_on_gs_path(gs_path, revision, channel): | 105 def safety_check_on_gs_path(gs_path, revision, channel): |
106 if not ((revision == 'latest' or int(revision) > 0) | 106 if not (revision != None |
107 and len(channel) > 0 | 107 and len(channel) > 0 |
108 and ('%s' % revision) in gs_path | 108 and ('%s' % revision) in gs_path |
109 and channel in gs_path): | 109 and channel in gs_path): |
110 raise Exception( | 110 raise Exception( |
111 "InternalError: Sanity check failed on GS URI: %s" % gs_path) | 111 "InternalError: Sanity check failed on GS URI: %s" % gs_path) |
112 | 112 |
113 # Google cloud storage has read-after-write, read-after-update, | 113 # Google cloud storage has read-after-write, read-after-update, |
114 # and read-after-delete consistency, but not list after delete consistency. | 114 # and read-after-delete consistency, but not list after delete consistency. |
115 # Because gsutil uses list to figure out if it should do the unix styly | 115 # Because gsutil uses list to figure out if it should do the unix styly |
116 # copy to or copy into, this means that if the directory is reported as | 116 # copy to or copy into, this means that if the directory is reported as |
(...skipping 13 matching lines...) Expand all Loading... |
130 safety_check_on_gs_path(gs_path, to_revision, channel) | 130 safety_check_on_gs_path(gs_path, to_revision, channel) |
131 Gsutil(['-m', 'rm', '-R', '-f', gs_path]) | 131 Gsutil(['-m', 'rm', '-R', '-f', gs_path]) |
132 wait_for_delete_to_be_consistent_with_list(gs_path) | 132 wait_for_delete_to_be_consistent_with_list(gs_path) |
133 | 133 |
134 # Copy sdk directory. | 134 # Copy sdk directory. |
135 from_loc = raw_namer.sdk_directory(revision) | 135 from_loc = raw_namer.sdk_directory(revision) |
136 to_loc = release_namer.sdk_directory(to_revision) | 136 to_loc = release_namer.sdk_directory(to_revision) |
137 remove_gs_directory(to_loc) | 137 remove_gs_directory(to_loc) |
138 Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | 138 Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) |
139 | 139 |
140 # Copy eclipse update directory. | |
141 from_loc = raw_namer.editor_eclipse_update_directory(revision) | |
142 to_loc = release_namer.editor_eclipse_update_directory(to_revision) | |
143 remove_gs_directory(to_loc) | |
144 Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | |
145 | |
146 # Copy api-docs zipfile. | 140 # Copy api-docs zipfile. |
147 from_loc = raw_namer.apidocs_zipfilepath(revision) | 141 from_loc = raw_namer.apidocs_zipfilepath(revision) |
148 to_loc = release_namer.apidocs_zipfilepath(to_revision) | 142 to_loc = release_namer.apidocs_zipfilepath(to_revision) |
149 Gsutil(['-m', 'cp', '-a', 'public-read', from_loc, to_loc]) | 143 Gsutil(['-m', 'cp', '-a', 'public-read', from_loc, to_loc]) |
150 | 144 |
151 # Copy dartium directory. | 145 # Copy dartium directory. |
152 from_loc = raw_namer.dartium_directory(revision) | 146 from_loc = raw_namer.dartium_directory(revision) |
153 to_loc = release_namer.dartium_directory(to_revision) | 147 to_loc = release_namer.dartium_directory(to_revision) |
154 remove_gs_directory(to_loc) | 148 remove_gs_directory(to_loc) |
155 Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | 149 Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) |
156 | 150 |
157 # Copy wheezy linux deb and src packages. | 151 # Copy wheezy linux deb and src packages. |
158 from_loc = raw_namer.linux_packages_directory(revision, 'debian_wheezy') | 152 from_loc = raw_namer.linux_packages_directory(revision, 'debian_wheezy') |
159 to_loc = release_namer.linux_packages_directory(to_revision, | 153 to_loc = release_namer.linux_packages_directory(to_revision, |
160 'debian_wheezy') | 154 'debian_wheezy') |
161 remove_gs_directory(to_loc) | 155 remove_gs_directory(to_loc) |
162 Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | 156 Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) |
163 | 157 |
164 # Copy VERSION file. | 158 # Copy VERSION file. |
165 from_loc = raw_namer.version_filepath(revision) | 159 from_loc = raw_namer.version_filepath(revision) |
166 to_loc = release_namer.version_filepath(to_revision) | 160 to_loc = release_namer.version_filepath(to_revision) |
167 Gsutil(['cp', '-a', 'public-read', from_loc, to_loc]) | 161 Gsutil(['cp', '-a', 'public-read', from_loc, to_loc]) |
168 | 162 |
169 | |
170 promote(revision) | 163 promote(revision) |
171 promote('latest') | 164 promote('latest') |
172 | 165 |
173 def Gsutil(cmd, throw_on_error=True): | 166 def Gsutil(cmd, throw_on_error=True): |
174 gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil') | 167 gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil') |
175 command = [sys.executable, gsutilTool] + cmd | 168 command = [sys.executable, gsutilTool] + cmd |
176 if DRY_RUN: | 169 if DRY_RUN: |
177 print "DRY runnning: %s" % command | 170 print "DRY runnning: %s" % command |
178 return | 171 return |
179 return bot_utils.run(command, throw_on_error=throw_on_error) | 172 return bot_utils.run(command, throw_on_error=throw_on_error) |
180 | 173 |
181 | 174 |
182 if __name__ == '__main__': | 175 if __name__ == '__main__': |
183 sys.exit(main()) | 176 sys.exit(main()) |
OLD | NEW |