| 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 |
| 11 import gflags | 11 import gflags |
| 12 import os | 12 import os |
| 13 import re | 13 import re |
| 14 import shutil | 14 import shutil |
| 15 import subprocess | 15 import subprocess |
| 16 import sys | 16 import sys |
| 17 | 17 |
| 18 # TODO(sosa): Refactor Die into common library. | 18 sys.path.append(os.path.join(os.path.dirname(__file__), 'lib')) |
| 19 sys.path.append(os.path.dirname(__file__)) | 19 from cros_build_lib import Info, Warning, Die |
| 20 import generate_test_report | |
| 21 | 20 |
| 22 | 21 |
| 23 gflags.DEFINE_string('board', 'x86-generic', | 22 gflags.DEFINE_string('board', 'x86-generic', |
| 24 'Board for which the package belongs.', short_name='b') | 23 'Board for which the package belongs.', short_name='b') |
| 25 gflags.DEFINE_string('commit_ids', '', | 24 gflags.DEFINE_string('commit_ids', '', |
| 26 """Optional list of commit ids for each package. | 25 """Optional list of commit ids for each package. |
| 27 This list must either be empty or have the same length as | 26 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 | 27 the packages list. If not set all rev'd ebuilds will have |
| 29 empty commit id's.""", | 28 empty commit id's.""", |
| 30 short_name='i') | 29 short_name='i') |
| 31 gflags.DEFINE_string('packages', '', | 30 gflags.DEFINE_string('packages', '', |
| 32 'Space separated list of packages to mark as stable.', | 31 'Space separated list of packages to mark as stable.', |
| 33 short_name='p') | 32 short_name='p') |
| 34 gflags.DEFINE_string('push_options', '', | 33 gflags.DEFINE_string('push_options', '', |
| 35 'Options to use with git-cl push using push command.') | 34 'Options to use with git-cl push using push command.') |
| 36 gflags.DEFINE_string('srcroot', '%s/trunk/src' % os.environ['HOME'], | 35 gflags.DEFINE_string('srcroot', '%s/trunk/src' % os.environ['HOME'], |
| 37 'Path to root src directory.', | 36 'Path to root src directory.', |
| 38 short_name='r') | 37 short_name='r') |
| 39 gflags.DEFINE_string('tracking_branch', 'cros/master', | 38 gflags.DEFINE_string('tracking_branch', 'cros/master', |
| 40 'Used with commit to specify branch to track against.', | 39 'Used with commit to specify branch to track against.', |
| 41 short_name='t') | 40 short_name='t') |
| 42 gflags.DEFINE_boolean('verbose', False, | 41 gflags.DEFINE_boolean('verbose', False, |
| 43 'Prints out verbose information about what is going on.', | 42 'Prints out verbose information about what is going on.', |
| 44 short_name='v') | 43 short_name='v') |
| 45 | 44 |
| 46 | 45 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 | 59 |
| 61 # Name used for stabilizing branch. | 60 # Name used for stabilizing branch. |
| 62 _STABLE_BRANCH_NAME = 'stabilizing_branch' | 61 _STABLE_BRANCH_NAME = 'stabilizing_branch' |
| 63 | 62 |
| 64 # ======================= Global Helper Functions ======================== | 63 # ======================= Global Helper Functions ======================== |
| 65 | 64 |
| 66 | 65 |
| 67 def _Print(message): | 66 def _Print(message): |
| 68 """Verbose print function.""" | 67 """Verbose print function.""" |
| 69 if gflags.FLAGS.verbose: | 68 if gflags.FLAGS.verbose: |
| 70 print message | 69 Info(message) |
| 71 | 70 |
| 72 def _CheckOnStabilizingBranch(): | 71 def _CheckOnStabilizingBranch(): |
| 73 """Returns true if the git branch is on the stabilizing branch.""" | 72 """Returns true if the git branch is on the stabilizing branch.""" |
| 74 current_branch = _RunCommand('git branch | grep \*').split()[1] | 73 current_branch = _SimpleRunCommand('git branch | grep \*').split()[1] |
| 75 return current_branch == _STABLE_BRANCH_NAME | 74 return current_branch == _STABLE_BRANCH_NAME |
| 76 | 75 |
| 77 def _CheckSaneArguments(package_list, commit_id_list, command): | 76 def _CheckSaneArguments(package_list, commit_id_list, command): |
| 78 """Checks to make sure the flags are sane. Dies if arguments are not sane.""" | 77 """Checks to make sure the flags are sane. Dies if arguments are not sane.""" |
| 79 if not command in _COMMAND_DICTIONARY.keys(): | 78 if not command in _COMMAND_DICTIONARY.keys(): |
| 80 _PrintUsageAndDie('%s is not a valid command' % command) | 79 _PrintUsageAndDie('%s is not a valid command' % command) |
| 81 if not gflags.FLAGS.packages and command == 'commit': | 80 if not gflags.FLAGS.packages and command == 'commit': |
| 82 _PrintUsageAndDie('Please specify at least one package') | 81 _PrintUsageAndDie('Please specify at least one package') |
| 83 if not gflags.FLAGS.board and command == 'commit': | 82 if not gflags.FLAGS.board and command == 'commit': |
| 84 _PrintUsageAndDie('Please specify a board') | 83 _PrintUsageAndDie('Please specify a board') |
| 85 if not os.path.isdir(gflags.FLAGS.srcroot): | 84 if not os.path.isdir(gflags.FLAGS.srcroot): |
| 86 _PrintUsageAndDie('srcroot is not a valid path') | 85 _PrintUsageAndDie('srcroot is not a valid path') |
| 87 if commit_id_list and (len(package_list) != len(commit_id_list)): | 86 if commit_id_list and (len(package_list) != len(commit_id_list)): |
| 88 _PrintUsageAndDie( | 87 _PrintUsageAndDie( |
| 89 'Package list is not the same length as the commit id list') | 88 'Package list is not the same length as the commit id list') |
| 90 | 89 |
| 91 | 90 |
| 92 def _Clean(): | 91 def _Clean(): |
| 93 """Cleans up uncommitted changes on either stabilizing branch or master.""" | 92 """Cleans up uncommitted changes on either stabilizing branch or master.""" |
| 94 _RunCommand('git reset HEAD --hard') | 93 _SimpleRunCommand('git reset HEAD --hard') |
| 95 _RunCommand('git checkout %s' % gflags.FLAGS.tracking_branch) | 94 _SimpleRunCommand('git checkout %s' % gflags.FLAGS.tracking_branch) |
| 96 | 95 |
| 97 | 96 |
| 98 def _PrintUsageAndDie(error_message=''): | 97 def _PrintUsageAndDie(error_message=''): |
| 99 """Prints optional error_message the usage and returns an error exit code.""" | 98 """Prints optional error_message the usage and returns an error exit code.""" |
| 100 command_usage = 'Commands: \n' | 99 command_usage = 'Commands: \n' |
| 101 # Add keys and usage information from dictionary. | 100 # Add keys and usage information from dictionary. |
| 102 commands = sorted(_COMMAND_DICTIONARY.keys()) | 101 commands = sorted(_COMMAND_DICTIONARY.keys()) |
| 103 for command in commands: | 102 for command in commands: |
| 104 command_usage += ' %s: %s\n' % (command, _COMMAND_DICTIONARY[command]) | 103 command_usage += ' %s: %s\n' % (command, _COMMAND_DICTIONARY[command]) |
| 105 commands_str = '|'.join(commands) | 104 commands_str = '|'.join(commands) |
| 106 print 'Usage: %s FLAGS [%s]\n\n%s\nFlags:%s' % (sys.argv[0], commands_str, | 105 Warning('Usage: %s FLAGS [%s]\n\n%s\nFlags:%s' % (sys.argv[0], commands_str, |
| 107 command_usage, gflags.FLAGS) | 106 command_usage, gflags.FLAGS)) |
| 108 if error_message: | 107 if error_message: |
| 109 generate_test_report.Die(error_message) | 108 Die(error_message) |
| 110 else: | 109 else: |
| 111 sys.exit(1) | 110 sys.exit(1) |
| 112 | 111 |
| 113 def _PushChange(): | 112 def _PushChange(): |
| 114 """Pushes changes to the git repository. | 113 """Pushes changes to the git repository. |
| 115 | 114 |
| 116 Pushes locals commits from calls to CommitChange to the remote git | 115 Pushes locals commits from calls to CommitChange to the remote git |
| 117 repository specified by os.pwd. | 116 repository specified by os.pwd. |
| 118 | 117 |
| 119 Raises: | 118 Raises: |
| 120 OSError: Error occurred while pushing. | 119 OSError: Error occurred while pushing. |
| 121 """ | 120 """ |
| 122 | 121 |
| 123 # TODO(sosa) - Add logic for buildbot to check whether other slaves have | 122 # TODO(sosa) - Add logic for buildbot to check whether other slaves have |
| 124 # completed and push this change only if they have. | 123 # completed and push this change only if they have. |
| 125 | 124 |
| 126 # Sanity check to make sure we're on a stabilizing branch before pushing. | 125 # Sanity check to make sure we're on a stabilizing branch before pushing. |
| 127 if not _CheckOnStabilizingBranch(): | 126 if not _CheckOnStabilizingBranch(): |
| 128 print 'Not on branch %s so no work found to push. Exiting' % \ | 127 Info('Not on branch %s so no work found to push. Exiting' % \ |
| 129 _STABLE_BRANCH_NAME | 128 _STABLE_BRANCH_NAME) |
| 130 return | 129 return |
| 131 | 130 |
| 132 description = _RunCommand('git log --format=format:%s%n%n%b ' + | 131 description = _SimpleRunCommand('git log --format=format:%s%n%n%b ' + |
| 133 gflags.FLAGS.tracking_branch + '..') | 132 gflags.FLAGS.tracking_branch + '..') |
| 134 description = 'Marking set of ebuilds as stable\n\n%s' % description | 133 description = 'Marking set of ebuilds as stable\n\n%s' % description |
| 135 merge_branch_name = 'merge_branch' | 134 merge_branch_name = 'merge_branch' |
| 136 _RunCommand('git remote update') | 135 _SimpleRunCommand('git remote update') |
| 137 merge_branch = _GitBranch(merge_branch_name) | 136 merge_branch = _GitBranch(merge_branch_name) |
| 138 merge_branch.CreateBranch() | 137 merge_branch.CreateBranch() |
| 139 if not merge_branch.Exists(): | 138 if not merge_branch.Exists(): |
| 140 generate_test_report.Die('Unable to create merge branch.') | 139 Die('Unable to create merge branch.') |
| 141 _RunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) | 140 _SimpleRunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) |
| 142 _RunCommand('git commit -m "%s"' % description) | 141 _SimpleRunCommand('git commit -m "%s"' % description) |
| 143 # Ugh. There has got to be an easier way to push to a tracking branch | 142 # Ugh. There has got to be an easier way to push to a tracking branch |
| 144 _RunCommand('git config push.default tracking') | 143 _SimpleRunCommand('git config push.default tracking') |
| 145 _RunCommand('git push') | 144 _SimpleRunCommand('git push') |
| 146 | 145 |
| 147 | 146 |
| 148 def _RunCommand(command): | 147 def _SimpleRunCommand(command): |
| 149 """Runs a shell command and returns stdout back to caller.""" | 148 """Runs a shell command and returns stdout back to caller.""" |
| 150 _Print(' + %s' % command) | 149 _Print(' + %s' % command) |
| 151 proc_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) | 150 proc_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) |
| 152 return proc_handle.communicate()[0] | 151 return proc_handle.communicate()[0] |
| 153 | 152 |
| 154 | 153 |
| 155 # ======================= End Global Helper Functions ======================== | 154 # ======================= End Global Helper Functions ======================== |
| 156 | 155 |
| 157 | 156 |
| 158 class _GitBranch(object): | 157 class _GitBranch(object): |
| 159 """Wrapper class for a git branch.""" | 158 """Wrapper class for a git branch.""" |
| 160 | 159 |
| 161 def __init__(self, branch_name): | 160 def __init__(self, branch_name): |
| 162 """Sets up variables but does not create the branch.""" | 161 """Sets up variables but does not create the branch.""" |
| 163 self.branch_name = branch_name | 162 self.branch_name = branch_name |
| 164 | 163 |
| 165 def CreateBranch(self): | 164 def CreateBranch(self): |
| 166 """Creates a new git branch or replaces an existing one.""" | 165 """Creates a new git branch or replaces an existing one.""" |
| 167 if self.Exists(): | 166 if self.Exists(): |
| 168 self.Delete() | 167 self.Delete() |
| 169 self._Checkout(self.branch_name) | 168 self._Checkout(self.branch_name) |
| 170 | 169 |
| 171 def _Checkout(self, target, create=True): | 170 def _Checkout(self, target, create=True): |
| 172 """Function used internally to create and move between branches.""" | 171 """Function used internally to create and move between branches.""" |
| 173 if create: | 172 if create: |
| 174 git_cmd = 'git checkout -b %s %s' % (target, gflags.FLAGS.tracking_branch) | 173 git_cmd = 'git checkout -b %s %s' % (target, gflags.FLAGS.tracking_branch) |
| 175 else: | 174 else: |
| 176 git_cmd = 'git checkout %s' % target | 175 git_cmd = 'git checkout %s' % target |
| 177 _RunCommand(git_cmd) | 176 _SimpleRunCommand(git_cmd) |
| 178 | 177 |
| 179 def Exists(self): | 178 def Exists(self): |
| 180 """Returns True if the branch exists.""" | 179 """Returns True if the branch exists.""" |
| 181 branch_cmd = 'git branch' | 180 branch_cmd = 'git branch' |
| 182 branches = _RunCommand(branch_cmd) | 181 branches = _SimpleRunCommand(branch_cmd) |
| 183 return self.branch_name in branches.split() | 182 return self.branch_name in branches.split() |
| 184 | 183 |
| 185 def Delete(self): | 184 def Delete(self): |
| 186 """Deletes the branch and returns the user to the master branch. | 185 """Deletes the branch and returns the user to the master branch. |
| 187 | 186 |
| 188 Returns True on success. | 187 Returns True on success. |
| 189 """ | 188 """ |
| 190 self._Checkout(gflags.FLAGS.tracking_branch, create=False) | 189 self._Checkout(gflags.FLAGS.tracking_branch, create=False) |
| 191 delete_cmd = 'git branch -D %s' % self.branch_name | 190 delete_cmd = 'git branch -D %s' % self.branch_name |
| 192 _RunCommand(delete_cmd) | 191 _SimpleRunCommand(delete_cmd) |
| 193 | 192 |
| 194 | 193 |
| 195 class _EBuild(object): | 194 class _EBuild(object): |
| 196 """Wrapper class for an ebuild.""" | 195 """Wrapper class for an ebuild.""" |
| 197 | 196 |
| 198 def __init__(self, package, commit_id=None): | 197 def __init__(self, package, commit_id=None): |
| 199 """Initializes all data about an ebuild. | 198 """Initializes all data about an ebuild. |
| 200 | 199 |
| 201 Uses equery to find the ebuild path and sets data about an ebuild for | 200 Uses equery to find the ebuild path and sets data about an ebuild for |
| 202 easy reference. | 201 easy reference. |
| 203 """ | 202 """ |
| 204 self.package = package | 203 self.package = package |
| 205 self.ebuild_path = self._FindEBuildPath(package) | 204 self.ebuild_path = self._FindEBuildPath(package) |
| 206 (self.ebuild_path_no_revision, | 205 (self.ebuild_path_no_revision, |
| 207 self.ebuild_path_no_version, | 206 self.ebuild_path_no_version, |
| 208 self.current_revision) = self._ParseEBuildPath(self.ebuild_path) | 207 self.current_revision) = self._ParseEBuildPath(self.ebuild_path) |
| 209 self.commit_id = commit_id | 208 self.commit_id = commit_id |
| 210 | 209 |
| 211 @classmethod | 210 @classmethod |
| 212 def _FindEBuildPath(cls, package): | 211 def _FindEBuildPath(cls, package): |
| 213 """Static method that returns the full path of an ebuild.""" | 212 """Static method that returns the full path of an ebuild.""" |
| 214 _Print('Looking for unstable ebuild for %s' % package) | 213 _Print('Looking for unstable ebuild for %s' % package) |
| 215 equery_cmd = 'equery-%s which %s 2> /dev/null' \ | 214 equery_cmd = 'equery-%s which %s 2> /dev/null' \ |
| 216 % (gflags.FLAGS.board, package) | 215 % (gflags.FLAGS.board, package) |
| 217 path = _RunCommand(equery_cmd) | 216 path = _SimpleRunCommand(equery_cmd) |
| 218 if path: | 217 if path: |
| 219 _Print('Unstable ebuild found at %s' % path) | 218 _Print('Unstable ebuild found at %s' % path) |
| 220 return path | 219 return path |
| 221 | 220 |
| 222 @classmethod | 221 @classmethod |
| 223 def _ParseEBuildPath(cls, ebuild_path): | 222 def _ParseEBuildPath(cls, ebuild_path): |
| 224 """Static method that parses the path of an ebuild | 223 """Static method that parses the path of an ebuild |
| 225 | 224 |
| 226 Returns a tuple containing the (ebuild path without the revision | 225 Returns a tuple containing the (ebuild path without the revision |
| 227 string, without the version string, and the current revision number for | 226 string, without the version string, and the current revision number for |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 redirect_file: Optional file to write the new ebuild. By default | 262 redirect_file: Optional file to write the new ebuild. By default |
| 264 it is written using the standard rev'ing logic. This file must be | 263 it is written using the standard rev'ing logic. This file must be |
| 265 opened and closed by the caller. | 264 opened and closed by the caller. |
| 266 | 265 |
| 267 Raises: | 266 Raises: |
| 268 OSError: Error occurred while creating a new ebuild. | 267 OSError: Error occurred while creating a new ebuild. |
| 269 IOError: Error occurred while writing to the new revved ebuild file. | 268 IOError: Error occurred while writing to the new revved ebuild file. |
| 270 """ | 269 """ |
| 271 # TODO(sosa): Change to a check. | 270 # TODO(sosa): Change to a check. |
| 272 if not self._ebuild: | 271 if not self._ebuild: |
| 273 generate_test_report.Die('Invalid ebuild given to EBuildStableMarker') | 272 Die('Invalid ebuild given to EBuildStableMarker') |
| 274 | 273 |
| 275 new_ebuild_path = '%s-r%d.ebuild' % (self._ebuild.ebuild_path_no_revision, | 274 new_ebuild_path = '%s-r%d.ebuild' % (self._ebuild.ebuild_path_no_revision, |
| 276 self._ebuild.current_revision + 1) | 275 self._ebuild.current_revision + 1) |
| 277 | 276 |
| 278 _Print('Creating new stable ebuild %s' % new_ebuild_path) | 277 _Print('Creating new stable ebuild %s' % new_ebuild_path) |
| 279 shutil.copyfile('%s-9999.ebuild' % self._ebuild.ebuild_path_no_version, | 278 shutil.copyfile('%s-9999.ebuild' % self._ebuild.ebuild_path_no_version, |
| 280 new_ebuild_path) | 279 new_ebuild_path) |
| 281 | 280 |
| 282 for line in fileinput.input(new_ebuild_path, inplace=1): | 281 for line in fileinput.input(new_ebuild_path, inplace=1): |
| 283 # Has to be done here to get changes to sys.stdout from fileinput.input. | 282 # Has to be done here to get changes to sys.stdout from fileinput.input. |
| 284 if not redirect_file: | 283 if not redirect_file: |
| 285 redirect_file = sys.stdout | 284 redirect_file = sys.stdout |
| 286 if line.startswith('KEYWORDS'): | 285 if line.startswith('KEYWORDS'): |
| 287 # Actually mark this file as stable by removing ~'s. | 286 # Actually mark this file as stable by removing ~'s. |
| 288 redirect_file.write(line.replace("~", "")) | 287 redirect_file.write(line.replace("~", "")) |
| 289 elif line.startswith('EAPI'): | 288 elif line.startswith('EAPI'): |
| 290 # Always add new commit_id after EAPI definition. | 289 # Always add new commit_id after EAPI definition. |
| 291 redirect_file.write(line) | 290 redirect_file.write(line) |
| 292 redirect_file.write('CROS_WORKON_COMMIT="%s"\n' % commit_id) | 291 redirect_file.write('CROS_WORKON_COMMIT="%s"\n' % commit_id) |
| 293 elif not line.startswith('CROS_WORKON_COMMIT'): | 292 elif not line.startswith('CROS_WORKON_COMMIT'): |
| 294 # Skip old CROS_WORKON_COMMIT definition. | 293 # Skip old CROS_WORKON_COMMIT definition. |
| 295 redirect_file.write(line) | 294 redirect_file.write(line) |
| 296 fileinput.close() | 295 fileinput.close() |
| 297 | 296 |
| 298 _Print('Adding new stable ebuild to git') | 297 _Print('Adding new stable ebuild to git') |
| 299 _RunCommand('git add %s' % new_ebuild_path) | 298 _SimpleRunCommand('git add %s' % new_ebuild_path) |
| 300 | 299 |
| 301 _Print('Removing old ebuild from git') | 300 _Print('Removing old ebuild from git') |
| 302 _RunCommand('git rm %s' % self._ebuild.ebuild_path) | 301 _SimpleRunCommand('git rm %s' % self._ebuild.ebuild_path) |
| 303 | 302 |
| 304 def CommitChange(self, message): | 303 def CommitChange(self, message): |
| 305 """Commits current changes in git locally. | 304 """Commits current changes in git locally. |
| 306 | 305 |
| 307 This method will take any changes from invocations to RevEBuild | 306 This method will take any changes from invocations to RevEBuild |
| 308 and commits them locally in the git repository that contains os.pwd. | 307 and commits them locally in the git repository that contains os.pwd. |
| 309 | 308 |
| 310 Args: | 309 Args: |
| 311 message: the commit string to write when committing to git. | 310 message: the commit string to write when committing to git. |
| 312 | 311 |
| 313 Raises: | 312 Raises: |
| 314 OSError: Error occurred while committing. | 313 OSError: Error occurred while committing. |
| 315 """ | 314 """ |
| 316 _Print('Committing changes for %s with commit message %s' % \ | 315 _Print('Committing changes for %s with commit message %s' % \ |
| 317 (self._ebuild.package, message)) | 316 (self._ebuild.package, message)) |
| 318 git_commit_cmd = 'git commit -am "%s"' % message | 317 git_commit_cmd = 'git commit -am "%s"' % message |
| 319 _RunCommand(git_commit_cmd) | 318 _SimpleRunCommand(git_commit_cmd) |
| 320 | 319 |
| 321 | 320 |
| 322 def main(argv): | 321 def main(argv): |
| 323 try: | 322 try: |
| 324 argv = gflags.FLAGS(argv) | 323 argv = gflags.FLAGS(argv) |
| 325 if len(argv) != 2: | 324 if len(argv) != 2: |
| 326 _PrintUsageAndDie('Must specify a valid command') | 325 _PrintUsageAndDie('Must specify a valid command') |
| 327 else: | 326 else: |
| 328 command = argv[1] | 327 command = argv[1] |
| 329 except gflags.FlagsError, e : | 328 except gflags.FlagsError, e : |
| 330 _PrintUsageAndDie(str(e)) | 329 _PrintUsageAndDie(str(e)) |
| 331 | 330 |
| 332 package_list = gflags.FLAGS.packages.split() | 331 package_list = gflags.FLAGS.packages.split() |
| 333 if gflags.FLAGS.commit_ids: | 332 if gflags.FLAGS.commit_ids: |
| 334 commit_id_list = gflags.FLAGS.commit_ids.split() | 333 commit_id_list = gflags.FLAGS.commit_ids.split() |
| 335 else: | 334 else: |
| 336 commit_id_list = None | 335 commit_id_list = None |
| 337 _CheckSaneArguments(package_list, commit_id_list, command) | 336 _CheckSaneArguments(package_list, commit_id_list, command) |
| 338 | 337 |
| 339 overlay_directory = '%s/third_party/chromiumos-overlay' % gflags.FLAGS.srcroot | 338 overlay_directory = '%s/third_party/chromiumos-overlay' % gflags.FLAGS.srcroot |
| 340 | 339 |
| 341 os.chdir(overlay_directory) | 340 os.chdir(overlay_directory) |
| 342 | 341 |
| 343 if command == 'clean': | 342 if command == 'clean': |
| 344 _Clean() | 343 _Clean() |
| 345 elif command == 'commit': | 344 elif command == 'commit': |
| 346 work_branch = _GitBranch(_STABLE_BRANCH_NAME) | 345 work_branch = _GitBranch(_STABLE_BRANCH_NAME) |
| 347 work_branch.CreateBranch() | 346 work_branch.CreateBranch() |
| 348 if not work_branch.Exists(): | 347 if not work_branch.Exists(): |
| 349 generate_test_report.Die('Unable to create stabilizing branch in %s' % | 348 Die('Unable to create stabilizing branch in %s' % |
| 350 overlay_directory) | 349 overlay_directory) |
| 351 index = 0 | 350 index = 0 |
| 352 try: | 351 try: |
| 353 for index in range(len(package_list)): | 352 for index in range(len(package_list)): |
| 354 # Gather the package and optional commit id to work on. | 353 # Gather the package and optional commit id to work on. |
| 355 package = package_list[index] | 354 package = package_list[index] |
| 356 commit_id = "" | 355 commit_id = "" |
| 357 if commit_id_list: | 356 if commit_id_list: |
| 358 commit_id = commit_id_list[index] | 357 commit_id = commit_id_list[index] |
| 359 | 358 |
| 360 _Print('Working on %s' % package) | 359 _Print('Working on %s' % package) |
| 361 worker = EBuildStableMarker(_EBuild(package, commit_id)) | 360 worker = EBuildStableMarker(_EBuild(package, commit_id)) |
| 362 worker.RevEBuild(commit_id) | 361 worker.RevEBuild(commit_id) |
| 363 worker.CommitChange(_GIT_COMMIT_MESSAGE % (package, commit_id)) | 362 worker.CommitChange(_GIT_COMMIT_MESSAGE % (package, commit_id)) |
| 364 | 363 |
| 365 except (OSError, IOError), e: | 364 except (OSError, IOError), e: |
| 366 print ('An exception occurred\n' | 365 Warning('An exception occurred\n' |
| 367 'Only the following packages were revved: %s\n' | 366 'Only the following packages were revved: %s\n' |
| 368 'Note you will have to go into %s' | 367 'Note you will have to go into %s' |
| 369 'and reset the git repo yourself.' % | 368 'and reset the git repo yourself.' % |
| 370 (package_list[:index], overlay_directory)) | 369 (package_list[:index], overlay_directory)) |
| 371 raise e | 370 raise e |
| 372 elif command == 'push': | 371 elif command == 'push': |
| 373 _PushChange() | 372 _PushChange() |
| 374 | 373 |
| 375 | 374 |
| 376 if __name__ == '__main__': | 375 if __name__ == '__main__': |
| 377 main(sys.argv) | 376 main(sys.argv) |
| 378 | 377 |
| OLD | NEW |