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

Side by Side Diff: bin/cros_mark_chrome_as_stable.py

Issue 5783001: Add support to pushing unstable changes for the chrome pfq. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Fix unittests Created 10 years 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') | bin/cros_mark_chrome_as_stable_unittest.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/python 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 After calling, it prints outs CHROME_VERSION_ATOM=(version atom string). A 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 10 caller could then use this atom with emerge to build the newly uprevved version
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 chrome_version_re = re.compile('^%s\.\d+.*' % branch) 102 chrome_version_re = re.compile('^%s\.\d+.*' % branch)
103 else: 103 else:
104 chrome_version_re = re.compile('^[0-9]\..*') 104 chrome_version_re = re.compile('^[0-9]\..*')
105 for chrome_version in sorted_ls.splitlines(): 105 for chrome_version in sorted_ls.splitlines():
106 if chrome_version_re.match(chrome_version): 106 if chrome_version_re.match(chrome_version):
107 current_version = chrome_version 107 current_version = chrome_version
108 108
109 return current_version.rstrip('/') 109 return current_version.rstrip('/')
110 110
111 111
112 def _GetStickyVersion(stable_ebuilds): 112 def _GetStickyEBuild(stable_ebuilds):
113 """Discovers the sticky version from the current stable_ebuilds.""" 113 """Returns the sticky ebuild."""
114 sticky_ebuilds = [] 114 sticky_ebuilds = []
115 non_sticky_re = re.compile(_NON_STICKY_REGEX) 115 non_sticky_re = re.compile(_NON_STICKY_REGEX)
116 for ebuild in stable_ebuilds: 116 for ebuild in stable_ebuilds:
117 if not non_sticky_re.match(ebuild.version): 117 if not non_sticky_re.match(ebuild.version):
118 sticky_ebuilds.append(ebuild) 118 sticky_ebuilds.append(ebuild)
119 119
120 if not sticky_ebuilds: 120 if not sticky_ebuilds:
121 raise Exception('No sticky ebuilds found') 121 raise Exception('No sticky ebuilds found')
122 elif len(sticky_ebuilds) > 1: 122 elif len(sticky_ebuilds) > 1:
123 Warning('More than one sticky ebuild found') 123 Warning('More than one sticky ebuild found')
124 124
125 return cros_mark_as_stable.BestEBuild(sticky_ebuilds).chrome_version 125 return cros_mark_as_stable.BestEBuild(sticky_ebuilds)
126 126
127 127
128 class ChromeEBuild(cros_mark_as_stable.EBuild): 128 class ChromeEBuild(cros_mark_as_stable.EBuild):
129 """Thin sub-class of EBuild that adds a chrome_version field.""" 129 """Thin sub-class of EBuild that adds a chrome_version field."""
130 chrome_version_re = re.compile('.*chromeos-chrome-(%s|9999).*' % ( 130 chrome_version_re = re.compile('.*chromeos-chrome-(%s|9999).*' % (
131 _CHROME_VERSION_REGEX)) 131 _CHROME_VERSION_REGEX))
132 chrome_version = '' 132 chrome_version = ''
133 133
134 def __init__(self, path): 134 def __init__(self, path):
135 cros_mark_as_stable.EBuild.__init__(self, path) 135 cros_mark_as_stable.EBuild.__init__(self, path)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 Returns the EBuild, otherwise None if none found. 196 Returns the EBuild, otherwise None if none found.
197 """ 197 """
198 candidates = [] 198 candidates = []
199 if chrome_rev == TIP_OF_TRUNK: 199 if chrome_rev == TIP_OF_TRUNK:
200 chrome_branch_re = re.compile('%s.*_alpha.*' % _CHROME_VERSION_REGEX) 200 chrome_branch_re = re.compile('%s.*_alpha.*' % _CHROME_VERSION_REGEX)
201 for ebuild in stable_ebuilds: 201 for ebuild in stable_ebuilds:
202 if chrome_branch_re.search(ebuild.version): 202 if chrome_branch_re.search(ebuild.version):
203 candidates.append(ebuild) 203 candidates.append(ebuild)
204 204
205 elif chrome_rev == STICKY: 205 elif chrome_rev == STICKY:
206 chrome_branch_re = re.compile('%s\.\d+.*_rc.*' % sticky_branch) 206 chrome_branch_re = re.compile('%s\..*' % sticky_branch)
207 for ebuild in stable_ebuilds: 207 for ebuild in stable_ebuilds:
208 if chrome_branch_re.search(ebuild.version): 208 if chrome_branch_re.search(ebuild.version):
209 candidates.append(ebuild) 209 candidates.append(ebuild)
210 210
211 else: 211 else:
212 chrome_branch_re = re.compile('%s.*_rc.*' % _CHROME_VERSION_REGEX) 212 chrome_branch_re = re.compile('%s.*_rc.*' % _CHROME_VERSION_REGEX)
213 for ebuild in stable_ebuilds: 213 for ebuild in stable_ebuilds:
214 if chrome_branch_re.search(ebuild.version) and ( 214 if chrome_branch_re.search(ebuild.version) and (
215 not ebuild.chrome_version.startswith(sticky_branch)): 215 not ebuild.chrome_version.startswith(sticky_branch)):
216 candidates.append(ebuild) 216 candidates.append(ebuild)
217 217
218 if candidates: 218 if candidates:
219 return cros_mark_as_stable.BestEBuild(candidates) 219 return cros_mark_as_stable.BestEBuild(candidates)
220 else: 220 else:
221 return None 221 return None
222 222
223 223
224 def MarkChromeEBuildAsStable(stable_candidate, unstable_ebuild, chrome_rev, 224 def MarkChromeEBuildAsStable(stable_candidate, unstable_ebuild, chrome_rev,
225 chrome_version, commit, overlay_dir): 225 chrome_version, commit, overlay_dir,
226 sticky_ebuild):
226 """Uprevs the chrome ebuild specified by chrome_rev. 227 """Uprevs the chrome ebuild specified by chrome_rev.
227 228
228 This is the main function that uprevs the chrome_rev from a stable candidate 229 This is the main function that uprevs the chrome_rev from a stable candidate
229 to its new version. 230 to its new version.
230 231
231 Args: 232 Args:
232 stable_candidate: ebuild that corresponds to the stable ebuild we are 233 stable_candidate: ebuild that corresponds to the stable ebuild we are
233 revving from. If None, builds the a new ebuild given the version 234 revving from. If None, builds the a new ebuild given the version
234 and logic for chrome_rev type with revision set to 1. 235 and logic for chrome_rev type with revision set to 1.
235 unstable_ebuild: ebuild corresponding to the unstable ebuild for chrome. 236 unstable_ebuild: ebuild corresponding to the unstable ebuild for chrome.
236 chrome_rev: one of CHROME_REV 237 chrome_rev: one of CHROME_REV
237 TIP_OF_TRUNK - Requires commit value. Revs the ebuild for the TOT 238 TIP_OF_TRUNK - Requires commit value. Revs the ebuild for the TOT
238 version and uses the portage suffix of _alpha. 239 version and uses the portage suffix of _alpha.
239 LATEST_RELEASE - This uses the portage suffix of _rc as they are release 240 LATEST_RELEASE - This uses the portage suffix of _rc as they are release
240 candidates for the next sticky version. 241 candidates for the next sticky version.
241 STICKY - Revs the sticky version. 242 STICKY - Revs the sticky version.
242 chrome_version: The \d.\d.\d.\d version of Chrome. 243 chrome_version: The \d.\d.\d.\d version of Chrome.
243 commit: Used with TIP_OF_TRUNK. The svn revision of chrome. 244 commit: Used with TIP_OF_TRUNK. The svn revision of chrome.
244 overlay_dir: Path to the chromeos-chrome package dir. 245 overlay_dir: Path to the chromeos-chrome package dir.
246 sticky_ebuild: EBuild class for the sticky ebuild.
245 Returns: 247 Returns:
246 Full portage version atom (including rc's, etc) that was revved. 248 Full portage version atom (including rc's, etc) that was revved.
247 """ 249 """
248 base_path = os.path.join(overlay_dir, 'chromeos-chrome-%s' % chrome_version) 250 base_path = os.path.join(overlay_dir, 'chromeos-chrome-%s' % chrome_version)
249 # Case where we have the last stable candidate with same version just rev. 251 # Case where we have the last stable candidate with same version just rev.
250 if stable_candidate and stable_candidate.chrome_version == chrome_version: 252 if stable_candidate and stable_candidate.chrome_version == chrome_version:
251 new_ebuild_path = '%s-r%d.ebuild' % ( 253 new_ebuild_path = '%s-r%d.ebuild' % (
252 stable_candidate.ebuild_path_no_revision, 254 stable_candidate.ebuild_path_no_revision,
253 stable_candidate.current_revision + 1) 255 stable_candidate.current_revision + 1)
254 else: 256 else:
255 if chrome_rev == TIP_OF_TRUNK: 257 if chrome_rev == TIP_OF_TRUNK:
256 portage_suffix = '_alpha' 258 portage_suffix = '_alpha'
257 else: 259 else:
258 portage_suffix = '_rc' 260 portage_suffix = '_rc'
259 261
260 new_ebuild_path = base_path + ('%s-r1.ebuild' % portage_suffix) 262 new_ebuild_path = base_path + ('%s-r1.ebuild' % portage_suffix)
261 263
262 cros_mark_as_stable.EBuildStableMarker.MarkAsStable( 264 cros_mark_as_stable.EBuildStableMarker.MarkAsStable(
263 unstable_ebuild.ebuild_path, new_ebuild_path, 'CROS_SVN_COMMIT', commit) 265 unstable_ebuild.ebuild_path, new_ebuild_path, 'CROS_SVN_COMMIT', commit,
266 make_stable=False)
Chris Masone 2010/12/10 16:31:24 Is this last arg temporary? If so, a comment to t
267 new_ebuild = ChromeEBuild(new_ebuild_path)
268 if stable_candidate and (
269 stable_candidate.chrome_version == new_ebuild.chrome_version):
270 if 0 == RunCommand(['diff', '-Bu', stable_candidate.ebuild_path,
271 new_ebuild_path], redirect_stderr=True,
272 redirect_stdout=True,
scottz 2010/12/11 00:05:36 redirect_ should be aligned with exit_code.
273 exit_code=True):
274 os.unlink(new_ebuild_path)
275 return None
276
264 RunCommand(['git', 'add', new_ebuild_path]) 277 RunCommand(['git', 'add', new_ebuild_path])
265 if stable_candidate: 278 if stable_candidate and stable_candidate != sticky_ebuild:
266 RunCommand(['git', 'rm', stable_candidate.ebuild_path]) 279 RunCommand(['git', 'rm', stable_candidate.ebuild_path])
267 280
268 cros_mark_as_stable.EBuildStableMarker.CommitChange( 281 cros_mark_as_stable.EBuildStableMarker.CommitChange(
269 _GIT_COMMIT_MESSAGE % {'chrome_rev': chrome_rev, 282 _GIT_COMMIT_MESSAGE % {'chrome_rev': chrome_rev,
270 'chrome_version': chrome_version}) 283 'chrome_version': chrome_version})
271 284
272 new_ebuild = ChromeEBuild(new_ebuild_path) 285 new_ebuild = ChromeEBuild(new_ebuild_path)
273 return '%s-%s' % (new_ebuild.package, new_ebuild.version) 286 return '%s-%s' % (new_ebuild.package, new_ebuild.version)
274 287
275 288
(...skipping 10 matching lines...) Expand all
286 if len(args) != 1 or args[0] not in CHROME_REV: 299 if len(args) != 1 or args[0] not in CHROME_REV:
287 parser.error('Commit requires arg set to one of %s.' % CHROME_REV) 300 parser.error('Commit requires arg set to one of %s.' % CHROME_REV)
288 301
289 overlay_dir = os.path.abspath(_CHROME_OVERLAY_DIR % 302 overlay_dir = os.path.abspath(_CHROME_OVERLAY_DIR %
290 {'srcroot': options.srcroot}) 303 {'srcroot': options.srcroot})
291 chrome_rev = args[0] 304 chrome_rev = args[0]
292 version_to_uprev = None 305 version_to_uprev = None
293 commit_to_use = None 306 commit_to_use = None
294 307
295 (unstable_ebuild, stable_ebuilds) = FindChromeCandidates(overlay_dir) 308 (unstable_ebuild, stable_ebuilds) = FindChromeCandidates(overlay_dir)
296 sticky_version = _GetStickyVersion(stable_ebuilds) 309 sticky_ebuild = _GetStickyEBuild(stable_ebuilds)
310 sticky_version = sticky_ebuild.chrome_version
297 sticky_branch = sticky_version.rpartition('.')[0] 311 sticky_branch = sticky_version.rpartition('.')[0]
298 312
299
300 if chrome_rev == TIP_OF_TRUNK: 313 if chrome_rev == TIP_OF_TRUNK:
301 version_to_uprev = _GetTipOfTrunkVersion() 314 version_to_uprev = _GetTipOfTrunkVersion()
302 commit_to_use = _GetTipOfTrunkSvnRevision() 315 commit_to_use = _GetTipOfTrunkSvnRevision()
303 elif chrome_rev == LATEST_RELEASE: 316 elif chrome_rev == LATEST_RELEASE:
304 version_to_uprev = _GetLatestRelease() 317 version_to_uprev = _GetLatestRelease()
305 else: 318 else:
306 version_to_uprev = _GetLatestRelease(sticky_branch) 319 version_to_uprev = _GetLatestRelease(sticky_branch)
307 320
308 stable_candidate = FindChromeUprevCandidate(stable_ebuilds, chrome_rev, 321 stable_candidate = FindChromeUprevCandidate(stable_ebuilds, chrome_rev,
309 sticky_branch) 322 sticky_branch)
310 # There are some cases we don't need to do anything. Check for them. 323
311 if stable_candidate and (version_to_uprev == stable_candidate.chrome_version 324 os.chdir(overlay_dir)
312 and not commit_to_use): 325 work_branch = cros_mark_as_stable.GitBranch(
313 Info('Found nothing to do for chrome_rev %s with version %s.' % ( 326 cros_mark_as_stable.STABLE_BRANCH_NAME, options.tracking_branch)
314 chrome_rev, version_to_uprev)) 327 work_branch.CreateBranch()
315 else: 328 try:
316 os.chdir(overlay_dir) 329 chrome_version_atom = MarkChromeEBuildAsStable(
317 work_branch = cros_mark_as_stable.GitBranch( 330 stable_candidate, unstable_ebuild, chrome_rev, version_to_uprev,
318 cros_mark_as_stable.STABLE_BRANCH_NAME, options.tracking_branch) 331 commit_to_use, overlay_dir, sticky_ebuild)
319 work_branch.CreateBranch() 332 # Explicit print to communicate to caller.
320 try: 333 if chrome_version_atom:
321 chrome_version_atom = MarkChromeEBuildAsStable(
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 334 print 'CHROME_VERSION_ATOM=%s' % chrome_version_atom
326 except: 335 else:
327 work_branch.Delete() 336 work_branch.Delete()
328 raise 337 except:
338 work_branch.Delete()
339 raise
329 340
330 341
331 if __name__ == '__main__': 342 if __name__ == '__main__':
332 main() 343 main()
OLDNEW
« no previous file with comments | « bin/cbuildbot.py ('k') | bin/cros_mark_chrome_as_stable_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698