service: needs_chrome_source: search for binpkgs in virtual/target depgraph

Rather than trying to emerge the chrome package directly to see if it
has a binpkg, emerge the high-level virtual/target-os packages.  This
will take into account things like changing deps/subslots that would
cause a binpkg to be ignored that testing a package directly misses.

BUG=b:292138028
TEST=CQ passes

Change-Id: I54d69afa88bd3346b4074c4dc2cfacc2d56e687e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4908599
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/has_prebuilt.py b/scripts/has_prebuilt.py
index c262283..6ce8b79 100644
--- a/scripts/has_prebuilt.py
+++ b/scripts/has_prebuilt.py
@@ -34,6 +34,11 @@
         help="The build target that is being checked.",
     )
     parser.add_argument(
+        "--depgraph-root-packages",
+        action="split_extend",
+        help="Search the depgraph starting at these packages.",
+    )
+    parser.add_argument(
         "--output",
         type="path",
         required=True,
@@ -112,7 +117,11 @@
         ]
         if board:
             args.append("--board=%s" % board)
-        args.extend("=%s" % best.cpvr for best in bests.values())
+        if opts.depgraph_root_packages:
+            args += [f"--reinstall-atoms={x.cp}" for x in bests.values()]
+            args += opts.depgraph_root_packages
+        else:
+            args.extend("=%s" % best.cpvr for best in bests.values())
 
         generator = depgraph.DepGraphGenerator()
         logging.debug(