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

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: Nit 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
« no previous file with comments | « bin/cbuildbot.py ('k') | cros_mark_as_stable.py » ('j') | 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/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
9 After calling, it prints outs CHROME_VERSION_ATOM=(version atom string). A
10 caller could then use this atom with emerge to build the newly uprevved version
11 of Chrome e.g.
12
13 ./cros_mark_chrome_as_stable tot
14 Returns chrome-base/chromeos-chrome-8.0.552.0_alpha_r1
15
16 emerge-x86-generic =chrome-base/chromeos-chrome-8.0.552.0_alpha_r1
17 """
8 18
9 import optparse 19 import optparse
10 import os 20 import os
11 import re 21 import re
12 import sys 22 import sys
13 import urllib 23 import urllib
14 24
15 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 25 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
16 import cros_mark_as_stable 26 import cros_mark_as_stable
17 27
18 sys.path.append(os.path.join(os.path.dirname(__file__), '../lib')) 28 sys.path.append(os.path.join(os.path.dirname(__file__), '../lib'))
19 from cros_build_lib import RunCommand, Info, Warning 29 from cros_build_lib import RunCommand, Info, Warning
20 30
21 BASE_CHROME_SVN_URL = 'http://src.chromium.org/svn' 31 BASE_CHROME_SVN_URL = 'http://src.chromium.org/svn'
22 32
23 # Command for which chrome ebuild to uprev. 33 # Command for which chrome ebuild to uprev.
24 TIP_OF_TRUNK, LATEST_RELEASE, STICKY = 'tot', 'latest_release', 'sticky_release' 34 TIP_OF_TRUNK, LATEST_RELEASE, STICKY = 'tot', 'latest_release', 'sticky_release'
25 CHROME_REV = [TIP_OF_TRUNK, LATEST_RELEASE, STICKY] 35 CHROME_REV = [TIP_OF_TRUNK, LATEST_RELEASE, STICKY]
26 36
27 # Helper regex's for finding ebuilds. 37 # Helper regex's for finding ebuilds.
28 _CHROME_VERSION_REGEX = '\d+\.\d+\.\d+\.\d+' 38 _CHROME_VERSION_REGEX = '\d+\.\d+\.\d+\.\d+'
29 _NON_STICKY_REGEX = '%s[(_rc.*)|(_alpha.*)]+' % _CHROME_VERSION_REGEX 39 _NON_STICKY_REGEX = '%s[(_rc.*)|(_alpha.*)]+' % _CHROME_VERSION_REGEX
30 40
31 # Dir where all the action happens. 41 # Dir where all the action happens.
32 _CHROME_OVERLAY_DIR = ('%(srcroot)s/third_party/chromiumos-overlay' 42 _CHROME_OVERLAY_DIR = ('%(srcroot)s/third_party/chromiumos-overlay'
33 '/chromeos-base/chromeos-chrome') 43 '/chromeos-base/chromeos-chrome')
34 44
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 ' 45 _GIT_COMMIT_MESSAGE = ('Marking %(chrome_rev)s for chrome ebuild with version '
39 '%(chrome_version)s as stable.') 46 '%(chrome_version)s as stable.')
40 47
41 48
42 def _GetSvnUrl(): 49 def _GetSvnUrl():
43 """Returns the path to the svn url for the given chrome branch.""" 50 """Returns the path to the svn url for the given chrome branch."""
44 return os.path.join(BASE_CHROME_SVN_URL, 'trunk') 51 return os.path.join(BASE_CHROME_SVN_URL, 'trunk')
45 52
46 53
47 def _GetTipOfTrunkSvnRevision(): 54 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. 235 unstable_ebuild: ebuild corresponding to the unstable ebuild for chrome.
229 chrome_rev: one of CHROME_REV 236 chrome_rev: one of CHROME_REV
230 TIP_OF_TRUNK - Requires commit value. Revs the ebuild for the TOT 237 TIP_OF_TRUNK - Requires commit value. Revs the ebuild for the TOT
231 version and uses the portage suffix of _alpha. 238 version and uses the portage suffix of _alpha.
232 LATEST_RELEASE - This uses the portage suffix of _rc as they are release 239 LATEST_RELEASE - This uses the portage suffix of _rc as they are release
233 candidates for the next sticky version. 240 candidates for the next sticky version.
234 STICKY - Revs the sticky version. 241 STICKY - Revs the sticky version.
235 chrome_version: The \d.\d.\d.\d version of Chrome. 242 chrome_version: The \d.\d.\d.\d version of Chrome.
236 commit: Used with TIP_OF_TRUNK. The svn revision of chrome. 243 commit: Used with TIP_OF_TRUNK. The svn revision of chrome.
237 overlay_dir: Path to the chromeos-chrome package dir. 244 overlay_dir: Path to the chromeos-chrome package dir.
245 Returns:
246 Full portage version atom (including rc's, etc) that was revved.
238 """ 247 """
239 base_path = os.path.join(overlay_dir, 'chromeos-chrome-%s' % chrome_version) 248 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. 249 # Case where we have the last stable candidate with same version just rev.
241 if stable_candidate and stable_candidate.chrome_version == chrome_version: 250 if stable_candidate and stable_candidate.chrome_version == chrome_version:
242 new_ebuild_path = '%s-r%d.ebuild' % ( 251 new_ebuild_path = '%s-r%d.ebuild' % (
243 stable_candidate.ebuild_path_no_revision, 252 stable_candidate.ebuild_path_no_revision,
244 stable_candidate.current_revision + 1) 253 stable_candidate.current_revision + 1)
245 else: 254 else:
246 if chrome_rev == TIP_OF_TRUNK: 255 if chrome_rev == TIP_OF_TRUNK:
247 portage_suffix = '_alpha' 256 portage_suffix = '_alpha'
248 else: 257 else:
249 portage_suffix = '_rc' 258 portage_suffix = '_rc'
250 259
251 new_ebuild_path = base_path + ('%s-r1.ebuild' % portage_suffix) 260 new_ebuild_path = base_path + ('%s-r1.ebuild' % portage_suffix)
252 261
253 cros_mark_as_stable.EBuildStableMarker.MarkAsStable( 262 cros_mark_as_stable.EBuildStableMarker.MarkAsStable(
254 unstable_ebuild.ebuild_path, new_ebuild_path, 'CROS_SVN_COMMIT', commit) 263 unstable_ebuild.ebuild_path, new_ebuild_path, 'CROS_SVN_COMMIT', commit)
255 RunCommand(['git', 'add', new_ebuild_path]) 264 RunCommand(['git', 'add', new_ebuild_path])
256 if stable_candidate: 265 if stable_candidate:
257 RunCommand(['git', 'rm', stable_candidate.ebuild_path]) 266 RunCommand(['git', 'rm', stable_candidate.ebuild_path])
258 267
259 cros_mark_as_stable.EBuildStableMarker.CommitChange( 268 cros_mark_as_stable.EBuildStableMarker.CommitChange(
260 _GIT_COMMIT_MESSAGE % {'chrome_rev': chrome_rev, 269 _GIT_COMMIT_MESSAGE % {'chrome_rev': chrome_rev,
261 'chrome_version': chrome_version}) 270 'chrome_version': chrome_version})
262 271
272 new_ebuild = ChromeEBuild(new_ebuild_path)
273 return '%s-%s' % (new_ebuild.package, new_ebuild.version)
263 274
264 def main(argv): 275
265 usage = '%s OPTIONS commit|clean|push' 276 def main():
277 usage = '%s OPTIONS [%s]' % (__file__, '|'.join(CHROME_REV))
266 parser = optparse.OptionParser(usage) 278 parser = optparse.OptionParser(usage)
267 parser.add_option('-c', '--chrome_rev', default=None, 279 parser.add_option('-s', '--srcroot', default=os.path.join(os.environ['HOME'],
268 help='One of %s' % CHROME_REV) 280 'trunk', 'src'),
269 parser.add_option('-s', '--srcroot', default='.',
270 help='Path to the src directory') 281 help='Path to the src directory')
271 parser.add_option('-t', '--tracking_branch', default='cros/master', 282 parser.add_option('-t', '--tracking_branch', default='cros/master',
272 help='Branch we are tracking changes against') 283 help='Branch we are tracking changes against')
273 (options, argv) = parser.parse_args(argv) 284 (options, args) = parser.parse_args()
274 285
275 if len(argv) != 2 or argv[1] not in ( 286 if len(args) != 1 or args[0] not in CHROME_REV:
276 cros_mark_as_stable.COMMAND_DICTIONARY.keys()): 287 parser.error('Commit requires arg set to one of %s.' % CHROME_REV)
277 parser.error('Arguments are invalid, see usage.')
278 288
279 command = argv[1]
280 overlay_dir = os.path.abspath(_CHROME_OVERLAY_DIR % 289 overlay_dir = os.path.abspath(_CHROME_OVERLAY_DIR %
281 {'srcroot': options.srcroot}) 290 {'srcroot': options.srcroot})
282 291 chrome_rev = args[0]
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 292 version_to_uprev = None
296 commit_to_use = None 293 commit_to_use = None
297 294
298 (unstable_ebuild, stable_ebuilds) = FindChromeCandidates(overlay_dir) 295 (unstable_ebuild, stable_ebuilds) = FindChromeCandidates(overlay_dir)
299 sticky_version = _GetStickyVersion(stable_ebuilds) 296 sticky_version = _GetStickyVersion(stable_ebuilds)
300 sticky_branch = sticky_version.rpartition('.')[0] 297 sticky_branch = sticky_version.rpartition('.')[0]
301 298
299
302 if chrome_rev == TIP_OF_TRUNK: 300 if chrome_rev == TIP_OF_TRUNK:
303 version_to_uprev = _GetTipOfTrunkVersion() 301 version_to_uprev = _GetTipOfTrunkVersion()
304 commit_to_use = _GetTipOfTrunkSvnRevision() 302 commit_to_use = _GetTipOfTrunkSvnRevision()
305 elif chrome_rev == LATEST_RELEASE: 303 elif chrome_rev == LATEST_RELEASE:
306 version_to_uprev = _GetLatestRelease() 304 version_to_uprev = _GetLatestRelease()
307 else: 305 else:
308 version_to_uprev = _GetLatestRelease(sticky_branch) 306 version_to_uprev = _GetLatestRelease(sticky_branch)
309 307
310 stable_candidate = FindChromeUprevCandidate(stable_ebuilds, chrome_rev, 308 stable_candidate = FindChromeUprevCandidate(stable_ebuilds, chrome_rev,
311 sticky_branch) 309 sticky_branch)
312 # There are some cases we don't need to do anything. Check for them. 310 # 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 311 if stable_candidate and (version_to_uprev == stable_candidate.chrome_version
314 and not commit_to_use): 312 and not commit_to_use):
315 Info('Found nothing to do for chrome_rev %s with version %s.' % ( 313 Info('Found nothing to do for chrome_rev %s with version %s.' % (
316 chrome_rev, version_to_uprev)) 314 chrome_rev, version_to_uprev))
317 else: 315 else:
316 os.chdir(overlay_dir)
318 work_branch = cros_mark_as_stable.GitBranch( 317 work_branch = cros_mark_as_stable.GitBranch(
319 _STABLE_BRANCH_NAME, options.tracking_branch) 318 cros_mark_as_stable.STABLE_BRANCH_NAME, options.tracking_branch)
320 work_branch.CreateBranch() 319 work_branch.CreateBranch()
321 try: 320 try:
322 MarkChromeEBuildAsStable(stable_candidate, unstable_ebuild, chrome_rev, 321 chrome_version_atom = MarkChromeEBuildAsStable(
323 version_to_uprev, commit_to_use, overlay_dir) 322 stable_candidate, unstable_ebuild, chrome_rev, version_to_uprev,
323 commit_to_use, overlay_dir)
324 # Explicit print to communicate to caller.
325 print 'CHROME_VERSION_ATOM=%s' % chrome_version_atom
324 except: 326 except:
325 work_branch.Delete() 327 work_branch.Delete()
326 raise 328 raise
327 329
328 330
329 if __name__ == '__main__': 331 if __name__ == '__main__':
330 main(sys.argv) 332 main()
OLDNEW
« no previous file with comments | « bin/cbuildbot.py ('k') | cros_mark_as_stable.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698