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

Side by Side Diff: bin/cros_mark_chrome_as_stable.py

Issue 5154008: Add ability to rev and build a chrome from cbuildbot (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Stuffs Created 10 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
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """This module uprevs Chrome for cbuildbot.""" 7 """This module uprevs Chrome for cbuildbot."""
8 8
9 import optparse 9 import optparse
10 import os 10 import os
11 import re 11 import re
(...skipping 13 matching lines...) Expand all
25 CHROME_REV = [TIP_OF_TRUNK, LATEST_RELEASE, STICKY] 25 CHROME_REV = [TIP_OF_TRUNK, LATEST_RELEASE, STICKY]
26 26
27 # Helper regex's for finding ebuilds. 27 # Helper regex's for finding ebuilds.
28 _CHROME_VERSION_REGEX = '\d+\.\d+\.\d+\.\d+' 28 _CHROME_VERSION_REGEX = '\d+\.\d+\.\d+\.\d+'
29 _NON_STICKY_REGEX = '%s[(_rc.*)|(_alpha.*)]+' % _CHROME_VERSION_REGEX 29 _NON_STICKY_REGEX = '%s[(_rc.*)|(_alpha.*)]+' % _CHROME_VERSION_REGEX
30 30
31 # Dir where all the action happens. 31 # Dir where all the action happens.
32 _CHROME_OVERLAY_DIR = ('%(srcroot)s/third_party/chromiumos-overlay' 32 _CHROME_OVERLAY_DIR = ('%(srcroot)s/third_party/chromiumos-overlay'
33 '/chromeos-base/chromeos-chrome') 33 '/chromeos-base/chromeos-chrome')
34 34
35 # Different than cros_mark so devs don't have local collisions.
36 _STABLE_BRANCH_NAME = 'chrome_stabilizing_branch'
37
38 _GIT_COMMIT_MESSAGE = ('Marking %(chrome_rev)s for chrome ebuild with version ' 35 _GIT_COMMIT_MESSAGE = ('Marking %(chrome_rev)s for chrome ebuild with version '
39 '%(chrome_version)s as stable.') 36 '%(chrome_version)s as stable.')
40 37
41 38
42 def _GetSvnUrl(): 39 def _GetSvnUrl():
43 """Returns the path to the svn url for the given chrome branch.""" 40 """Returns the path to the svn url for the given chrome branch."""
44 return os.path.join(BASE_CHROME_SVN_URL, 'trunk') 41 return os.path.join(BASE_CHROME_SVN_URL, 'trunk')
45 42
46 43
47 def _GetTipOfTrunkSvnRevision(): 44 def _GetTipOfTrunkSvnRevision():
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 unstable_ebuild: ebuild corresponding to the unstable ebuild for chrome. 225 unstable_ebuild: ebuild corresponding to the unstable ebuild for chrome.
229 chrome_rev: one of CHROME_REV 226 chrome_rev: one of CHROME_REV
230 TIP_OF_TRUNK - Requires commit value. Revs the ebuild for the TOT 227 TIP_OF_TRUNK - Requires commit value. Revs the ebuild for the TOT
231 version and uses the portage suffix of _alpha. 228 version and uses the portage suffix of _alpha.
232 LATEST_RELEASE - This uses the portage suffix of _rc as they are release 229 LATEST_RELEASE - This uses the portage suffix of _rc as they are release
233 candidates for the next sticky version. 230 candidates for the next sticky version.
234 STICKY - Revs the sticky version. 231 STICKY - Revs the sticky version.
235 chrome_version: The \d.\d.\d.\d version of Chrome. 232 chrome_version: The \d.\d.\d.\d version of Chrome.
236 commit: Used with TIP_OF_TRUNK. The svn revision of chrome. 233 commit: Used with TIP_OF_TRUNK. The svn revision of chrome.
237 overlay_dir: Path to the chromeos-chrome package dir. 234 overlay_dir: Path to the chromeos-chrome package dir.
235 Returns:
236 Full portage version atom (including rc's, etc) that was revved.
238 """ 237 """
239 base_path = os.path.join(overlay_dir, 'chromeos-chrome-%s' % chrome_version) 238 base_path = os.path.join(overlay_dir, 'chromeos-chrome-%s' % chrome_version)
240 # Case where we have the last stable candidate with same version just rev. 239 # Case where we have the last stable candidate with same version just rev.
241 if stable_candidate and stable_candidate.chrome_version == chrome_version: 240 if stable_candidate and stable_candidate.chrome_version == chrome_version:
242 new_ebuild_path = '%s-r%d.ebuild' % ( 241 new_ebuild_path = '%s-r%d.ebuild' % (
243 stable_candidate.ebuild_path_no_revision, 242 stable_candidate.ebuild_path_no_revision,
244 stable_candidate.current_revision + 1) 243 stable_candidate.current_revision + 1)
245 else: 244 else:
246 if chrome_rev == TIP_OF_TRUNK: 245 if chrome_rev == TIP_OF_TRUNK:
247 portage_suffix = '_alpha' 246 portage_suffix = '_alpha'
248 else: 247 else:
249 portage_suffix = '_rc' 248 portage_suffix = '_rc'
250 249
251 new_ebuild_path = base_path + ('%s-r1.ebuild' % portage_suffix) 250 new_ebuild_path = base_path + ('%s-r1.ebuild' % portage_suffix)
252 251
253 cros_mark_as_stable.EBuildStableMarker.MarkAsStable( 252 cros_mark_as_stable.EBuildStableMarker.MarkAsStable(
254 unstable_ebuild.ebuild_path, new_ebuild_path, 'CROS_SVN_COMMIT', commit) 253 unstable_ebuild.ebuild_path, new_ebuild_path, 'CROS_SVN_COMMIT', commit)
255 RunCommand(['git', 'add', new_ebuild_path]) 254 RunCommand(['git', 'add', new_ebuild_path])
256 if stable_candidate: 255 if stable_candidate:
257 RunCommand(['git', 'rm', stable_candidate.ebuild_path]) 256 RunCommand(['git', 'rm', stable_candidate.ebuild_path])
258 257
259 cros_mark_as_stable.EBuildStableMarker.CommitChange( 258 cros_mark_as_stable.EBuildStableMarker.CommitChange(
260 _GIT_COMMIT_MESSAGE % {'chrome_rev': chrome_rev, 259 _GIT_COMMIT_MESSAGE % {'chrome_rev': chrome_rev,
261 'chrome_version': chrome_version}) 260 'chrome_version': chrome_version})
262 261
262 new_ebuild = ChromeEBuild(new_ebuild_path)
263 return '%s-%s' % (new_ebuild.package, new_ebuild.version)
264
263 265
264 def main(argv): 266 def main(argv):
265 usage = '%s OPTIONS commit|clean|push' 267 usage = '%s OPTIONS [%s]' % ((__file__), '|'.join(CHROME_REV))
scottz 2010/11/23 02:44:40 __file__ withut the parens?
sosa 2010/11/23 21:09:19 Done.
266 parser = optparse.OptionParser(usage) 268 parser = optparse.OptionParser(usage)
267 parser.add_option('-c', '--chrome_rev', default=None, 269 parser.add_option('-s', '--srcroot', default=('%s/trunk/src' %
scottz 2010/11/23 02:44:40 os.path.join(os.environ['HOME'], ....)
sosa 2010/11/23 21:09:19 Done.
268 help='One of %s' % CHROME_REV) 270 os.environ['HOME']),
269 parser.add_option('-s', '--srcroot', default='.',
270 help='Path to the src directory') 271 help='Path to the src directory')
271 parser.add_option('-t', '--tracking_branch', default='cros/master', 272 parser.add_option('-t', '--tracking_branch', default='cros/master',
272 help='Branch we are tracking changes against') 273 help='Branch we are tracking changes against')
273 (options, argv) = parser.parse_args(argv) 274 (options, argv) = parser.parse_args(argv)
scottz 2010/11/23 02:44:40 I know this isn't your code but this is bad. We ar
sosa 2010/11/23 21:09:19 Done.
274 275
275 if len(argv) != 2 or argv[1] not in ( 276 if len(argv) != 2 or argv[1] not in CHROME_REV:
276 cros_mark_as_stable.COMMAND_DICTIONARY.keys()): 277 parser.error('Commit requires arg set to one of %s.' % CHROME_REV)
277 parser.error('Arguments are invalid, see usage.')
278 278
279 command = argv[1]
280 overlay_dir = os.path.abspath(_CHROME_OVERLAY_DIR % 279 overlay_dir = os.path.abspath(_CHROME_OVERLAY_DIR %
281 {'srcroot': options.srcroot}) 280 {'srcroot': options.srcroot})
282 281 chrome_rev = argv[1]
283 os.chdir(overlay_dir)
284 if command == 'clean':
285 cros_mark_as_stable.Clean(options.tracking_branch)
286 return
287 elif command == 'push':
288 cros_mark_as_stable.PushChange(_STABLE_BRANCH_NAME, options.tracking_branch)
289 return
290
291 if not options.chrome_rev or options.chrome_rev not in CHROME_REV:
292 parser.error('Commit requires type set to one of %s.' % CHROME_REV)
293
294 chrome_rev = options.chrome_rev
295 version_to_uprev = None 282 version_to_uprev = None
296 commit_to_use = None 283 commit_to_use = None
297 284
298 (unstable_ebuild, stable_ebuilds) = FindChromeCandidates(overlay_dir) 285 (unstable_ebuild, stable_ebuilds) = FindChromeCandidates(overlay_dir)
299 sticky_version = _GetStickyVersion(stable_ebuilds) 286 sticky_version = _GetStickyVersion(stable_ebuilds)
300 sticky_branch = sticky_version.rpartition('.')[0] 287 sticky_branch = sticky_version.rpartition('.')[0]
301 288
302 if chrome_rev == TIP_OF_TRUNK: 289 if chrome_rev == TIP_OF_TRUNK:
303 version_to_uprev = _GetTipOfTrunkVersion() 290 version_to_uprev = _GetTipOfTrunkVersion()
304 commit_to_use = _GetTipOfTrunkSvnRevision() 291 commit_to_use = _GetTipOfTrunkSvnRevision()
305 elif chrome_rev == LATEST_RELEASE: 292 elif chrome_rev == LATEST_RELEASE:
306 version_to_uprev = _GetLatestRelease() 293 version_to_uprev = _GetLatestRelease()
307 else: 294 else:
308 version_to_uprev = _GetLatestRelease(sticky_branch) 295 version_to_uprev = _GetLatestRelease(sticky_branch)
309 296
310 stable_candidate = FindChromeUprevCandidate(stable_ebuilds, chrome_rev, 297 stable_candidate = FindChromeUprevCandidate(stable_ebuilds, chrome_rev,
311 sticky_branch) 298 sticky_branch)
312 # There are some cases we don't need to do anything. Check for them. 299 # There are some cases we don't need to do anything. Check for them.
313 if stable_candidate and (version_to_uprev == stable_candidate.chrome_version 300 if stable_candidate and (version_to_uprev == stable_candidate.chrome_version
314 and not commit_to_use): 301 and not commit_to_use):
315 Info('Found nothing to do for chrome_rev %s with version %s.' % ( 302 Info('Found nothing to do for chrome_rev %s with version %s.' % (
316 chrome_rev, version_to_uprev)) 303 chrome_rev, version_to_uprev))
317 else: 304 else:
305 os.chdir(overlay_dir)
318 work_branch = cros_mark_as_stable.GitBranch( 306 work_branch = cros_mark_as_stable.GitBranch(
319 _STABLE_BRANCH_NAME, options.tracking_branch) 307 cros_mark_as_stable.STABLE_BRANCH_NAME, options.tracking_branch)
320 work_branch.CreateBranch() 308 work_branch.CreateBranch()
321 try: 309 try:
322 MarkChromeEBuildAsStable(stable_candidate, unstable_ebuild, chrome_rev, 310 portage_version_atom = MarkChromeEBuildAsStable(
323 version_to_uprev, commit_to_use, overlay_dir) 311 stable_candidate, unstable_ebuild, chrome_rev, version_to_uprev,
312 commit_to_use, overlay_dir)
313 # Explicit print to communicate to caller.
scottz 2010/11/23 02:44:40 perhaps I do not understand all that is being done
sosa 2010/11/23 21:09:19 Good idea. Even though cbuildbot is the only expe
314 print portage_version_atom
324 except: 315 except:
325 work_branch.Delete() 316 work_branch.Delete()
326 raise 317 raise
327 318
328 319
329 if __name__ == '__main__': 320 if __name__ == '__main__':
330 main(sys.argv) 321 main(sys.argv)
OLDNEW
« bin/cbuildbot.py ('K') | « bin/cbuildbot.py ('k') | cros_mark_as_stable.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698