blob: fc2c437221e5f8a8398ab85a7d6c208f6c433b98 [file] [log] [blame]
David Jamese5867812012-10-19 12:02:20 -07001# 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 Garrett25f309a2014-03-19 14:02:12 -07005"""Calculate what overlays are needed for a particular board."""
David Jamese5867812012-10-19 12:02:20 -07006
David Jamese5867812012-10-19 12:02:20 -07007import os
8
Mike Frysinger58f9eb72014-08-26 10:10:47 -04009from chromite.lib import commandline
Mike Frysinger807d8282022-04-28 22:45:17 -040010from chromite.lib import constants
Alex Deymo075c2292014-09-04 18:31:50 -070011from chromite.lib import portage_util
David Jamese5867812012-10-19 12:02:20 -070012
13
14def _ParseArguments(argv):
Alex Klein1699fab2022-09-08 08:46:06 -060015 parser = commandline.ArgumentParser(description=__doc__)
David Jamese5867812012-10-19 12:02:20 -070016
Alex Klein1699fab2022-09-08 08:46:06 -060017 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 Jamese5867812012-10-19 12:02:20 -070025
Alex Klein1699fab2022-09-08 08:46:06 -060026 opts = parser.parse_args(argv)
27 opts.Freeze()
David Jamese5867812012-10-19 12:02:20 -070028
Alex Klein1699fab2022-09-08 08:46:06 -060029 return opts
David Jamese5867812012-10-19 12:02:20 -070030
31
32def main(argv):
Alex Klein1699fab2022-09-08 08:46:06 -060033 opts = _ParseArguments(argv)
David Jamese5867812012-10-19 12:02:20 -070034
Alex Klein1699fab2022-09-08 08:46:06 -060035 overlays = portage_util.FindOverlays(constants.BOTH_OVERLAYS, opts.board)
David Jamese5867812012-10-19 12:02:20 -070036
Alex Klein1699fab2022-09-08 08:46:06 -060037 # 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 Jamese5867812012-10-19 12:02:20 -070044
Alex Klein1699fab2022-09-08 08:46:06 -060045 print("\n".join(overlays))