Implement Sysroot.GenerateArchive.
Regenerated api/gen/chromite/api/sysroot_pb2.py by running
compile_build_api_proto. This ports the code in
cbuildbot/stages/artifact_stage.py (_GenerateSysroot).
BUG=chromium:1042402
TEST=manual, run_tests
Change-Id: I71ea25babdd696162fd512dffa8859346f03e348
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2044369
Reviewed-by: Alex Klein <saklein@chromium.org>
Tested-by: Michael Mortensen <mmortensen@google.com>
diff --git a/api/controller/sysroot.py b/api/controller/sysroot.py
index a1f892b..4c21eca 100644
--- a/api/controller/sysroot.py
+++ b/api/controller/sysroot.py
@@ -18,6 +18,7 @@
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
from chromite.lib import goma_lib
+from chromite.lib import osutils
from chromite.lib import portage_util
from chromite.lib import sysroot_lib
from chromite.service import sysroot
@@ -71,6 +72,26 @@
return controller.RETURN_CODE_SUCCESS
+@faux.all_empty
+@validate.require('build_target.name', 'packages')
+@validate.validation_complete
+def GenerateArchive(input_proto, output_proto, _config):
+ """Generate a sysroot. Typically used by informational builders."""
+ build_target_name = input_proto.build_target.name
+ pkg_list = []
+ for package in input_proto.packages:
+ pkg_list.append('%s/%s' % (package.category, package.package_name))
+
+ with osutils.TempDir(delete=False) as temp_output_dir:
+ sysroot_tar_path = sysroot.GenerateArchive(temp_output_dir,
+ build_target_name,
+ pkg_list)
+
+ # By assigning this Path variable to the tar path, the tar file will be
+ # copied out to the input_proto's ResultPath location.
+ output_proto.sysroot_archive.path = sysroot_tar_path
+
+
def _MockFailedPackagesResponse(_input_proto, output_proto, _config):
"""Mock error response that populates failed packages."""
pkg = output_proto.failed_packages.add()