Mike Frysinger | f1ba7ad | 2022-09-12 05:42:57 -0400 | [diff] [blame] | 1 | # Copyright 2019 The ChromiumOS Authors |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [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 | """SDK chroot operations.""" |
| 6 | |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [diff] [blame] | 7 | import os |
Greg Edelston | cd70b20 | 2023-09-14 14:04:12 -0600 | [diff] [blame] | 8 | from pathlib import Path |
Alex Klein | 0996b46 | 2023-06-15 15:26:37 -0600 | [diff] [blame] | 9 | from typing import Dict, TYPE_CHECKING, Union |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [diff] [blame] | 10 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 11 | from chromite.api import controller |
Alex Klein | 076841b | 2019-08-29 15:19:39 -0600 | [diff] [blame] | 12 | from chromite.api import faux |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 13 | from chromite.api import validate |
Alex Klein | 71a9a1d | 2019-10-28 15:45:10 -0600 | [diff] [blame] | 14 | from chromite.api.controller import controller_util |
Bob Haarman | 0853ce9 | 2022-12-13 18:11:53 +0000 | [diff] [blame] | 15 | from chromite.api.gen.chromiumos import common_pb2 |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [diff] [blame] | 16 | from chromite.lib import cros_build_lib |
Greg Edelston | cd70b20 | 2023-09-14 14:04:12 -0600 | [diff] [blame] | 17 | from chromite.lib import path_util |
Navil Perez | e73734a | 2023-08-11 13:07:41 +0000 | [diff] [blame] | 18 | from chromite.lib import sysroot_lib |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [diff] [blame] | 19 | from chromite.service import sdk |
| 20 | |
| 21 | |
Alex Klein | 0996b46 | 2023-06-15 15:26:37 -0600 | [diff] [blame] | 22 | if TYPE_CHECKING: |
| 23 | from chromite.api import api_config |
| 24 | from chromite.api.gen.chromite.api import sdk_pb2 |
| 25 | |
| 26 | |
Alex Klein | 076841b | 2019-08-29 15:19:39 -0600 | [diff] [blame] | 27 | def _ChrootVersionResponse(_input_proto, output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 28 | """Add a fake chroot version to a successful response.""" |
| 29 | output_proto.version.version = 168 |
Alex Klein | 076841b | 2019-08-29 15:19:39 -0600 | [diff] [blame] | 30 | |
| 31 | |
Bob Haarman | 171d409 | 2023-01-10 16:44:19 +0000 | [diff] [blame] | 32 | def _BinhostCLs(_input_proto, output_proto, _config): |
| 33 | """Add fake CL identifiers to a successful response.""" |
Bob Haarman | c008260 | 2022-09-20 16:12:43 -0700 | [diff] [blame] | 34 | output_proto.cls = [ |
Bob Haarman | 171d409 | 2023-01-10 16:44:19 +0000 | [diff] [blame] | 35 | "fakecl:1", |
| 36 | "fakecl:2", |
Bob Haarman | c008260 | 2022-09-20 16:12:43 -0700 | [diff] [blame] | 37 | ] |
| 38 | |
| 39 | |
Bob Haarman | 0853ce9 | 2022-12-13 18:11:53 +0000 | [diff] [blame] | 40 | def _BuildSdkTarballResponse(_input_proto, output_proto, _config): |
| 41 | """Populate a fake BuildSdkTarballResponse.""" |
| 42 | output_proto.sdk_tarball_path.path = "/fake/sdk/tarball.tar.gz" |
| 43 | output_proto.sdk_tarball_path.location = common_pb2.Path.OUTSIDE |
| 44 | |
| 45 | |
| 46 | @faux.success(_BuildSdkTarballResponse) |
| 47 | @validate.require("chroot") |
| 48 | @validate.validation_complete |
| 49 | def BuildSdkTarball( |
Alex Klein | 0996b46 | 2023-06-15 15:26:37 -0600 | [diff] [blame] | 50 | input_proto: "sdk_pb2.BuildSdkTarballRequest", |
| 51 | output_proto: "sdk_pb2.BuildSdkTarballResponse", |
Bob Haarman | 0853ce9 | 2022-12-13 18:11:53 +0000 | [diff] [blame] | 52 | _config: "api_config.ApiConfig", |
| 53 | ) -> None: |
| 54 | chroot = controller_util.ParseChroot(input_proto.chroot) |
| 55 | output_proto.sdk_tarball_path.path = str(sdk.BuildSdkTarball(chroot)) |
| 56 | output_proto.sdk_tarball_path.location = common_pb2.Path.OUTSIDE |
| 57 | |
| 58 | |
Greg Edelston | 01ae594 | 2023-01-30 16:26:54 -0700 | [diff] [blame] | 59 | def _CreateManifestFromSdkResponse(_input_proto, output_proto, _config): |
| 60 | """Populate a fake CreateManifestFromSdkResponse.""" |
| 61 | output_proto.manifest_path.path = "/fake/sdk/tarball.tar.gz.Manifest" |
| 62 | output_proto.manifest_path.location = common_pb2.Path.Location.INSIDE |
| 63 | |
| 64 | |
| 65 | @faux.success(_CreateManifestFromSdkResponse) |
| 66 | @validate.require("chroot") |
| 67 | @validate.require("sdk_path") |
| 68 | @validate.require("dest_dir") |
| 69 | @validate.validation_complete |
| 70 | def CreateManifestFromSdk( |
Alex Klein | 0996b46 | 2023-06-15 15:26:37 -0600 | [diff] [blame] | 71 | input_proto: "sdk_pb2.CreateManifestFromSdkRequest", |
| 72 | output_proto: "sdk_pb2.CreateManifestFromSdkResponse", |
Greg Edelston | 01ae594 | 2023-01-30 16:26:54 -0700 | [diff] [blame] | 73 | _config: "api_config.ApiConfig", |
| 74 | ) -> None: |
| 75 | """Create a manifest file showing the ebuilds in an SDK.""" |
| 76 | |
| 77 | def _assert_path_is_absolute(path: str, name: str): |
| 78 | """Raise an exception if the given path is not absolute.""" |
| 79 | if not os.path.isabs(path): |
| 80 | cros_build_lib.Die(f"The {name} must be absolute; got {path}") |
| 81 | |
| 82 | _assert_path_is_absolute(input_proto.chroot.path, "chroot path") |
| 83 | _assert_path_is_absolute(input_proto.sdk_path.path, "SDK path") |
| 84 | _assert_path_is_absolute(input_proto.dest_dir.path, "destination directory") |
| 85 | |
Greg Edelston | 1f5deb6 | 2023-03-31 14:22:08 -0600 | [diff] [blame] | 86 | sdk_path = controller_util.pb2_path_to_pathlib_path( |
Greg Edelston | 01ae594 | 2023-01-30 16:26:54 -0700 | [diff] [blame] | 87 | input_proto.sdk_path, input_proto.chroot |
| 88 | ) |
Greg Edelston | 1f5deb6 | 2023-03-31 14:22:08 -0600 | [diff] [blame] | 89 | dest_dir = controller_util.pb2_path_to_pathlib_path( |
Greg Edelston | 01ae594 | 2023-01-30 16:26:54 -0700 | [diff] [blame] | 90 | input_proto.dest_dir, input_proto.chroot |
| 91 | ) |
| 92 | |
| 93 | manifest_path = sdk.CreateManifestFromSdk(sdk_path, dest_dir) |
| 94 | output_proto.manifest_path.path = str(manifest_path) |
| 95 | output_proto.manifest_path.location = common_pb2.Path.Location.OUTSIDE |
| 96 | |
| 97 | |
Alex Klein | 076841b | 2019-08-29 15:19:39 -0600 | [diff] [blame] | 98 | @faux.success(_ChrootVersionResponse) |
| 99 | @faux.empty_error |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 100 | def Create( |
Alex Klein | 0996b46 | 2023-06-15 15:26:37 -0600 | [diff] [blame] | 101 | input_proto: "sdk_pb2.CreateRequest", |
| 102 | output_proto: "sdk_pb2.CreateResponse", |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 103 | config: "api_config.ApiConfig", |
| 104 | ) -> Union[int, None]: |
| 105 | """Chroot creation, includes support for replacing an existing chroot. |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [diff] [blame] | 106 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 107 | Args: |
Alex Klein | 611dddd | 2022-10-11 17:02:01 -0600 | [diff] [blame] | 108 | input_proto: The input proto. |
| 109 | output_proto: The output proto. |
| 110 | config: The API call config. |
Kevin Shelton | 50dabff | 2022-04-09 11:29:53 -0700 | [diff] [blame] | 111 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 112 | Returns: |
Alex Klein | 611dddd | 2022-10-11 17:02:01 -0600 | [diff] [blame] | 113 | An error code, None otherwise. |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 114 | """ |
| 115 | replace = not input_proto.flags.no_replace |
| 116 | bootstrap = input_proto.flags.bootstrap |
Brian Norris | 67374d8 | 2023-05-01 12:31:12 -0700 | [diff] [blame] | 117 | chroot = controller_util.ParseChroot(input_proto.chroot) |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [diff] [blame] | 118 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 119 | sdk_version = input_proto.sdk_version |
| 120 | skip_chroot_upgrade = input_proto.skip_chroot_upgrade |
George Burgess IV | 6e04d60 | 2023-08-16 15:08:32 -0600 | [diff] [blame] | 121 | ccache_disable = input_proto.ccache_disable |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [diff] [blame] | 122 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 123 | if config.validate_only: |
| 124 | return controller.RETURN_CODE_VALID_INPUT |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 125 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 126 | args = sdk.CreateArguments( |
| 127 | replace=replace, |
| 128 | bootstrap=bootstrap, |
Brian Norris | 67374d8 | 2023-05-01 12:31:12 -0700 | [diff] [blame] | 129 | chroot=chroot, |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 130 | sdk_version=sdk_version, |
| 131 | skip_chroot_upgrade=skip_chroot_upgrade, |
George Burgess IV | 6e04d60 | 2023-08-16 15:08:32 -0600 | [diff] [blame] | 132 | ccache_disable=ccache_disable, |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 133 | ) |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [diff] [blame] | 134 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 135 | version = sdk.Create(args) |
Alex Klein | 19c4cc4 | 2019-02-27 14:47:57 -0700 | [diff] [blame] | 136 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 137 | if version: |
| 138 | output_proto.version.version = version |
| 139 | else: |
| 140 | # This should be very rare, if ever used, but worth noting. |
| 141 | cros_build_lib.Die( |
| 142 | "No chroot version could be found. There was likely an" |
| 143 | "error creating the chroot that was not detected." |
| 144 | ) |
Alex Klein | aa5c417 | 2019-02-27 17:12:20 -0700 | [diff] [blame] | 145 | |
| 146 | |
Alex Klein | 076841b | 2019-08-29 15:19:39 -0600 | [diff] [blame] | 147 | @faux.success(_ChrootVersionResponse) |
| 148 | @faux.empty_error |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 149 | @validate.require_each("toolchain_targets", ["name"]) |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 150 | @validate.validation_complete |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 151 | def Update( |
Alex Klein | 0996b46 | 2023-06-15 15:26:37 -0600 | [diff] [blame] | 152 | input_proto: "sdk_pb2.UpdateRequest", |
| 153 | output_proto: "sdk_pb2.UpdateResponse", |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 154 | _config: "api_config.ApiConfig", |
| 155 | ): |
| 156 | """Update the chroot. |
Alex Klein | aa5c417 | 2019-02-27 17:12:20 -0700 | [diff] [blame] | 157 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 158 | Args: |
Alex Klein | 611dddd | 2022-10-11 17:02:01 -0600 | [diff] [blame] | 159 | input_proto: The input proto. |
| 160 | output_proto: The output proto. |
| 161 | _config: The API call config. |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 162 | """ |
| 163 | build_source = input_proto.flags.build_source |
| 164 | targets = [target.name for target in input_proto.toolchain_targets] |
| 165 | toolchain_changed = input_proto.flags.toolchain_changed |
Alex Klein | aa5c417 | 2019-02-27 17:12:20 -0700 | [diff] [blame] | 166 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 167 | args = sdk.UpdateArguments( |
| 168 | build_source=build_source, |
| 169 | toolchain_targets=targets, |
| 170 | toolchain_changed=toolchain_changed, |
| 171 | ) |
Chris McDonald | 68faa2a | 2020-01-13 12:23:05 -0700 | [diff] [blame] | 172 | |
Navil Perez | e73734a | 2023-08-11 13:07:41 +0000 | [diff] [blame] | 173 | result = sdk.Update(args) |
| 174 | if result.success: |
| 175 | output_proto.version.version = result.version |
| 176 | elif result.failed_pkgs: |
| 177 | sysroot = sysroot_lib.Sysroot("/") |
| 178 | controller_util.retrieve_package_log_paths( |
| 179 | result.failed_pkgs, output_proto, sysroot |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 180 | ) |
Navil Perez | e73734a | 2023-08-11 13:07:41 +0000 | [diff] [blame] | 181 | return controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE |
| 182 | else: |
| 183 | return controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY |
Alex Klein | 730cf55 | 2019-10-16 11:28:22 -0600 | [diff] [blame] | 184 | |
| 185 | |
| 186 | @faux.all_empty |
Greg Edelston | 6733dc5 | 2023-02-15 15:20:07 -0700 | [diff] [blame] | 187 | @validate.require("binhost_gs_bucket") |
Greg Edelston | 0382ca4 | 2023-05-04 14:00:15 -0600 | [diff] [blame] | 188 | @validate.require("toolchain_tarball_template") |
Greg Edelston | 6733dc5 | 2023-02-15 15:20:07 -0700 | [diff] [blame] | 189 | @validate.validation_complete |
| 190 | def Uprev(input_proto, output_proto, _config): |
Greg Edelston | 40aea81 | 2023-03-27 16:34:35 -0600 | [diff] [blame] | 191 | """Update SDK version file and prebuilt files to point to the latest SDK. |
| 192 | |
| 193 | Files will be changed locally, but not committed. |
| 194 | """ |
| 195 | # If the UprevRequest did not specify a target version, |
| 196 | # check the remote SDK version file on Google Cloud Storage for the latest |
| 197 | # uprev target. |
Greg Edelston | d401e5a | 2023-04-28 15:29:11 -0600 | [diff] [blame] | 198 | target_version = ( |
| 199 | input_proto.version or sdk.get_latest_uprev_target_version() |
| 200 | ) |
Greg Edelston | 40aea81 | 2023-03-27 16:34:35 -0600 | [diff] [blame] | 201 | |
| 202 | # The main uprev logic occurs in service/sdk.py. |
Greg Edelston | d401e5a | 2023-04-28 15:29:11 -0600 | [diff] [blame] | 203 | modified_files = sdk.uprev_sdk_and_prebuilts( |
Greg Edelston | 6733dc5 | 2023-02-15 15:20:07 -0700 | [diff] [blame] | 204 | binhost_gs_bucket=input_proto.binhost_gs_bucket, |
Greg Edelston | 8bf6d4c | 2023-06-30 17:14:39 -0600 | [diff] [blame] | 205 | sdk_version=target_version, |
Greg Edelston | 0382ca4 | 2023-05-04 14:00:15 -0600 | [diff] [blame] | 206 | toolchain_tarball_template=input_proto.toolchain_tarball_template, |
Greg Edelston | 6733dc5 | 2023-02-15 15:20:07 -0700 | [diff] [blame] | 207 | ) |
Greg Edelston | 40aea81 | 2023-03-27 16:34:35 -0600 | [diff] [blame] | 208 | |
| 209 | # Populate the UprevResponse object with the modified files. |
Greg Edelston | 6733dc5 | 2023-02-15 15:20:07 -0700 | [diff] [blame] | 210 | for modified_file in modified_files: |
Greg Edelston | 40aea81 | 2023-03-27 16:34:35 -0600 | [diff] [blame] | 211 | proto_path = output_proto.modified_files.add() |
| 212 | proto_path.path = str(modified_file) |
| 213 | proto_path.location = common_pb2.Path.OUTSIDE |
Greg Edelston | 6733dc5 | 2023-02-15 15:20:07 -0700 | [diff] [blame] | 214 | output_proto.version = target_version |
| 215 | |
| 216 | |
| 217 | @faux.all_empty |
Alex Klein | 730cf55 | 2019-10-16 11:28:22 -0600 | [diff] [blame] | 218 | @validate.validation_complete |
| 219 | def Delete(input_proto, _output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 220 | """Delete a chroot.""" |
| 221 | chroot = controller_util.ParseChroot(input_proto.chroot) |
| 222 | sdk.Delete(chroot, force=True) |
Chris McDonald | 53ad544 | 2020-01-17 14:11:55 -0700 | [diff] [blame] | 223 | |
| 224 | |
| 225 | @faux.all_empty |
| 226 | @validate.validation_complete |
Brian Norris | f624bf4 | 2023-03-02 12:57:49 -0800 | [diff] [blame] | 227 | def Unmount(_input_proto, _output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 228 | """Unmount a chroot""" |
Brian Norris | f624bf4 | 2023-03-02 12:57:49 -0800 | [diff] [blame] | 229 | # Deprecated. Do nothing. |
Chris McDonald | f48ea20 | 2020-01-29 13:19:23 -0700 | [diff] [blame] | 230 | |
| 231 | |
| 232 | @faux.all_empty |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 233 | @validate.require("path.path") |
Michael Mortensen | 52a98ac | 2020-07-28 16:00:18 -0600 | [diff] [blame] | 234 | @validate.validation_complete |
| 235 | def UnmountPath(input_proto, _output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 236 | """Unmount a path""" |
| 237 | sdk.UnmountPath(input_proto.path.path) |
Michael Mortensen | 52a98ac | 2020-07-28 16:00:18 -0600 | [diff] [blame] | 238 | |
| 239 | |
| 240 | @faux.all_empty |
Chris McDonald | f48ea20 | 2020-01-29 13:19:23 -0700 | [diff] [blame] | 241 | @validate.validation_complete |
| 242 | def Clean(input_proto, _output_proto, _config): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 243 | """Clean unneeded files from a chroot.""" |
| 244 | chroot = controller_util.ParseChroot(input_proto.chroot) |
George Engelbrecht | 86cfae6 | 2023-04-05 10:57:41 -0600 | [diff] [blame] | 245 | |
| 246 | # Default (flagless) call sets 'safe' and 'sysroots'. |
| 247 | if not ( |
| 248 | input_proto.safe |
| 249 | or input_proto.images |
| 250 | or input_proto.sysroots |
| 251 | or input_proto.tmp |
| 252 | or input_proto.cache |
| 253 | or input_proto.logs |
| 254 | or input_proto.workdirs |
| 255 | or input_proto.incrementals |
| 256 | ): |
| 257 | sdk.Clean(chroot, safe=True, sysroots=True) |
| 258 | else: |
| 259 | sdk.Clean( |
| 260 | chroot, |
| 261 | safe=input_proto.safe, |
| 262 | images=input_proto.images, |
| 263 | sysroots=input_proto.sysroots, |
| 264 | tmp=input_proto.tmp, |
| 265 | cache=input_proto.cache, |
| 266 | logs=input_proto.logs, |
| 267 | workdirs=input_proto.workdirs, |
| 268 | incrementals=input_proto.incrementals, |
| 269 | ) |
Chris McDonald | 9d48680 | 2020-01-29 15:57:22 -0700 | [diff] [blame] | 270 | |
| 271 | |
| 272 | @faux.all_empty |
| 273 | @validate.validation_complete |
Greg Edelston | cd70b20 | 2023-09-14 14:04:12 -0600 | [diff] [blame] | 274 | def BuildPrebuilts(input_proto, output_proto, _config): |
| 275 | """Build the binary packages that comprise the Chromium OS SDK.""" |
| 276 | chroot = controller_util.ParseChroot(input_proto.chroot) |
| 277 | host_path, target_path = sdk.BuildPrebuilts( |
| 278 | chroot, |
| 279 | board=input_proto.build_target.name, |
| 280 | ) |
| 281 | # Convert paths to OUTSIDE, rather than using the ResultPath, to avoid |
| 282 | # unnecessary copying of several-gigabyte directories, and because |
| 283 | # ResultPath doesn't support returning multiple directories. |
| 284 | chroot_path_resolver = path_util.ChrootPathResolver( |
| 285 | chroot_path=Path(input_proto.chroot.path), |
| 286 | out_path=Path(input_proto.chroot.out_path), |
| 287 | ) |
| 288 | output_proto.host_prebuilts_path.path = str( |
| 289 | chroot_path_resolver.FromChroot(host_path), |
| 290 | ) |
| 291 | output_proto.host_prebuilts_path.location = common_pb2.Path.OUTSIDE |
| 292 | output_proto.target_prebuilts_path.path = str( |
| 293 | chroot_path_resolver.FromChroot(target_path), |
| 294 | ) |
| 295 | output_proto.target_prebuilts_path.location = common_pb2.Path.OUTSIDE |
Bob Haarman | d1225ea | 2022-01-19 22:01:42 +0000 | [diff] [blame] | 296 | |
| 297 | |
Bob Haarman | 171d409 | 2023-01-10 16:44:19 +0000 | [diff] [blame] | 298 | @faux.success(_BinhostCLs) |
Bob Haarman | c008260 | 2022-09-20 16:12:43 -0700 | [diff] [blame] | 299 | @faux.empty_error |
Bob Haarman | 0853ce9 | 2022-12-13 18:11:53 +0000 | [diff] [blame] | 300 | @validate.require( |
| 301 | "prepend_version", "version", "upload_location", "sdk_tarball_template" |
| 302 | ) |
Bob Haarman | d1225ea | 2022-01-19 22:01:42 +0000 | [diff] [blame] | 303 | @validate.validation_complete |
Bob Haarman | c008260 | 2022-09-20 16:12:43 -0700 | [diff] [blame] | 304 | def CreateBinhostCLs( |
Alex Klein | 0996b46 | 2023-06-15 15:26:37 -0600 | [diff] [blame] | 305 | input_proto: "sdk_pb2.CreateBinhostCLsRequest", |
| 306 | output_proto: "sdk_pb2.CreateBinhostCLsResponse", |
Bob Haarman | c008260 | 2022-09-20 16:12:43 -0700 | [diff] [blame] | 307 | _config: "api_config.ApiConfig", |
| 308 | ) -> None: |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 309 | """Create CLs to update the binhost to point at uploaded prebuilts.""" |
Bob Haarman | 171d409 | 2023-01-10 16:44:19 +0000 | [diff] [blame] | 310 | output_proto.cls.extend( |
| 311 | sdk.CreateBinhostCLs( |
| 312 | input_proto.prepend_version, |
| 313 | input_proto.version, |
| 314 | input_proto.upload_location, |
| 315 | input_proto.sdk_tarball_template, |
| 316 | ) |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 317 | ) |
Bob Haarman | 338f8b7 | 2022-02-04 01:02:46 +0000 | [diff] [blame] | 318 | |
| 319 | |
| 320 | @faux.all_empty |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 321 | @validate.require("prepend_version", "version", "upload_location") |
Bob Haarman | 338f8b7 | 2022-02-04 01:02:46 +0000 | [diff] [blame] | 322 | @validate.validation_complete |
Bob Haarman | d1225ea | 2022-01-19 22:01:42 +0000 | [diff] [blame] | 323 | def UploadPrebuiltPackages(input_proto, _output_proto, _config): |
Greg Edelston | 9dcdc8a | 2023-01-11 17:07:10 -0700 | [diff] [blame] | 324 | """Upload prebuilt packages.""" |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 325 | sdk.UploadPrebuiltPackages( |
| 326 | controller_util.ParseChroot(input_proto.chroot), |
| 327 | input_proto.prepend_version, |
| 328 | input_proto.version, |
| 329 | input_proto.upload_location, |
| 330 | ) |
Greg Edelston | 9dcdc8a | 2023-01-11 17:07:10 -0700 | [diff] [blame] | 331 | |
| 332 | |
| 333 | @faux.all_empty |
Greg Edelston | 9dcdc8a | 2023-01-11 17:07:10 -0700 | [diff] [blame] | 334 | @validate.validation_complete |
| 335 | def BuildSdkToolchain(input_proto, output_proto, _config): |
| 336 | """Build cross-compiler packages for the SDK.""" |
Greg Edelston | 9dcdc8a | 2023-01-11 17:07:10 -0700 | [diff] [blame] | 337 | extra_env: Dict[str, str] = {} |
| 338 | if input_proto.use_flags: |
| 339 | extra_env["USE"] = " ".join(use.flag for use in input_proto.use_flags) |
Greg Edelston | e265a17 | 2023-06-26 17:20:05 -0600 | [diff] [blame] | 340 | generated_files = sdk.BuildSdkToolchain(extra_env=extra_env) |
Greg Edelston | 9dcdc8a | 2023-01-11 17:07:10 -0700 | [diff] [blame] | 341 | output_proto.generated_files.extend(generated_files) |