blob: cd79b889bca5b87db1a10a68a136c485a7f658da [file] [log] [blame]
Mike Frysingerf1ba7ad2022-09-12 05:42:57 -04001# Copyright 2019 The ChromiumOS Authors
Alex Kleineb77ffa2019-05-28 14:47:44 -06002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Package related functionality."""
6
Chris McDonald1672ddb2021-07-21 11:48:23 -06007import logging
8
Alex Klein076841b2019-08-29 15:19:39 -06009from chromite.api import faux
David Burger1e0fe232019-07-01 14:52:07 -060010from chromite.api import validate
Alex Kleineb77ffa2019-05-28 14:47:44 -060011from chromite.api.controller import controller_util
12from chromite.api.gen.chromite.api import binhost_pb2
Alex Klein6becabc2020-09-11 14:03:05 -060013from chromite.api.gen.chromite.api import packages_pb2
David Burger1e0fe232019-07-01 14:52:07 -060014from chromite.api.gen.chromiumos import common_pb2
Alex Kleineb77ffa2019-05-28 14:47:44 -060015from chromite.lib import constants
16from chromite.lib import cros_build_lib
Michael Mortensenbbce7e42020-05-01 15:03:49 -060017from chromite.lib import portage_util
Alex Klein6becabc2020-09-11 14:03:05 -060018from chromite.lib.parser import package_info
Chris McDonald1672ddb2021-07-21 11:48:23 -060019from chromite.lib.uprev_lib import GitRef
Alex Kleineb77ffa2019-05-28 14:47:44 -060020from chromite.service import packages
21
22
23_OVERLAY_TYPE_TO_NAME = {
24 binhost_pb2.OVERLAYTYPE_PUBLIC: constants.PUBLIC_OVERLAYS,
25 binhost_pb2.OVERLAYTYPE_PRIVATE: constants.PRIVATE_OVERLAYS,
26 binhost_pb2.OVERLAYTYPE_BOTH: constants.BOTH_OVERLAYS,
27}
28
Alex Klein1699fab2022-09-08 08:46:06 -060029
Michael Mortensen2677bf62019-10-29 08:31:25 -060030def _UprevResponse(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -060031 """Add fake paths to a successful uprev response."""
32 output_proto.modified_ebuilds.add().path = "/fake/path1"
33 output_proto.modified_ebuilds.add().path = "/fake/path2"
34
Alex Kleineb77ffa2019-05-28 14:47:44 -060035
Michael Mortensen2677bf62019-10-29 08:31:25 -060036@faux.success(_UprevResponse)
37@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -060038@validate.require("overlay_type")
39@validate.is_in("overlay_type", _OVERLAY_TYPE_TO_NAME)
Alex Klein231d2da2019-07-22 16:44:45 -060040@validate.validation_complete
41def Uprev(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -060042 """Uprev all cros workon ebuilds that have changes."""
43 build_targets = controller_util.ParseBuildTargets(input_proto.build_targets)
44 overlay_type = _OVERLAY_TYPE_TO_NAME[input_proto.overlay_type]
45 chroot = controller_util.ParseChroot(input_proto.chroot)
46 output_dir = input_proto.output_dir or None
Alex Kleineb77ffa2019-05-28 14:47:44 -060047
Alex Klein1699fab2022-09-08 08:46:06 -060048 try:
49 modified_ebuilds, revved_packages = packages.uprev_build_targets(
50 build_targets, overlay_type, chroot, output_dir
51 )
52 except packages.Error as e:
53 # Handle module errors nicely, let everything else bubble up.
54 cros_build_lib.Die(e)
David Burger1e0fe232019-07-01 14:52:07 -060055
Alex Klein1699fab2022-09-08 08:46:06 -060056 for path in modified_ebuilds:
57 output_proto.modified_ebuilds.add().path = path
Alex Klein5dd6b1e2019-07-31 15:45:24 -060058
Alex Klein1699fab2022-09-08 08:46:06 -060059 for package in revved_packages:
60 pkg_info = package_info.parse(package)
61 pkg_proto = output_proto.packages.add()
62 controller_util.serialize_package_info(pkg_info, pkg_proto)
63
Alex Klein231d2da2019-07-22 16:44:45 -060064
Michael Mortensen2677bf62019-10-29 08:31:25 -060065def _UprevVersionedPackageResponse(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -060066 """Add fake paths to a successful uprev versioned package response."""
67 uprev_response = output_proto.responses.add()
68 uprev_response.modified_ebuilds.add().path = "/uprev/response/path"
Michael Mortensen2677bf62019-10-29 08:31:25 -060069
70
71@faux.success(_UprevVersionedPackageResponse)
72@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -060073@validate.require("versions")
74@validate.require("package_info.package_name", "package_info.category")
Alex Klein231d2da2019-07-22 16:44:45 -060075@validate.validation_complete
Alex Klein87531182019-08-12 15:23:37 -060076def UprevVersionedPackage(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -060077 """Uprev a versioned package.
Evan Hernandez38555d42019-08-05 15:11:54 -060078
Alex Klein1699fab2022-09-08 08:46:06 -060079 See go/pupr-generator for details about this endpoint.
80 """
81 chroot = controller_util.ParseChroot(input_proto.chroot)
82 build_targets = controller_util.ParseBuildTargets(input_proto.build_targets)
83 package = controller_util.PackageInfoToCPV(input_proto.package_info)
84 refs = []
85 for ref in input_proto.versions:
86 refs.append(
87 GitRef(path=ref.repository, ref=ref.ref, revision=ref.revision)
88 )
Alex Klein87531182019-08-12 15:23:37 -060089
Alex Klein1699fab2022-09-08 08:46:06 -060090 try:
91 result = packages.uprev_versioned_package(
92 package, build_targets, refs, chroot
93 )
94 except packages.Error as e:
95 # Handle module errors nicely, let everything else bubble up.
96 cros_build_lib.Die(e)
Alex Klein87531182019-08-12 15:23:37 -060097
Alex Klein1699fab2022-09-08 08:46:06 -060098 for modified in result.modified:
99 uprev_response = output_proto.responses.add()
100 uprev_response.version = modified.new_version
101 for path in modified.files:
102 uprev_response.modified_ebuilds.add().path = path
Alex Klein16ea1b32021-10-01 15:48:50 -0600103
104
105@faux.success(_UprevVersionedPackageResponse)
106@faux.empty_error
107@validate.validation_complete
108def RevBumpChrome(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600109 result = packages.revbump_chrome()
Alex Klein34afcbc2019-08-22 16:14:31 -0600110
Alex Klein1699fab2022-09-08 08:46:06 -0600111 for modified in result.modified:
112 uprev_response = output_proto.responses.add()
113 uprev_response.version = modified.new_version
114 for path in modified.files:
115 uprev_response.modified_ebuilds.add().path = path
Yaakov Shaul730814a2019-09-10 13:58:25 -0600116
Alex Klein87531182019-08-12 15:23:37 -0600117
Michael Mortensen2677bf62019-10-29 08:31:25 -0600118def _GetBestVisibleResponse(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600119 """Add fake paths to a successful GetBestVisible response."""
120 pkg_info_msg = common_pb2.PackageInfo(
121 category="category",
122 package_name="name",
123 version="1.01",
124 )
125 output_proto.package_info.CopyFrom(pkg_info_msg)
Michael Mortensen2677bf62019-10-29 08:31:25 -0600126
127
128@faux.success(_GetBestVisibleResponse)
129@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -0600130@validate.require("atom")
Alex Klein231d2da2019-07-22 16:44:45 -0600131@validate.validation_complete
132def GetBestVisible(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600133 """Returns the best visible PackageInfo for the indicated atom."""
134 build_target = None
135 if input_proto.build_target.name:
136 build_target = controller_util.ParseBuildTarget(
137 input_proto.build_target
138 )
Alex Kleinbbef2b32019-08-27 10:38:50 -0600139
Alex Klein1699fab2022-09-08 08:46:06 -0600140 best = packages.get_best_visible(
141 input_proto.atom, build_target=build_target
142 )
143 controller_util.serialize_package_info(best, output_proto.package_info)
Alex Klein551e8052019-08-29 11:23:48 -0600144
145
Michael Mortensen68abdb72019-10-28 09:43:52 -0600146def _ChromeVersionResponse(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600147 """Add a fake chrome version to a successful response."""
148 output_proto.version = "78.0.3900.0"
Michael Mortensen68abdb72019-10-28 09:43:52 -0600149
150
151@faux.success(_ChromeVersionResponse)
152@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -0600153@validate.require("build_target.name")
Alex Klein551e8052019-08-29 11:23:48 -0600154@validate.validation_complete
155def GetChromeVersion(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600156 """Returns the chrome version."""
157 build_target = controller_util.ParseBuildTarget(input_proto.build_target)
158 chrome_version = packages.determine_chrome_version(build_target)
159 if chrome_version:
160 output_proto.version = chrome_version
Alex Kleinda39c6d2019-09-16 14:36:36 -0600161
162
Michael Mortensen2677bf62019-10-29 08:31:25 -0600163def _GetTargetVersionsResponse(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600164 """Add fake target version fields to a successful response."""
165 output_proto.android_version = "5812377"
166 output_proto.android_branch_version = "git_nyc-mr1-arc"
167 output_proto.android_target_version = "cheets"
168 output_proto.chrome_version = "78.0.3900.0"
169 output_proto.platform_version = "12438.0.0"
170 output_proto.milestone_version = "78"
171 output_proto.full_version = "R78-12438.0.0"
Michael Mortensen2677bf62019-10-29 08:31:25 -0600172
173
174@faux.success(_GetTargetVersionsResponse)
175@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -0600176@validate.require("build_target.name")
177@validate.require_each("packages", ["category", "package_name"])
Michael Mortensenb70e8a82019-10-10 18:43:41 -0600178@validate.validation_complete
179def GetTargetVersions(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600180 """Returns the target versions."""
181 build_target = controller_util.ParseBuildTarget(input_proto.build_target)
182 package_list = [
183 controller_util.PackageInfoToCPV(x) for x in input_proto.packages or []
184 ]
185 target_versions = packages.get_target_versions(build_target, package_list)
Alex Klein445ae3c2020-01-08 16:40:43 -0700186
Alex Klein1699fab2022-09-08 08:46:06 -0600187 output_proto.android_version = target_versions.android_version or ""
188 output_proto.android_branch_version = target_versions.android_branch or ""
189 output_proto.android_target_version = target_versions.android_target or ""
190 output_proto.chrome_version = target_versions.chrome_version or ""
191 output_proto.platform_version = target_versions.platform_version or ""
192 output_proto.milestone_version = target_versions.milestone_version or ""
193 output_proto.full_version = target_versions.full_version or ""
Michael Mortensenb70e8a82019-10-10 18:43:41 -0600194
195
Michael Mortensenbfc56392020-04-30 15:23:47 -0600196def _GetBuilderMetadataResponse(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600197 """Add fake metadata fields to a successful response."""
198 # Populate only a few fields to validate faux testing.
199 build_target_metadata = output_proto.build_target_metadata.add()
200 build_target_metadata.build_target = input_proto.build_target.name
201 build_target_metadata.android_container_branch = "git_pi-arc"
202 model_metadata = output_proto.model_metadata.add()
203 model_metadata.model_name = "astronaut"
204 model_metadata.ec_firmware_version = "coral_v1.1.1234-56789f"
Michael Mortensenbfc56392020-04-30 15:23:47 -0600205
206
207@faux.success(_GetBuilderMetadataResponse)
208@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -0600209@validate.require("build_target.name")
Michael Mortensenbfc56392020-04-30 15:23:47 -0600210@validate.validation_complete
211def GetBuilderMetadata(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600212 """Returns the target builder metadata."""
213 build_target = controller_util.ParseBuildTarget(input_proto.build_target)
214 build_target_metadata = output_proto.build_target_metadata.add()
215 build_target_metadata.build_target = build_target.name
216 # Android version.
217 android_version = packages.determine_android_version(build_target.name)
218 logging.info("Found android version: %s", android_version)
219 if android_version:
220 build_target_metadata.android_container_version = android_version
221 # Android branch version.
222 android_branch_version = packages.determine_android_branch(
223 build_target.name
224 )
225 logging.info("Found android branch version: %s", android_branch_version)
226 if android_branch_version:
227 build_target_metadata.android_container_branch = android_branch_version
228 # Android target version.
229 android_target_version = packages.determine_android_target(
230 build_target.name
231 )
232 logging.info("Found android target version: %s", android_target_version)
233 if android_target_version:
234 build_target_metadata.android_container_target = android_target_version
Michael Mortensenbbce7e42020-05-01 15:03:49 -0600235
Alex Klein1699fab2022-09-08 08:46:06 -0600236 build_target_metadata.arc_use_set = "arc" in portage_util.GetBoardUseFlags(
237 build_target.name
238 )
Michael Mortensenbbce7e42020-05-01 15:03:49 -0600239
Alex Klein1699fab2022-09-08 08:46:06 -0600240 fw_versions = packages.determine_firmware_versions(build_target)
241 build_target_metadata.main_firmware_version = (
242 fw_versions.main_fw_version or ""
243 )
244 build_target_metadata.ec_firmware_version = fw_versions.ec_fw_version or ""
Benjamin Shai0858cd32022-01-10 20:23:49 +0000245
Alex Klein1699fab2022-09-08 08:46:06 -0600246 build_target_metadata.kernel_version = (
247 packages.determine_kernel_version(build_target) or ""
248 )
249 fingerprints = packages.find_fingerprints(build_target)
250 build_target_metadata.fingerprints.extend(fingerprints)
Michael Mortensenbfc56392020-04-30 15:23:47 -0600251
Alex Klein1699fab2022-09-08 08:46:06 -0600252 models = packages.get_models(build_target)
253 if models:
254 all_fw_versions = packages.get_all_firmware_versions(build_target)
255 for model in models:
256 if model in all_fw_versions:
257 fw_versions = all_fw_versions[model]
258 ec = fw_versions.ec_rw or fw_versions.ec
259 main_ro = fw_versions.main
260 main_rw = fw_versions.main_rw or main_ro
261 # Get the firmware key-id for the current board and model.
262 key_id = packages.get_key_id(build_target, model)
263 model_metadata = output_proto.model_metadata.add()
264 model_metadata.model_name = model
265 model_metadata.ec_firmware_version = ec or ""
266 model_metadata.firmware_key_id = key_id
267 model_metadata.main_readonly_firmware_version = main_ro or ""
268 model_metadata.main_readwrite_firmware_version = main_rw or ""
Michael Mortensen770bc122020-05-27 17:53:30 -0600269
270
Alex Klein7d66c092020-03-23 15:13:18 -0600271def _HasPrebuiltSuccess(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600272 """The mock success case for HasChromePrebuilt."""
273 output_proto.has_prebuilt = True
Michael Mortensen68abdb72019-10-28 09:43:52 -0600274
275
Alex Klein7d66c092020-03-23 15:13:18 -0600276@faux.success(_HasPrebuiltSuccess)
Alex Kleinda39c6d2019-09-16 14:36:36 -0600277@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -0600278@validate.require("build_target.name")
Alex Kleinda39c6d2019-09-16 14:36:36 -0600279@validate.validation_complete
280def HasChromePrebuilt(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600281 """Checks if the most recent version of Chrome has a prebuilt."""
282 build_target = controller_util.ParseBuildTarget(input_proto.build_target)
283 useflags = "chrome_internal" if input_proto.chrome else None
284 exists = packages.has_prebuilt(
285 constants.CHROME_CP, build_target=build_target, useflags=useflags
286 )
Alex Kleinda39c6d2019-09-16 14:36:36 -0600287
Alex Klein1699fab2022-09-08 08:46:06 -0600288 output_proto.has_prebuilt = exists
Alex Klein73fb6572019-09-30 16:55:23 -0600289
290
Alex Klein7d66c092020-03-23 15:13:18 -0600291@faux.success(_HasPrebuiltSuccess)
292@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -0600293@validate.require(
294 "build_target.name", "package_info.category", "package_info.package_name"
295)
Alex Klein7d66c092020-03-23 15:13:18 -0600296@validate.validation_complete
297def HasPrebuilt(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600298 """Checks if the most recent version of Chrome has a prebuilt."""
299 build_target = controller_util.ParseBuildTarget(input_proto.build_target)
300 package = controller_util.PackageInfoToCPV(input_proto.package_info).cp
301 useflags = "chrome_internal" if input_proto.chrome else None
302 exists = packages.has_prebuilt(
303 package, build_target=build_target, useflags=useflags
304 )
Alex Klein7d66c092020-03-23 15:13:18 -0600305
Alex Klein1699fab2022-09-08 08:46:06 -0600306 output_proto.has_prebuilt = exists
Alex Klein7d66c092020-03-23 15:13:18 -0600307
308
Alex Klein73fb6572019-09-30 16:55:23 -0600309def _BuildsChromeSuccess(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600310 """Mock success case for BuildsChrome."""
311 output_proto.builds_chrome = True
Alex Klein73fb6572019-09-30 16:55:23 -0600312
313
314@faux.success(_BuildsChromeSuccess)
315@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -0600316@validate.require("build_target.name")
317@validate.require_each("packages", ["category", "package_name"])
Alex Klein73fb6572019-09-30 16:55:23 -0600318@validate.validation_complete
319def BuildsChrome(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600320 """Check if the board builds chrome."""
321 build_target = controller_util.ParseBuildTarget(input_proto.build_target)
322 cpvs = [controller_util.PackageInfoToCPV(pi) for pi in input_proto.packages]
323 builds_chrome = packages.builds(constants.CHROME_CP, build_target, cpvs)
324 output_proto.builds_chrome = builds_chrome
Alex Klein6becabc2020-09-11 14:03:05 -0600325
326
327def _NeedsChromeSourceSuccess(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600328 """Mock success case for NeedsChromeSource."""
329 output_proto.needs_chrome_source = True
330 output_proto.builds_chrome = True
Alex Klein6becabc2020-09-11 14:03:05 -0600331
Alex Klein1699fab2022-09-08 08:46:06 -0600332 output_proto.reasons.append(
333 packages_pb2.NeedsChromeSourceResponse.NO_PREBUILT
334 )
Alex Klein6becabc2020-09-11 14:03:05 -0600335 pkg_info_msg = output_proto.packages.add()
Alex Klein1699fab2022-09-08 08:46:06 -0600336 pkg_info_msg.category = constants.CHROME_CN
337 pkg_info_msg.package_name = constants.CHROME_PN
338
339 output_proto.reasons.append(
340 packages_pb2.NeedsChromeSourceResponse.FOLLOWER_LACKS_PREBUILT
341 )
342 for pkg in constants.OTHER_CHROME_PACKAGES:
343 pkg_info_msg = output_proto.packages.add()
344 pkg_info = package_info.parse(pkg)
345 controller_util.serialize_package_info(pkg_info, pkg_info_msg)
Alex Klein6becabc2020-09-11 14:03:05 -0600346
347
348@faux.success(_NeedsChromeSourceSuccess)
349@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -0600350@validate.require("install_request.sysroot.build_target.name")
351@validate.exists("install_request.sysroot.path")
Alex Klein6becabc2020-09-11 14:03:05 -0600352@validate.validation_complete
353def NeedsChromeSource(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600354 """Check if the build will need the chrome source."""
355 # Input parsing.
356 build_target = controller_util.ParseBuildTarget(
357 input_proto.install_request.sysroot.build_target
358 )
359 compile_source = (
360 input_proto.install_request.flags.compile_source
361 or input_proto.install_request.flags.toolchain_changed
362 )
363 pkgs = [
364 controller_util.deserialize_package_info(pi)
365 for pi in input_proto.install_request.packages
366 ]
367 use_flags = [f.flag for f in input_proto.install_request.use_flags]
Alex Klein6becabc2020-09-11 14:03:05 -0600368
Alex Klein1699fab2022-09-08 08:46:06 -0600369 result = packages.needs_chrome_source(
370 build_target,
371 compile_source=compile_source,
372 packages=pkgs,
373 useflags=use_flags,
374 )
Alex Klein6becabc2020-09-11 14:03:05 -0600375
Alex Klein1699fab2022-09-08 08:46:06 -0600376 # Record everything in the response.
377 output_proto.needs_chrome_source = result.needs_chrome_source
378 output_proto.builds_chrome = result.builds_chrome
Alex Klein6becabc2020-09-11 14:03:05 -0600379
Alex Klein1699fab2022-09-08 08:46:06 -0600380 # Compile source reason.
381 if compile_source:
382 output_proto.reasons.append(
383 packages_pb2.NeedsChromeSourceResponse.COMPILE_SOURCE
384 )
Alex Klein6becabc2020-09-11 14:03:05 -0600385
Alex Klein1699fab2022-09-08 08:46:06 -0600386 # Local uprev reason.
387 if result.local_uprev:
388 output_proto.reasons.append(
389 packages_pb2.NeedsChromeSourceResponse.LOCAL_UPREV
390 )
Alex Klein9ce3f682021-06-23 15:06:44 -0600391
Alex Klein1699fab2022-09-08 08:46:06 -0600392 # No chrome prebuilt reason.
393 if result.missing_chrome_prebuilt:
394 output_proto.reasons.append(
395 packages_pb2.NeedsChromeSourceResponse.NO_PREBUILT
396 )
Alex Klein6becabc2020-09-11 14:03:05 -0600397
Alex Klein1699fab2022-09-08 08:46:06 -0600398 # Follower package(s) lack prebuilt reason.
399 if result.missing_follower_prebuilt:
400 output_proto.reasons.append(
401 packages_pb2.NeedsChromeSourceResponse.FOLLOWER_LACKS_PREBUILT
402 )
Alex Klein6becabc2020-09-11 14:03:05 -0600403
Alex Klein1699fab2022-09-08 08:46:06 -0600404 for pkg in result.packages:
405 pkg_info = output_proto.packages.add()
406 controller_util.serialize_package_info(pkg, pkg_info)
Shao-Chuan Leeeb834a32021-05-12 17:10:55 +0900407
408
409def _GetAndroidMetadataResponse(_input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600410 """Mock Android metadata on successful run."""
411 output_proto.android_package = "android-vm-rvc"
412 output_proto.android_branch = "git_rvc-arc"
413 output_proto.android_version = "7123456"
Shao-Chuan Leeeb834a32021-05-12 17:10:55 +0900414
415
416@faux.success(_GetAndroidMetadataResponse)
417@faux.empty_error
Alex Klein1699fab2022-09-08 08:46:06 -0600418@validate.require("build_target.name")
Shao-Chuan Leeeb834a32021-05-12 17:10:55 +0900419@validate.validation_complete
420def GetAndroidMetadata(input_proto, output_proto, _config):
Alex Klein1699fab2022-09-08 08:46:06 -0600421 """Returns Android-related metadata."""
422 build_target = controller_util.ParseBuildTarget(input_proto.build_target)
423 # This returns a full CPVR string, e.g.
424 # 'chromeos-base/android-vm-rvc-7336577-r1'
425 android_full_package = packages.determine_android_package(build_target.name)
426 if android_full_package:
427 logging.info("Found Android package: %s", android_full_package)
428 info = package_info.parse(android_full_package)
429 output_proto.android_package = info.package
Shao-Chuan Leeeb834a32021-05-12 17:10:55 +0900430
Alex Klein1699fab2022-09-08 08:46:06 -0600431 android_branch = packages.determine_android_branch(
432 build_target.name, package=android_full_package
433 )
434 logging.info("Found Android branch: %s", android_branch)
435 output_proto.android_branch = android_branch
Shao-Chuan Leeeb834a32021-05-12 17:10:55 +0900436
Alex Klein1699fab2022-09-08 08:46:06 -0600437 android_version = packages.determine_android_version(
438 build_target.name, package=android_full_package
439 )
440 logging.info("Found Android version: %s", android_version)
441 output_proto.android_version = android_version