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 sys.path.append(os.path.join(os.path.dirname(__file__), 'lib')) | 18 sys.path.append(os.path.join(os.path.dirname(__file__), 'lib')) |
19 from cros_build_lib import Info, RunCommand, Warning, Die | 19 from cros_build_lib import Info, RunCommand, Warning, Die |
20 | 20 |
21 | 21 |
22 gflags.DEFINE_string('board', '', | 22 gflags.DEFINE_string('board', '', |
23 'Board for which the package belongs.', short_name='b') | 23 'Board for which the package belongs.', short_name='b') |
24 gflags.DEFINE_string('overlays', '', | 24 gflags.DEFINE_string('overlays', '', |
25 'Space separated list of overlays to modify.', | 25 'Colon-separated list of overlays to modify.', |
26 short_name='o') | 26 short_name='o') |
27 gflags.DEFINE_string('packages', '', | 27 gflags.DEFINE_string('packages', '', |
28 'Space separated list of packages to mark as stable.', | 28 'Colon-separated list of packages to mark as stable.', |
29 short_name='p') | 29 short_name='p') |
30 gflags.DEFINE_string('push_options', '', | 30 gflags.DEFINE_string('push_options', '', |
31 'Options to use with git-cl push using push command.') | 31 'Options to use with git-cl push using push command.') |
32 gflags.DEFINE_string('srcroot', '%s/trunk/src' % os.environ['HOME'], | 32 gflags.DEFINE_string('srcroot', '%s/trunk/src' % os.environ['HOME'], |
33 'Path to root src directory.', | 33 'Path to root src directory.', |
34 short_name='r') | 34 short_name='r') |
35 gflags.DEFINE_string('tracking_branch', 'cros/master', | 35 gflags.DEFINE_string('tracking_branch', 'cros/master', |
36 'Used with commit to specify branch to track against.', | 36 'Used with commit to specify branch to track against.', |
37 short_name='t') | 37 short_name='t') |
38 gflags.DEFINE_boolean('all', False, | 38 gflags.DEFINE_boolean('all', False, |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 merge_branch.CreateBranch() | 234 merge_branch.CreateBranch() |
235 if not merge_branch.Exists(): | 235 if not merge_branch.Exists(): |
236 Die('Unable to create merge branch.') | 236 Die('Unable to create merge branch.') |
237 _SimpleRunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) | 237 _SimpleRunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) |
238 _SimpleRunCommand('git commit -m "%s"' % description) | 238 _SimpleRunCommand('git commit -m "%s"' % description) |
239 # Ugh. There has got to be an easier way to push to a tracking branch | 239 # Ugh. There has got to be an easier way to push to a tracking branch |
240 _SimpleRunCommand('git config push.default tracking') | 240 _SimpleRunCommand('git config push.default tracking') |
241 _SimpleRunCommand('git push') | 241 _SimpleRunCommand('git push') |
242 | 242 |
243 | 243 |
244 def _SimpleRunCommand(command): | 244 def _SimpleRunCommand(command): |
scottz-goog
2010/11/10 23:48:14
Update description to match new function behavior.
| |
245 """Runs a shell command and returns stdout back to caller.""" | 245 """Runs a shell command and returns stdout back to caller.""" |
246 _Print(' + %s' % command) | 246 _Print(' + %s' % command) |
247 proc_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) | 247 proc_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) |
248 return proc_handle.communicate()[0] | 248 stdout = proc_handle.communicate()[0] |
249 retcode = proc_handle.wait() | |
250 assert retcode == 0, "Return code %s for command: %s" % (retcode, command) | |
scottz-goog
2010/11/10 23:48:14
Assert are good for debugging but generally if you
| |
251 return stdout | |
249 | 252 |
250 | 253 |
251 # ======================= End Global Helper Functions ======================== | 254 # ======================= End Global Helper Functions ======================== |
252 | 255 |
253 | 256 |
254 class _GitBranch(object): | 257 class _GitBranch(object): |
255 """Wrapper class for a git branch.""" | 258 """Wrapper class for a git branch.""" |
256 | 259 |
257 def __init__(self, branch_name): | 260 def __init__(self, branch_name): |
258 """Sets up variables but does not create the branch.""" | 261 """Sets up variables but does not create the branch.""" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 def main(argv): | 483 def main(argv): |
481 try: | 484 try: |
482 argv = gflags.FLAGS(argv) | 485 argv = gflags.FLAGS(argv) |
483 if len(argv) != 2: | 486 if len(argv) != 2: |
484 _PrintUsageAndDie('Must specify a valid command') | 487 _PrintUsageAndDie('Must specify a valid command') |
485 else: | 488 else: |
486 command = argv[1] | 489 command = argv[1] |
487 except gflags.FlagsError, e : | 490 except gflags.FlagsError, e : |
488 _PrintUsageAndDie(str(e)) | 491 _PrintUsageAndDie(str(e)) |
489 | 492 |
490 package_list = gflags.FLAGS.packages.split() | 493 package_list = gflags.FLAGS.packages.split(':') |
491 _CheckSaneArguments(package_list, command) | 494 _CheckSaneArguments(package_list, command) |
492 if gflags.FLAGS.overlays: | 495 if gflags.FLAGS.overlays: |
493 overlays = dict((path, []) for path in gflags.FLAGS.overlays.split()) | 496 overlays = {} |
497 for path in gflags.FLAGS.overlays.split(':'): | |
498 if not os.path.exists(path): | |
499 Die('Cannot find overlay: %s' % path) | |
500 overlays[path] = [] | |
494 else: | 501 else: |
502 Warning('Missing --overlays argument') | |
495 overlays = { | 503 overlays = { |
496 '%s/private-overlays/chromeos-overlay' % gflags.FLAGS.srcroot: [], | 504 '%s/private-overlays/chromeos-overlay' % gflags.FLAGS.srcroot: [], |
497 '%s/third_party/chromiumos-overlay' % gflags.FLAGS.srcroot: [] | 505 '%s/third_party/chromiumos-overlay' % gflags.FLAGS.srcroot: [] |
498 } | 506 } |
499 | 507 |
500 if command == 'commit': | 508 if command == 'commit': |
501 _BuildEBuildDictionary(overlays, gflags.FLAGS.all, package_list) | 509 _BuildEBuildDictionary(overlays, gflags.FLAGS.all, package_list) |
502 | 510 |
503 for overlay, ebuilds in overlays.items(): | 511 for overlay, ebuilds in overlays.items(): |
504 if not os.path.exists(overlay): | 512 if not os.path.exists(overlay): |
(...skipping 30 matching lines...) Expand all Loading... | |
535 raise | 543 raise |
536 | 544 |
537 if revved_packages: | 545 if revved_packages: |
538 _CleanStalePackages(gflags.FLAGS.board, revved_packages) | 546 _CleanStalePackages(gflags.FLAGS.board, revved_packages) |
539 else: | 547 else: |
540 work_branch.Delete() | 548 work_branch.Delete() |
541 | 549 |
542 | 550 |
543 if __name__ == '__main__': | 551 if __name__ == '__main__': |
544 main(sys.argv) | 552 main(sys.argv) |
OLD | NEW |