sdk_subtools: Split the export step so it can upload outside the chroot.

Defines a simple data structure that contains metadata required for
the upload which is serialized to json in the metadata path.

The exporter reloads this and currently just invokes `cipd create`. A
follow-up will do this conditionally based on whether the package has
changed by interrogating cipd for additional metadata.

Only upload cares about the `use_production` flag. Ensure it is plumbed
through from the build API controller.

Proto change: https://crrev.com/c/4878477
Recipe changes: https://crrev.com/c/4881790

BUG=b:277992359
TEST=CQ, led, call_scripts, bin/build_sdk_subtools

Change-Id: If71758585f0af29323ed9c893157f5c8ffb50e5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4878101
Tested-by: Trent Apted <tapted@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
diff --git a/scripts/build_sdk_subtools.py b/scripts/build_sdk_subtools.py
index 265a768..a716e0d 100644
--- a/scripts/build_sdk_subtools.py
+++ b/scripts/build_sdk_subtools.py
@@ -14,7 +14,7 @@
 changed USE flags will be rebuilt, along with reverse dependencies.
 
 Packages (e.g. an ebuild) provide manifests that describes how files, once
-installed, are to be bundled and exported.
+installed, are to be bundled and uploaded.
 
 If packages are specified in the command line, only consider the deptree from
 those specific packages rather than all of virtual/target-sdk-subtools.
@@ -76,7 +76,7 @@
     relaunch_for_setup: bool
     output_dir: Path
     packages: List[str]
-    export: List[str]
+    upload: List[str]
     jobs: int
 
     def Freeze(self) -> None:
@@ -111,8 +111,8 @@
     parser.add_bool_argument(
         "--production",
         False,
-        "Use production environments for subtool exports.",
-        "Use staging environments for subtool exports.",
+        "Use production environments for subtool uploads.",
+        "Use staging environments for subtool uploads.",
     )
 
     parser.add_argument(
@@ -123,11 +123,11 @@
     )
 
     parser.add_argument(
-        "--export",
+        "--upload",
         nargs="+",
         default=[],
         metavar="BUNDLE",
-        help="Packages to export (e.g. to CIPD). May require auth.",
+        help="Packages to upload (e.g. to CIPD). May require auth.",
     )
 
     parser.add_argument(
@@ -197,12 +197,12 @@
         except sysroot_lib.PackageInstallError as e:
             cros_build_lib.Die(e)
 
-    installed = sdk_subtools.bundle_and_export(opts.production, opts.export)
+    installed = sdk_subtools.bundle_and_upload(opts.production, opts.upload)
     if not installed.subtools:
         logger.warn("No subtools available.")
-    elif not opts.export:
+    elif not opts.upload:
         logger.notice(
-            "Use --export to export a package. Available:%s",
+            "Use --upload to upload a package. Available:%s",
             "".join(f"\n\t{x.summary}" for x in installed.subtools),
         )