David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Don Garrett | 25f309a | 2014-03-19 14:02:12 -0700 | [diff] [blame] | 5 | """Calculate what overlays are needed for a particular board.""" |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 6 | |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 7 | import os |
| 8 | |
Mike Frysinger | 58f9eb7 | 2014-08-26 10:10:47 -0400 | [diff] [blame] | 9 | from chromite.lib import commandline |
Mike Frysinger | 807d828 | 2022-04-28 22:45:17 -0400 | [diff] [blame] | 10 | from chromite.lib import constants |
Alex Deymo | 075c229 | 2014-09-04 18:31:50 -0700 | [diff] [blame] | 11 | from chromite.lib import portage_util |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 12 | |
| 13 | |
| 14 | def _ParseArguments(argv): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 15 | parser = commandline.ArgumentParser(description=__doc__) |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 16 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 17 | parser.add_argument("--board", default=None, help="Board name") |
| 18 | parser.add_argument( |
| 19 | "-a", |
| 20 | "--all", |
| 21 | default=False, |
| 22 | action="store_true", |
| 23 | help="Show all overlays (even common ones).", |
| 24 | ) |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 25 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 26 | opts = parser.parse_args(argv) |
| 27 | opts.Freeze() |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 28 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 29 | return opts |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 30 | |
| 31 | |
| 32 | def main(argv): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 33 | opts = _ParseArguments(argv) |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 34 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 35 | overlays = portage_util.FindOverlays(constants.BOTH_OVERLAYS, opts.board) |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 36 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 37 | # Exclude any overlays in src/third_party, for backwards compatibility with |
| 38 | # scripts that expected these to not be listed. |
| 39 | if not opts.all: |
| 40 | ignore_prefix = os.path.join( |
| 41 | constants.SOURCE_ROOT, "src", "third_party" |
| 42 | ) |
| 43 | overlays = [o for o in overlays if not o.startswith(ignore_prefix)] |
David James | e586781 | 2012-10-19 12:02:20 -0700 | [diff] [blame] | 44 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 45 | print("\n".join(overlays)) |