Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 a given package's ebuild to the next revision.""" | 7 """This module uprevs a given package's ebuild to the next revision.""" |
| 8 | 8 |
| 9 | 9 |
| 10 import fileinput | 10 import fileinput |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 """Optional list of commit ids for each package. | 26 """Optional list of commit ids for each package. |
| 27 This list must either be empty or have the same length as | 27 This list must either be empty or have the same length as |
| 28 the packages list. If not set all rev'd ebuilds will have | 28 the packages list. If not set all rev'd ebuilds will have |
| 29 empty commit id's.""", | 29 empty commit id's.""", |
| 30 short_name='i') | 30 short_name='i') |
| 31 gflags.DEFINE_string('packages', '', | 31 gflags.DEFINE_string('packages', '', |
| 32 'Space separated list of packages to mark as stable.', | 32 'Space separated list of packages to mark as stable.', |
| 33 short_name='p') | 33 short_name='p') |
| 34 gflags.DEFINE_string('push_options', '', | 34 gflags.DEFINE_string('push_options', '', |
| 35 'Options to use with git-cl push using push command.') | 35 'Options to use with git-cl push using push command.') |
| 36 gflags.DEFINE_string('srcroot', '%s/trunk/src' % os.environ['HOME'], | |
| 37 'Used with commit to specify branch to track against.', | |
|
petkov
2010/08/02 18:35:23
Update option description.
| |
| 38 short_name='r') | |
| 36 gflags.DEFINE_string('tracking_branch', 'origin', | 39 gflags.DEFINE_string('tracking_branch', 'origin', |
| 37 'Used with commit to specify branch to track against.', | 40 'Used with commit to specify branch to track against.', |
| 38 short_name='t') | 41 short_name='t') |
| 39 gflags.DEFINE_boolean('verbose', False, | 42 gflags.DEFINE_boolean('verbose', False, |
| 40 'Prints out verbose information about what is going on.', | 43 'Prints out verbose information about what is going on.', |
| 41 short_name='v') | 44 short_name='v') |
| 42 | 45 |
| 43 | 46 |
| 44 # TODO(sosa): Remove hard-coding of overlays directory once there is a better | |
| 45 # way. | |
| 46 _CHROMIUMOS_OVERLAYS_DIRECTORY = \ | |
| 47 '%s/trunk/src/third_party/chromiumos-overlay' % os.environ['HOME'] | |
| 48 | |
| 49 # Takes two strings, package_name and commit_id. | 47 # Takes two strings, package_name and commit_id. |
| 50 _GIT_COMMIT_MESSAGE = \ | 48 _GIT_COMMIT_MESSAGE = \ |
| 51 'Marking 9999 ebuild for %s with commit %s as stable.' | 49 'Marking 9999 ebuild for %s with commit %s as stable.' |
| 52 | 50 |
| 53 # Dictionary of valid commands with usage information. | 51 # Dictionary of valid commands with usage information. |
| 54 _COMMAND_DICTIONARY = { | 52 _COMMAND_DICTIONARY = { |
| 55 'clean': | 53 'clean': |
| 56 'Cleans up previous calls to either commit or push', | 54 'Cleans up previous calls to either commit or push', |
| 57 'commit': | 55 'commit': |
| 58 'Marks given ebuilds as stable locally', | 56 'Marks given ebuilds as stable locally', |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 77 return current_branch == _STABLE_BRANCH_NAME | 75 return current_branch == _STABLE_BRANCH_NAME |
| 78 | 76 |
| 79 def _CheckSaneArguments(package_list, commit_id_list, command): | 77 def _CheckSaneArguments(package_list, commit_id_list, command): |
| 80 """Checks to make sure the flags are sane. Dies if arguments are not sane.""" | 78 """Checks to make sure the flags are sane. Dies if arguments are not sane.""" |
| 81 if not command in _COMMAND_DICTIONARY.keys(): | 79 if not command in _COMMAND_DICTIONARY.keys(): |
| 82 _PrintUsageAndDie('%s is not a valid command' % command) | 80 _PrintUsageAndDie('%s is not a valid command' % command) |
| 83 if not gflags.FLAGS.packages and command == 'commit': | 81 if not gflags.FLAGS.packages and command == 'commit': |
| 84 _PrintUsageAndDie('Please specify at least one package') | 82 _PrintUsageAndDie('Please specify at least one package') |
| 85 if not gflags.FLAGS.board and command == 'commit': | 83 if not gflags.FLAGS.board and command == 'commit': |
| 86 _PrintUsageAndDie('Please specify a board') | 84 _PrintUsageAndDie('Please specify a board') |
| 85 if not os.path.isdir(gflags.FLAGS.srcroot): | |
| 86 _PrintUsageAndDie('srcroot is not a valid path') | |
| 87 if commit_id_list and (len(package_list) != len(commit_id_list)): | 87 if commit_id_list and (len(package_list) != len(commit_id_list)): |
| 88 _PrintUsageAndDie( | 88 _PrintUsageAndDie( |
| 89 'Package list is not the same length as the commit id list') | 89 'Package list is not the same length as the commit id list') |
| 90 | 90 |
| 91 | 91 |
| 92 def _Clean(): | 92 def _Clean(): |
| 93 """Cleans up uncommitted changes on either stabilizing branch or master.""" | 93 """Cleans up uncommitted changes on either stabilizing branch or master.""" |
| 94 if _CheckOnStabilizingBranch(): | 94 if _CheckOnStabilizingBranch(): |
| 95 _RunCommand('git reset HEAD --hard') | 95 _RunCommand('git reset HEAD --hard') |
| 96 _RunCommand('git checkout master') | 96 _RunCommand('git checkout master') |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 122 Raises: | 122 Raises: |
| 123 OSError: Error occurred while pushing. | 123 OSError: Error occurred while pushing. |
| 124 """ | 124 """ |
| 125 | 125 |
| 126 # TODO(sosa) - Add logic for buildbot to check whether other slaves have | 126 # TODO(sosa) - Add logic for buildbot to check whether other slaves have |
| 127 # completed and push this change only if they have. | 127 # completed and push this change only if they have. |
| 128 | 128 |
| 129 # Sanity check to make sure we're on a stabilizing branch before pushing. | 129 # Sanity check to make sure we're on a stabilizing branch before pushing. |
| 130 if not _CheckOnStabilizingBranch(): | 130 if not _CheckOnStabilizingBranch(): |
| 131 generate_test_report.Die('Expected %s to be on branch "%s"' % | 131 generate_test_report.Die('Expected %s to be on branch "%s"' % |
| 132 (_CHROMIUMOS_OVERLAYS_DIRECTORY, | 132 (os.getcwd(), _STABLE_BRANCH_NAME)) |
| 133 _STABLE_BRANCH_NAME)) | |
| 134 _RunCommand('git cl upload --desc_from_logs -m "%s"' % | 133 _RunCommand('git cl upload --desc_from_logs -m "%s"' % |
| 135 'Marking set of ebuilds as stable') | 134 'Marking set of ebuilds as stable') |
| 136 _RunCommand('git remote update') | 135 _RunCommand('git remote update') |
| 137 _RunCommand('git rebase origin/master') | 136 _RunCommand('git rebase origin/master') |
| 138 _RunCommand('git cl push %s' % gflags.FLAGS.push_options) | 137 _RunCommand('git cl push %s' % gflags.FLAGS.push_options) |
| 139 | 138 |
| 140 | 139 |
| 141 def _RunCommand(command): | 140 def _RunCommand(command): |
| 142 """Runs a shell command and returns stdout back to caller.""" | 141 """Runs a shell command and returns stdout back to caller.""" |
| 143 _Print(' + %s' % command) | 142 _Print(' + %s' % command) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 except gflags.FlagsError, e : | 321 except gflags.FlagsError, e : |
| 323 _PrintUsageAndDie(str(e)) | 322 _PrintUsageAndDie(str(e)) |
| 324 | 323 |
| 325 package_list = gflags.FLAGS.packages.split() | 324 package_list = gflags.FLAGS.packages.split() |
| 326 if gflags.FLAGS.commit_ids: | 325 if gflags.FLAGS.commit_ids: |
| 327 commit_id_list = gflags.FLAGS.commit_ids.split() | 326 commit_id_list = gflags.FLAGS.commit_ids.split() |
| 328 else: | 327 else: |
| 329 commit_id_list = None | 328 commit_id_list = None |
| 330 _CheckSaneArguments(package_list, commit_id_list, command) | 329 _CheckSaneArguments(package_list, commit_id_list, command) |
| 331 | 330 |
| 332 os.chdir(_CHROMIUMOS_OVERLAYS_DIRECTORY) | 331 overlay_directory = '%s/third_party/chromiumos-overlay' % gflags.FLAGS.srcroot |
| 332 | |
|
petkov
2010/08/02 18:35:23
no need for blank line, i think
| |
| 333 os.chdir(overlay_directory) | |
| 333 | 334 |
| 334 if command == 'clean': | 335 if command == 'clean': |
| 335 _Clean() | 336 _Clean() |
| 336 elif command == 'commit': | 337 elif command == 'commit': |
| 337 work_branch = _GitBranch(_STABLE_BRANCH_NAME) | 338 work_branch = _GitBranch(_STABLE_BRANCH_NAME) |
| 338 work_branch.CreateBranch() | 339 work_branch.CreateBranch() |
| 339 if not work_branch.Exists(): | 340 if not work_branch.Exists(): |
| 340 generate_test_report.Die('Unable to create stabilizing branch in %s' % | 341 generate_test_report.Die('Unable to create stabilizing branch in %s' % |
| 341 _CHROMIUMOS_OVERLAYS_DIRECTORY) | 342 overlay_directory) |
| 342 index = 0 | 343 index = 0 |
| 343 try: | 344 try: |
| 344 for index in range(len(package_list)): | 345 for index in range(len(package_list)): |
| 345 # Gather the package and optional commit id to work on. | 346 # Gather the package and optional commit id to work on. |
| 346 package = package_list[index] | 347 package = package_list[index] |
| 347 commit_id = "" | 348 commit_id = "" |
| 348 if commit_id_list: | 349 if commit_id_list: |
| 349 commit_id = commit_id_list[index] | 350 commit_id = commit_id_list[index] |
| 350 | 351 |
| 351 _Print('Working on %s' % package) | 352 _Print('Working on %s' % package) |
| 352 worker = EBuildStableMarker(_EBuild(package, commit_id)) | 353 worker = EBuildStableMarker(_EBuild(package, commit_id)) |
| 353 worker.RevEBuild(commit_id) | 354 worker.RevEBuild(commit_id) |
| 354 worker.CommitChange(_GIT_COMMIT_MESSAGE % (package, commit_id)) | 355 worker.CommitChange(_GIT_COMMIT_MESSAGE % (package, commit_id)) |
| 355 | 356 |
| 356 except (OSError, IOError), e: | 357 except (OSError, IOError), e: |
| 357 print ('An exception occurred\n' | 358 print ('An exception occurred\n' |
| 358 'Only the following packages were revved: %s\n' | 359 'Only the following packages were revved: %s\n' |
| 359 'Note you will have to go into %s' | 360 'Note you will have to go into %s' |
| 360 'and reset the git repo yourself.' % | 361 'and reset the git repo yourself.' % |
| 361 (package_list[:index], _CHROMIUMOS_OVERLAYS_DIRECTORY)) | 362 (package_list[:index], overlay_directory)) |
| 362 raise e | 363 raise e |
| 363 elif command == 'push': | 364 elif command == 'push': |
| 364 _PushChange() | 365 _PushChange() |
| 365 | 366 |
| 366 | 367 |
| 367 if __name__ == '__main__': | 368 if __name__ == '__main__': |
| 368 main(sys.argv) | 369 main(sys.argv) |
| 369 | 370 |
| OLD | NEW |