| 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 from portage.versions import pkgsplit, pkgsplit, vercmp | |
| 18 | 17 |
| 19 sys.path.append(os.path.join(os.path.dirname(__file__), 'lib')) | 18 sys.path.append(os.path.join(os.path.dirname(__file__), 'lib')) |
| 20 from cros_build_lib import Info, RunCommand, Warning, Die | 19 from cros_build_lib import Info, RunCommand, Warning, Die |
| 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 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 66 |
| 68 | 67 |
| 69 def _Print(message): | 68 def _Print(message): |
| 70 """Verbose print function.""" | 69 """Verbose print function.""" |
| 71 if gflags.FLAGS.verbose: | 70 if gflags.FLAGS.verbose: |
| 72 Info(message) | 71 Info(message) |
| 73 | 72 |
| 74 | 73 |
| 75 def _BestEBuild(ebuilds): | 74 def _BestEBuild(ebuilds): |
| 76 """Returns the newest EBuild from a list of EBuild objects.""" | 75 """Returns the newest EBuild from a list of EBuild objects.""" |
| 76 from portage.versions import vercmp |
| 77 winner = ebuilds[0] | 77 winner = ebuilds[0] |
| 78 for ebuild in ebuilds[1:]: | 78 for ebuild in ebuilds[1:]: |
| 79 if vercmp(winner.version, ebuild.version) < 0: | 79 if vercmp(winner.version, ebuild.version) < 0: |
| 80 winner = ebuild | 80 winner = ebuild |
| 81 return winner | 81 return winner |
| 82 | 82 |
| 83 | 83 |
| 84 def _FindStableEBuilds(files): | 84 def _FindStableEBuilds(files): |
| 85 """Return a list of stable ebuilds from specified list of files. | 85 """Return a list of stable ebuilds from specified list of files. |
| 86 | 86 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 272 |
| 273 class _EBuild(object): | 273 class _EBuild(object): |
| 274 """Wrapper class for an ebuild.""" | 274 """Wrapper class for an ebuild.""" |
| 275 | 275 |
| 276 def __init__(self, path): | 276 def __init__(self, path): |
| 277 """Initializes all data about an ebuild. | 277 """Initializes all data about an ebuild. |
| 278 | 278 |
| 279 Uses equery to find the ebuild path and sets data about an ebuild for | 279 Uses equery to find the ebuild path and sets data about an ebuild for |
| 280 easy reference. | 280 easy reference. |
| 281 """ | 281 """ |
| 282 from portage.versions import pkgsplit |
| 282 self.ebuild_path = path | 283 self.ebuild_path = path |
| 283 (self.ebuild_path_no_revision, | 284 (self.ebuild_path_no_revision, |
| 284 self.ebuild_path_no_version, | 285 self.ebuild_path_no_version, |
| 285 self.current_revision) = self._ParseEBuildPath(self.ebuild_path) | 286 self.current_revision) = self._ParseEBuildPath(self.ebuild_path) |
| 286 _, self.category, pkgpath, filename = path.rsplit('/', 3) | 287 _, self.category, pkgpath, filename = path.rsplit('/', 3) |
| 287 filename_no_suffix = os.path.join(filename.replace('.ebuild', '')) | 288 filename_no_suffix = os.path.join(filename.replace('.ebuild', '')) |
| 288 self.pkgname, version_no_rev, rev = pkgsplit(filename_no_suffix) | 289 self.pkgname, version_no_rev, rev = pkgsplit(filename_no_suffix) |
| 289 self.version = '%s-%s' % (version_no_rev, rev) | 290 self.version = '%s-%s' % (version_no_rev, rev) |
| 290 self.package = '%s/%s' % (self.category, self.pkgname) | 291 self.package = '%s/%s' % (self.category, self.pkgname) |
| 291 self.is_workon = False | 292 self.is_workon = False |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 except (OSError, IOError): | 505 except (OSError, IOError): |
| 505 Warning('Cannot rev %s\n' % ebuild.package, | 506 Warning('Cannot rev %s\n' % ebuild.package, |
| 506 'Note you will have to go into %s ' | 507 'Note you will have to go into %s ' |
| 507 'and reset the git repo yourself.' % overlay) | 508 'and reset the git repo yourself.' % overlay) |
| 508 raise | 509 raise |
| 509 | 510 |
| 510 | 511 |
| 511 if __name__ == '__main__': | 512 if __name__ == '__main__': |
| 512 main(sys.argv) | 513 main(sys.argv) |
| 513 | 514 |
| OLD | NEW |