Mike Frysinger | f1ba7ad | 2022-09-12 05:42:57 -0400 | [diff] [blame^] | 1 | # Copyright 2019 The ChromiumOS Authors |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Portage Binhost operations.""" |
| 6 | |
Michael Mortensen | fc82388 | 2019-08-27 14:38:07 -0600 | [diff] [blame] | 7 | import os |
| 8 | import shutil |
Kevin Shelton | 703b688 | 2022-01-24 16:31:31 -0800 | [diff] [blame] | 9 | from typing import TYPE_CHECKING |
Mike Frysinger | 1cc8f1f | 2022-04-28 22:40:40 -0400 | [diff] [blame] | 10 | import urllib.parse |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 11 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 12 | from chromite.api import controller |
Alex Klein | 076841b | 2019-08-29 15:19:39 -0600 | [diff] [blame] | 13 | from chromite.api import faux |
Alex Klein | 2b23672 | 2019-06-19 15:44:26 -0600 | [diff] [blame] | 14 | from chromite.api import validate |
Alex Klein | af0e045 | 2019-06-03 18:10:01 -0600 | [diff] [blame] | 15 | from chromite.api.controller import controller_util |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 16 | from chromite.api.gen.chromite.api import binhost_pb2 |
LaMont Jones | c64ae21 | 2019-04-15 15:41:28 -0600 | [diff] [blame] | 17 | from chromite.lib import constants |
| 18 | from chromite.lib import cros_build_lib |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 19 | from chromite.lib import gs |
Alex Klein | af0e045 | 2019-06-03 18:10:01 -0600 | [diff] [blame] | 20 | from chromite.lib import sysroot_lib |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 21 | from chromite.service import binhost |
| 22 | |
Mike Frysinger | 1cc8f1f | 2022-04-28 22:40:40 -0400 | [diff] [blame] | 23 | |
Kevin Shelton | 703b688 | 2022-01-24 16:31:31 -0800 | [diff] [blame] | 24 | if TYPE_CHECKING: |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 25 | from chromite.api import api_config |
Mike Frysinger | ef94e4c | 2020-02-10 23:59:54 -0500 | [diff] [blame] | 26 | |
Alex Klein | af0e045 | 2019-06-03 18:10:01 -0600 | [diff] [blame] | 27 | _OVERLAY_TYPE_TO_NAME = { |
| 28 | binhost_pb2.OVERLAYTYPE_PUBLIC: constants.PUBLIC_OVERLAYS, |
| 29 | binhost_pb2.OVERLAYTYPE_PRIVATE: constants.PRIVATE_OVERLAYS, |
| 30 | binhost_pb2.OVERLAYTYPE_BOTH: constants.BOTH_OVERLAYS, |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 31 | binhost_pb2.OVERLAYTYPE_NONE: None, |
Alex Klein | af0e045 | 2019-06-03 18:10:01 -0600 | [diff] [blame] | 32 | } |
| 33 | |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 34 | |
Michael Mortensen | a0af77b | 2019-11-13 11:15:15 -0700 | [diff] [blame] | 35 | def _GetBinhostsResponse(_input_proto, output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 36 | """Add fake binhosts to a successful response.""" |
| 37 | new_binhost = output_proto.binhosts.add() |
| 38 | new_binhost.uri = ( |
| 39 | "gs://cr-prebuilt/board/amd64-generic/" |
| 40 | "paladin-R66-17.0.0-rc2/packages/" |
| 41 | ) |
| 42 | new_binhost.package_index = "Packages" |
Michael Mortensen | a0af77b | 2019-11-13 11:15:15 -0700 | [diff] [blame] | 43 | |
| 44 | |
| 45 | @faux.success(_GetBinhostsResponse) |
| 46 | @faux.empty_error |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 47 | @validate.require("build_target.name") |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 48 | @validate.validation_complete |
| 49 | def GetBinhosts(input_proto, output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 50 | """Get a list of binhosts.""" |
| 51 | build_target = controller_util.ParseBuildTarget(input_proto.build_target) |
Alex Klein | 7e40d25 | 2019-06-10 09:01:32 -0600 | [diff] [blame] | 52 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 53 | binhosts = binhost.GetBinhosts(build_target) |
Alex Klein | 7e40d25 | 2019-06-10 09:01:32 -0600 | [diff] [blame] | 54 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 55 | for current in binhosts: |
| 56 | new_binhost = output_proto.binhosts.add() |
| 57 | new_binhost.uri = current |
| 58 | new_binhost.package_index = "Packages" |
Alex Klein | 7e40d25 | 2019-06-10 09:01:32 -0600 | [diff] [blame] | 59 | |
| 60 | |
Michael Mortensen | 42251f9 | 2019-11-14 11:01:43 -0700 | [diff] [blame] | 61 | def _GetPrivatePrebuiltAclArgsResponse(_input_proto, output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 62 | """Add fake acls to a successful response.""" |
| 63 | new_arg = output_proto.args.add() |
| 64 | new_arg.arg = "-g" |
| 65 | new_arg.value = "group1:READ" |
Michael Mortensen | 42251f9 | 2019-11-14 11:01:43 -0700 | [diff] [blame] | 66 | |
| 67 | |
| 68 | @faux.success(_GetPrivatePrebuiltAclArgsResponse) |
| 69 | @faux.empty_error |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 70 | @validate.require("build_target.name") |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 71 | @validate.validation_complete |
| 72 | def GetPrivatePrebuiltAclArgs(input_proto, output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 73 | """Get the ACL args from the files in the private overlays.""" |
| 74 | build_target = controller_util.ParseBuildTarget(input_proto.build_target) |
Alex Klein | a471f68 | 2019-05-31 11:23:45 -0600 | [diff] [blame] | 75 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 76 | try: |
| 77 | args = binhost.GetPrebuiltAclArgs(build_target) |
| 78 | except binhost.Error as e: |
| 79 | cros_build_lib.Die(e) |
Alex Klein | a471f68 | 2019-05-31 11:23:45 -0600 | [diff] [blame] | 80 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 81 | for arg, value in args: |
| 82 | new_arg = output_proto.args.add() |
| 83 | new_arg.arg = arg |
| 84 | new_arg.value = value |
Alex Klein | a471f68 | 2019-05-31 11:23:45 -0600 | [diff] [blame] | 85 | |
| 86 | |
Michael Mortensen | 42251f9 | 2019-11-14 11:01:43 -0700 | [diff] [blame] | 87 | def _PrepareBinhostUploadsResponse(_input_proto, output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 88 | """Add fake binhost upload targets to a successful response.""" |
| 89 | output_proto.uploads_dir = "/upload/directory" |
| 90 | output_proto.upload_targets.add().path = "upload_target" |
Michael Mortensen | 42251f9 | 2019-11-14 11:01:43 -0700 | [diff] [blame] | 91 | |
| 92 | |
| 93 | @faux.success(_PrepareBinhostUploadsResponse) |
| 94 | @faux.empty_error |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 95 | @validate.require("uri") |
Kevin Shelton | 703b688 | 2022-01-24 16:31:31 -0800 | [diff] [blame] | 96 | def PrepareBinhostUploads( |
| 97 | input_proto: binhost_pb2.PrepareBinhostUploadsRequest, |
| 98 | output_proto: binhost_pb2.PrepareBinhostUploadsResponse, |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 99 | config: "api_config.ApiConfig", |
| 100 | ): |
| 101 | """Return a list of files to upload to the binhost. |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 102 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 103 | See BinhostService documentation in api/proto/binhost.proto. |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 104 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 105 | Args: |
| 106 | input_proto: The input proto. |
| 107 | output_proto: The output proto. |
| 108 | config: The API call config. |
| 109 | """ |
| 110 | if input_proto.sysroot.build_target.name: |
| 111 | build_target_msg = input_proto.sysroot.build_target |
| 112 | else: |
| 113 | build_target_msg = input_proto.build_target |
| 114 | sysroot_path = input_proto.sysroot.path |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 115 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 116 | if not sysroot_path and not build_target_msg.name: |
| 117 | cros_build_lib.Die("Sysroot.path is required.") |
Alex Klein | af0e045 | 2019-06-03 18:10:01 -0600 | [diff] [blame] | 118 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 119 | build_target = controller_util.ParseBuildTarget(build_target_msg) |
| 120 | chroot = controller_util.ParseChroot(input_proto.chroot) |
Alex Klein | af0e045 | 2019-06-03 18:10:01 -0600 | [diff] [blame] | 121 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 122 | if not sysroot_path: |
| 123 | sysroot_path = build_target.root |
| 124 | sysroot = sysroot_lib.Sysroot(sysroot_path) |
Alex Klein | af0e045 | 2019-06-03 18:10:01 -0600 | [diff] [blame] | 125 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 126 | uri = input_proto.uri |
| 127 | # For now, we enforce that all input URIs are Google Storage buckets. |
| 128 | if not gs.PathIsGs(uri): |
| 129 | raise ValueError("Upload URI %s must be Google Storage." % uri) |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 130 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 131 | if config.validate_only: |
| 132 | return controller.RETURN_CODE_VALID_INPUT |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 133 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 134 | parsed_uri = urllib.parse.urlparse(uri) |
| 135 | upload_uri = gs.GetGsURL(parsed_uri.netloc, for_gsutil=True).rstrip("/") |
| 136 | upload_path = parsed_uri.path.lstrip("/") |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 137 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 138 | # Read all packages and update the index. The index must be uploaded to the |
| 139 | # binhost for Portage to use it, so include it in upload_targets. |
| 140 | uploads_dir = binhost.GetPrebuiltsRoot(chroot, sysroot, build_target) |
| 141 | index_path = binhost.UpdatePackageIndex( |
| 142 | uploads_dir, upload_uri, upload_path, sudo=True |
| 143 | ) |
| 144 | upload_targets = binhost.GetPrebuiltsFiles(uploads_dir) |
| 145 | assert index_path.startswith( |
| 146 | uploads_dir |
| 147 | ), "expected index_path to start with uploads_dir" |
| 148 | upload_targets.append(index_path[len(uploads_dir) :]) |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 149 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 150 | output_proto.uploads_dir = uploads_dir |
| 151 | for upload_target in upload_targets: |
| 152 | output_proto.upload_targets.add().path = upload_target.strip("/") |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 153 | |
Alex Klein | 076841b | 2019-08-29 15:19:39 -0600 | [diff] [blame] | 154 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 155 | def _PrepareDevInstallBinhostUploadsResponse( |
| 156 | _input_proto, output_proto, _config |
| 157 | ): |
| 158 | """Add fake binhost files to a successful response.""" |
| 159 | output_proto.upload_targets.add().path = "app-arch/zip-3.0-r3.tbz2" |
| 160 | output_proto.upload_targets.add().path = "virtual/python-enum34-1.tbz2" |
| 161 | output_proto.upload_targets.add().path = "Packages" |
Michael Mortensen | 42251f9 | 2019-11-14 11:01:43 -0700 | [diff] [blame] | 162 | |
| 163 | |
| 164 | @faux.success(_PrepareDevInstallBinhostUploadsResponse) |
| 165 | @faux.empty_error |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 166 | @validate.require("uri", "sysroot.path") |
| 167 | @validate.exists("uploads_dir") |
Kevin Shelton | 703b688 | 2022-01-24 16:31:31 -0800 | [diff] [blame] | 168 | def PrepareDevInstallBinhostUploads( |
| 169 | input_proto: binhost_pb2.PrepareDevInstallBinhostUploadsRequest, |
| 170 | output_proto: binhost_pb2.PrepareDevInstallBinhostUploadsResponse, |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 171 | config: "api_config.ApiConfig", |
| 172 | ): |
| 173 | """Return a list of files to upload to the binhost" |
Michael Mortensen | fc82388 | 2019-08-27 14:38:07 -0600 | [diff] [blame] | 174 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 175 | The files will also be copied to the uploads_dir. |
| 176 | See BinhostService documentation in api/proto/binhost.proto. |
Michael Mortensen | fc82388 | 2019-08-27 14:38:07 -0600 | [diff] [blame] | 177 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 178 | Args: |
| 179 | input_proto: The input proto. |
| 180 | output_proto: The output proto. |
| 181 | config: The API call config. |
| 182 | """ |
| 183 | sysroot_path = input_proto.sysroot.path |
Michael Mortensen | fc82388 | 2019-08-27 14:38:07 -0600 | [diff] [blame] | 184 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 185 | chroot = controller_util.ParseChroot(input_proto.chroot) |
| 186 | sysroot = sysroot_lib.Sysroot(sysroot_path) |
Michael Mortensen | fc82388 | 2019-08-27 14:38:07 -0600 | [diff] [blame] | 187 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 188 | uri = input_proto.uri |
| 189 | # For now, we enforce that all input URIs are Google Storage buckets. |
| 190 | if not gs.PathIsGs(uri): |
| 191 | raise ValueError("Upload URI %s must be Google Storage." % uri) |
Michael Mortensen | fc82388 | 2019-08-27 14:38:07 -0600 | [diff] [blame] | 192 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 193 | if config.validate_only: |
| 194 | return controller.RETURN_CODE_VALID_INPUT |
Michael Mortensen | fc82388 | 2019-08-27 14:38:07 -0600 | [diff] [blame] | 195 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 196 | parsed_uri = urllib.parse.urlparse(uri) |
| 197 | upload_uri = gs.GetGsURL(parsed_uri.netloc, for_gsutil=True).rstrip("/") |
| 198 | upload_path = parsed_uri.path.lstrip("/") |
Michael Mortensen | fc82388 | 2019-08-27 14:38:07 -0600 | [diff] [blame] | 199 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 200 | # Calculate the filename for the to-be-created Packages file, which will |
| 201 | # contain only devinstall packages. |
| 202 | devinstall_package_index_path = os.path.join( |
| 203 | input_proto.uploads_dir, "Packages" |
| 204 | ) |
| 205 | upload_targets_list = binhost.ReadDevInstallFilesToCreatePackageIndex( |
| 206 | chroot, sysroot, devinstall_package_index_path, upload_uri, upload_path |
| 207 | ) |
Michael Mortensen | fc82388 | 2019-08-27 14:38:07 -0600 | [diff] [blame] | 208 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 209 | package_dir = chroot.full_path(sysroot.path, "packages") |
| 210 | for upload_target in upload_targets_list: |
| 211 | # Copy each package to target/category/package |
| 212 | upload_target = upload_target.strip("/") |
| 213 | category = upload_target.split(os.sep)[0] |
| 214 | target_dir = os.path.join(input_proto.uploads_dir, category) |
| 215 | if not os.path.exists(target_dir): |
| 216 | os.makedirs(target_dir) |
| 217 | full_src_pkg_path = os.path.join(package_dir, upload_target) |
| 218 | full_target_src_path = os.path.join( |
| 219 | input_proto.uploads_dir, upload_target |
| 220 | ) |
| 221 | shutil.copyfile(full_src_pkg_path, full_target_src_path) |
| 222 | output_proto.upload_targets.add().path = upload_target |
| 223 | output_proto.upload_targets.add().path = "Packages" |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 224 | |
Alex Klein | 076841b | 2019-08-29 15:19:39 -0600 | [diff] [blame] | 225 | |
Michael Mortensen | 42251f9 | 2019-11-14 11:01:43 -0700 | [diff] [blame] | 226 | def _SetBinhostResponse(_input_proto, output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 227 | """Add fake binhost file to a successful response.""" |
| 228 | output_proto.output_file = "/path/to/BINHOST.conf" |
Michael Mortensen | 42251f9 | 2019-11-14 11:01:43 -0700 | [diff] [blame] | 229 | |
| 230 | |
| 231 | @faux.success(_SetBinhostResponse) |
| 232 | @faux.empty_error |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 233 | @validate.require("build_target.name", "key", "uri") |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 234 | @validate.validation_complete |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 235 | def SetBinhost( |
| 236 | input_proto: binhost_pb2.SetBinhostRequest, |
| 237 | output_proto: binhost_pb2.SetBinhostResponse, |
| 238 | _config: "api_config.ApiConfig", |
| 239 | ): |
| 240 | """Set the URI for a given binhost key and build target. |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 241 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 242 | See BinhostService documentation in api/proto/binhost.proto. |
Evan Hernandez | d437b4e | 2019-03-25 13:48:30 -0600 | [diff] [blame] | 243 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 244 | Args: |
| 245 | input_proto: The input proto. |
| 246 | output_proto: The output proto. |
| 247 | _config: The API call config. |
| 248 | """ |
| 249 | target = input_proto.build_target.name |
| 250 | key = binhost_pb2.BinhostKey.Name(input_proto.key) |
| 251 | uri = input_proto.uri |
| 252 | private = input_proto.private |
Alex Klein | 6fb0eb8 | 2019-05-20 16:16:14 -0600 | [diff] [blame] | 253 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 254 | output_proto.output_file = binhost.SetBinhost( |
| 255 | target, key, uri, private=private |
| 256 | ) |
LaMont Jones | c64ae21 | 2019-04-15 15:41:28 -0600 | [diff] [blame] | 257 | |
LaMont Jones | c64ae21 | 2019-04-15 15:41:28 -0600 | [diff] [blame] | 258 | |
Michael Mortensen | 42251f9 | 2019-11-14 11:01:43 -0700 | [diff] [blame] | 259 | def _RegenBuildCacheResponse(_input_proto, output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 260 | """Add fake binhosts cache path to a successful response.""" |
| 261 | output_proto.modified_overlays.add().path = "/path/to/BuildCache" |
Michael Mortensen | 42251f9 | 2019-11-14 11:01:43 -0700 | [diff] [blame] | 262 | |
| 263 | |
| 264 | @faux.success(_RegenBuildCacheResponse) |
| 265 | @faux.empty_error |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 266 | @validate.require("overlay_type") |
| 267 | @validate.is_in("overlay_type", _OVERLAY_TYPE_TO_NAME) |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 268 | @validate.validation_complete |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 269 | def RegenBuildCache( |
| 270 | input_proto: binhost_pb2.RegenBuildCacheRequest, |
| 271 | output_proto: binhost_pb2.RegenBuildCacheResponse, |
| 272 | _config: "api_config.ApiConfig", |
| 273 | ): |
| 274 | """Regenerate the Build Cache for a build target. |
LaMont Jones | c64ae21 | 2019-04-15 15:41:28 -0600 | [diff] [blame] | 275 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 276 | See BinhostService documentation in api/proto/binhost.proto. |
LaMont Jones | c64ae21 | 2019-04-15 15:41:28 -0600 | [diff] [blame] | 277 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 278 | Args: |
| 279 | input_proto: The input proto. |
| 280 | output_proto: The output proto. |
| 281 | _config: The API call config. |
| 282 | """ |
| 283 | chroot = controller_util.ParseChroot(input_proto.chroot) |
| 284 | overlay_type = input_proto.overlay_type |
| 285 | overlays = binhost.RegenBuildCache( |
| 286 | chroot, _OVERLAY_TYPE_TO_NAME[overlay_type] |
| 287 | ) |
Alex Klein | 82c85d4 | 2019-08-14 15:47:51 -0600 | [diff] [blame] | 288 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 289 | for overlay in overlays: |
| 290 | output_proto.modified_overlays.add().path = overlay |