scripts: lint_packages supports host packages

This CL implements support for linting host packages in CLI using --host
instead of --board.

BUG=b:236735676
TEST=ran lint_package --host for a few packages

Change-Id: I0eba6b079c2000bb911242fae1be83f41d7feeb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3718650
Tested-by: Ryan Beltran <ryanbeltran@chromium.org>
Reviewed-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Ryan Beltran <ryanbeltran@chromium.org>
diff --git a/scripts/lint_package.py b/scripts/lint_package.py
index f3eae96..f37e7ce 100644
--- a/scripts/lint_package.py
+++ b/scripts/lint_package.py
@@ -38,8 +38,12 @@
     parsed = package_info.parse(package)
     if not parsed.category:
       # If a category is not specified, we can get it from the ebuild path.
-      ebuild_path = portage_util.FindEbuildForBoardPackage(
-          package, build_target.name, build_target.root)
+      if build_target.is_host():
+        ebuild_path = portage_util.FindEbuildForPackage(
+            package, build_target.root)
+      else:
+        ebuild_path = portage_util.FindEbuildForBoardPackage(
+            package, build_target.name, build_target.root)
       ebuild_data = portage_util.EBuild(ebuild_path)
       parsed = package_info.parse(ebuild_data.package)
     package_infos.append(parsed)
@@ -60,6 +64,10 @@
       default=default_board,
       help='The board to emerge packages for')
   board_group.add_argument(
+      '--host',
+      action='store_true',
+      help='emerge for host instead of board.')
+  board_group.add_argument(
       '--fetch-only',
       action='store_true',
       help='Fetch lints from previous run without reseting or calling emerge.')
@@ -107,7 +115,11 @@
   cros_build_lib.AssertInsideChroot()
   opts = parse_args(argv)
 
-  build_target = build_target_lib.BuildTarget(opts.board)
+  if opts.host:
+    # BuildTarget interprets None as host target
+    build_target = build_target_lib.BuildTarget(None)
+  else:
+    build_target = build_target_lib.BuildTarget(opts.board)
   packages = parse_packages(build_target, opts.packages)
   package_atoms = [x.atom for x in packages]