blob: 83205231a632ad1f19252ba689cdd5b43dbb88ea [file] [log] [blame]
Mike Frysingerf1ba7ad2022-09-12 05:42:57 -04001# Copyright 2016 The ChromiumOS Authors
David Rileyc0da9d92016-02-01 12:11:01 -08002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""This module uprevs Android for cbuildbot.
6
Shao-Chuan Lee84bf9a22021-11-19 17:42:11 +09007After calling, it prints out a JSON representing the result, with the new
8Android version atom string included. A caller could then use this atom with
9emerge to build the newly uprevved version of Android e.g.
David Rileyc0da9d92016-02-01 12:11:01 -080010
Shuhei Takahashi6d02c192017-04-05 14:01:24 +090011./cros_mark_android_as_stable \
Shao-Chuan Lee9c39e0c2020-04-24 11:40:34 +090012 --android_build_branch=git_pi-arc \
13 --android_package=android-container-pi
Shuhei Takahashi6d02c192017-04-05 14:01:24 +090014
Shao-Chuan Lee84bf9a22021-11-19 17:42:11 +090015Returns {"android_atom": "chromeos-base/android-container-pi-6417892-r1"}
David Rileyc0da9d92016-02-01 12:11:01 -080016
Shao-Chuan Lee9c39e0c2020-04-24 11:40:34 +090017emerge-eve =chromeos-base/android-container-pi-6417892-r1
David Rileyc0da9d92016-02-01 12:11:01 -080018"""
19
David Rileyc0da9d92016-02-01 12:11:01 -080020import filecmp
21import glob
Junichi Uekawad21f94d2020-07-27 15:50:05 +090022import json
Chris McDonaldb55b7032021-06-17 16:41:32 -060023import logging
David Rileyc0da9d92016-02-01 12:11:01 -080024import os
25
Chris McDonaldb55b7032021-06-17 16:41:32 -060026from chromite.cbuildbot import cbuildbot_alerts
David Rileyc0da9d92016-02-01 12:11:01 -080027from chromite.lib import commandline
Chris McDonaldb55b7032021-06-17 16:41:32 -060028from chromite.lib import constants
David Rileyc0da9d92016-02-01 12:11:01 -080029from chromite.lib import cros_build_lib
David Rileyc0da9d92016-02-01 12:11:01 -080030from chromite.lib import git
31from chromite.lib import gs
Shao-Chuan Lee301a4192021-02-08 11:53:49 +090032from chromite.lib import osutils
David Rileyc0da9d92016-02-01 12:11:01 -080033from chromite.lib import portage_util
Shao-Chuan Lee007dbe82021-02-09 14:05:39 +090034from chromite.lib import repo_util
David Rileyc0da9d92016-02-01 12:11:01 -080035from chromite.scripts import cros_mark_as_stable
Shao-Chuan Lee7fd0ca12021-03-19 15:57:40 +090036from chromite.service import android
David Rileyc0da9d92016-02-01 12:11:01 -080037
38
39# Dir where all the action happens.
Alex Klein1699fab2022-09-08 08:46:06 -060040_OVERLAY_DIR = "%(srcroot)s/private-overlays/project-cheets-private/"
David Rileyc0da9d92016-02-01 12:11:01 -080041
Junichi Uekawa6d61ab02020-04-15 14:52:28 +090042_GIT_COMMIT_MESSAGE = """Marking latest for %(android_package)s ebuild with \
43version %(android_version)s as stable.
44
45BUG=None
46TEST=CQ
47"""
David Rileyc0da9d92016-02-01 12:11:01 -080048
Shao-Chuan Lee3aa76522021-12-03 17:18:58 +090049_GIT_COMMIT_MESSAGE_LKGB = """%(android_package)s: Mark version \
50%(android_version)s as LKGB.
51
52Generated by Android PFQ. This change will trigger PUpr to actually submit an
53Android uprev.
54
55For details, see "Migration plan" section of go/android-uprev-recipes.
56
57BUG=None
58TEST=CQ
59"""
60
Alex Klein1699fab2022-09-08 08:46:06 -060061_RUNTIME_ARTIFACTS_BUCKET_URL = "gs://chromeos-arc-images/runtime_artifacts"
David Rileyc0da9d92016-02-01 12:11:01 -080062
David Rileyc0da9d92016-02-01 12:11:01 -080063
64def FindAndroidCandidates(package_dir):
Alex Klein1699fab2022-09-08 08:46:06 -060065 """Return a tuple of Android's unstable ebuild and stable ebuilds.
David Rileyc0da9d92016-02-01 12:11:01 -080066
Alex Klein1699fab2022-09-08 08:46:06 -060067 Args:
68 package_dir: The path to where the package ebuild is stored.
David Rileyc0da9d92016-02-01 12:11:01 -080069
Alex Klein1699fab2022-09-08 08:46:06 -060070 Returns:
71 Tuple [unstable_ebuild, stable_ebuilds].
David Rileyc0da9d92016-02-01 12:11:01 -080072
Alex Klein1699fab2022-09-08 08:46:06 -060073 Raises:
74 Exception: if no unstable ebuild exists for Android.
75 """
76 stable_ebuilds = []
77 unstable_ebuilds = []
78 for path in glob.glob(os.path.join(package_dir, "*.ebuild")):
79 ebuild = portage_util.EBuild(path)
80 if ebuild.version == "9999":
81 unstable_ebuilds.append(ebuild)
82 else:
83 stable_ebuilds.append(ebuild)
David Rileyc0da9d92016-02-01 12:11:01 -080084
Alex Klein1699fab2022-09-08 08:46:06 -060085 # Apply some confidence checks.
86 if not unstable_ebuilds:
87 raise Exception("Missing 9999 ebuild for %s" % package_dir)
88 if not stable_ebuilds:
89 logging.warning("Missing stable ebuild for %s", package_dir)
David Rileyc0da9d92016-02-01 12:11:01 -080090
Alex Klein1699fab2022-09-08 08:46:06 -060091 return portage_util.BestEBuild(unstable_ebuilds), stable_ebuilds
David Rileyc0da9d92016-02-01 12:11:01 -080092
93
Shao-Chuan Lee085e3d72020-05-11 16:00:42 +090094def PrintUprevMetadata(build_branch, stable_candidate, new_ebuild):
Alex Klein1699fab2022-09-08 08:46:06 -060095 """Shows metadata on buildbot page at UprevAndroid step.
David Rileyc0da9d92016-02-01 12:11:01 -080096
Alex Klein1699fab2022-09-08 08:46:06 -060097 Args:
98 build_branch: The branch of Android builds.
99 stable_candidate: The existing stable ebuild.
100 new_ebuild: The newly written ebuild.
David Rileyc0da9d92016-02-01 12:11:01 -0800101 """
Alex Klein1699fab2022-09-08 08:46:06 -0600102 # Examples:
103 # "android-container-pi revved 6461825-r1 -> 6468247-r1"
104 # "android-container-pi revved 6461825-r1 -> 6461825-r2 (ebuild update only)"
105 msg = "%s revved %s -> %s" % (
106 stable_candidate.pkgname,
107 stable_candidate.version,
108 new_ebuild.version,
109 )
David Rileyc0da9d92016-02-01 12:11:01 -0800110
Alex Klein1699fab2022-09-08 08:46:06 -0600111 old_android = stable_candidate.version_no_rev
112 new_android = new_ebuild.version_no_rev
David Rileyc0da9d92016-02-01 12:11:01 -0800113
Alex Klein1699fab2022-09-08 08:46:06 -0600114 if old_android == new_android:
115 msg += " (ebuild update only)"
116 else:
117 ab_link = (
118 "https://android-build.googleplex.com"
119 "/builds/%s/branches/%s/cls?end=%s"
120 % (new_android, build_branch, old_android)
121 )
122 cbuildbot_alerts.PrintBuildbotLink("Android changelog", ab_link)
David Rileyc0da9d92016-02-01 12:11:01 -0800123
Alex Klein1699fab2022-09-08 08:46:06 -0600124 cbuildbot_alerts.PrintBuildbotStepText(msg)
125 cbuildbot_alerts.PrintKitchenSetBuildProperty(
126 "android_uprev",
127 json.dumps(
128 {
129 "branch": build_branch,
130 "new": new_ebuild.version,
131 "old": stable_candidate.version,
132 "pkgname": stable_candidate.pkgname,
133 }
134 ),
135 )
David Rileyc0da9d92016-02-01 12:11:01 -0800136
khmel@chromium.orgd3ec3d72020-04-29 15:57:35 -0700137
Alex Klein1699fab2022-09-08 08:46:06 -0600138def FindDataCollectorArtifacts(
139 gs_context, android_version, runtime_artifacts_bucket_url, version_reference
140):
141 r"""Finds and includes into variables artifacts from arc.DataCollector.
David Rileyc0da9d92016-02-01 12:11:01 -0800142
Alex Klein1699fab2022-09-08 08:46:06 -0600143 This is used from UpdateDataCollectorArtifacts in order to check the
144 particular version.
David Rileyc0da9d92016-02-01 12:11:01 -0800145
Alex Klein1699fab2022-09-08 08:46:06 -0600146 Args:
147 gs_context: context to execute gsutil
148 android_version: The \d+ build id of Android.
149 runtime_artifacts_bucket_url: root of runtime artifacts
150 build_branch: build branch. Used to determine the pinned version if exists.
151 version_reference: which version to use as a reference. Could be '${PV}' in
152 case version of data collector artifacts matches the
153 Android version or direct version in case of override.
David Rileyc0da9d92016-02-01 12:11:01 -0800154
Alex Klein1699fab2022-09-08 08:46:06 -0600155 Returns:
156 dictionary with filled ebuild variables. This dictionary is empty in case
157 no artificats are found.
158 """
159 variables = {}
David Rileyc0da9d92016-02-01 12:11:01 -0800160
Alex Klein1699fab2022-09-08 08:46:06 -0600161 buckets = ["ureadahead_pack", "gms_core_cache", "tts_cache"]
162 archs = ["arm", "arm64", "x86", "x86_64"]
163 build_types = ["user", "userdebug"]
David Rileyc0da9d92016-02-01 12:11:01 -0800164
Alex Klein1699fab2022-09-08 08:46:06 -0600165 for bucket in buckets:
166 for arch in archs:
167 for build_type in build_types:
168 path = (
169 f"{runtime_artifacts_bucket_url}/{bucket}_{arch}_{build_type}_"
170 f"{android_version}.tar"
171 )
172 if gs_context.Exists(path):
173 variables[(f"{arch}_{build_type}_{bucket}").upper()] = (
174 f"{runtime_artifacts_bucket_url}/{bucket}_{arch}_{build_type}_"
175 f"{version_reference}.tar"
176 )
177
178 return variables
179
180
181def UpdateDataCollectorArtifacts(
182 android_version, runtime_artifacts_bucket_url, build_branch
183):
184 r"""Finds and includes into variables artifacts from arc.DataCollector.
185
186 This verifies default android version. In case artificts are not found for
187 default Android version it tries to find artifacts for pinned version. If
188 pinned version is provided, it is required artifacts exist for the pinned
189 version.
190
191 Args:
192 android_version: The \d+ build id of Android.
193 runtime_artifacts_bucket_url: root of runtime artifacts
194 build_branch: build branch. Used to determine the pinned version if exists.
195
196 Returns:
197 dictionary with filled ebuild variables.
198 """
199
200 gs_context = gs.GSContext()
201 # Check the existing version. If we find any artifacts, use them.
202 variables = FindDataCollectorArtifacts(
203 gs_context, android_version, runtime_artifacts_bucket_url, "${PV}"
204 )
205 if variables:
206 # Data artificts were found.
207 return variables
208
209 # Check pinned version for the current branch.
210 pin_path = f"{runtime_artifacts_bucket_url}/{build_branch}_pin_version"
211 if not gs_context.Exists(pin_path):
212 # No pinned version.
213 logging.warning(
214 "No data collector artifacts were found for %s", android_version
215 )
216 return variables
217
218 pin_version = gs_context.Cat(pin_path, encoding="utf-8").rstrip()
219 logging.info("Pinned version %s overrides %s", pin_version, android_version)
220 variables = FindDataCollectorArtifacts(
221 gs_context, pin_version, runtime_artifacts_bucket_url, pin_version
222 )
223 if not variables:
224 # If pin version set it must contain data.
225 raise Exception(
226 "Pinned version %s:%s does not contain artificats"
227 % (build_branch, pin_version)
228 )
229
230 return variables
231
232
233def MarkAndroidEBuildAsStable(
234 stable_candidate,
235 unstable_ebuild,
236 android_package,
237 android_version,
238 package_dir,
239 build_branch,
240 arc_bucket_url,
241 runtime_artifacts_bucket_url,
242):
243 r"""Uprevs the Android ebuild.
244
245 This is the main function that uprevs from a stable candidate
246 to its new version.
247
248 Args:
249 stable_candidate: ebuild that corresponds to the stable ebuild we are
250 revving from. If None, builds the a new ebuild given the version
251 with revision set to 1.
252 unstable_ebuild: ebuild corresponding to the unstable ebuild for Android.
253 android_package: android package name.
254 android_version: The \d+ build id of Android.
255 package_dir: Path to the android-container package dir.
256 build_branch: branch of Android builds.
257 arc_bucket_url: URL of the target ARC build gs bucket.
258 runtime_artifacts_bucket_url: root of runtime artifacts
259
260 Returns:
261 Tuple[str, List[str], List[str]] if revved, or None
262 1. Full portage version atom (including rc's, etc) that was revved.
263 2. List of files to be `git add`ed.
264 3. List of files to be `git rm`ed.
265 """
266
267 def IsTheNewEBuildRedundant(new_ebuild, stable_ebuild):
268 """Returns True if the new ebuild is redundant.
269
270 This is True if there if the current stable ebuild is the exact same copy
271 of the new one.
272 """
273 if not stable_ebuild:
274 return False
275
276 if stable_candidate.version_no_rev == new_ebuild.version_no_rev:
277 return filecmp.cmp(
278 new_ebuild.ebuild_path, stable_ebuild.ebuild_path, shallow=False
279 )
280 return False
281
282 # Case where we have the last stable candidate with same version just rev.
283 if stable_candidate and stable_candidate.version_no_rev == android_version:
284 new_ebuild_path = "%s-r%d.ebuild" % (
285 stable_candidate.ebuild_path_no_revision,
286 stable_candidate.current_revision + 1,
287 )
288 else:
289 pf = "%s-%s-r1" % (android_package, android_version)
290 new_ebuild_path = os.path.join(package_dir, "%s.ebuild" % pf)
291
292 build_targets = constants.ANDROID_BRANCH_TO_BUILD_TARGETS[build_branch]
293 variables = {"BASE_URL": arc_bucket_url}
294 for var, target in build_targets.items():
295 variables[var] = f"{build_branch}-linux-{target}"
296
297 variables.update(
298 UpdateDataCollectorArtifacts(
299 android_version, runtime_artifacts_bucket_url, build_branch
300 )
301 )
302
303 portage_util.EBuild.MarkAsStable(
304 unstable_ebuild.ebuild_path,
305 new_ebuild_path,
306 variables,
307 make_stable=True,
308 )
309 new_ebuild = portage_util.EBuild(new_ebuild_path)
310
311 # Determine whether this is ebuild is redundant.
312 if IsTheNewEBuildRedundant(new_ebuild, stable_candidate):
313 msg = "Previous ebuild with same version found and ebuild is redundant."
314 logging.info(msg)
315 cbuildbot_alerts.PrintBuildbotStepText(
316 "%s %s not revved"
317 % (stable_candidate.pkgname, stable_candidate.version)
318 )
319 osutils.SafeUnlink(new_ebuild_path)
320 return None
321
322 # PFQ runs should always be able to find a stable candidate.
323 if stable_candidate:
324 PrintUprevMetadata(build_branch, stable_candidate, new_ebuild)
325
326 files_to_add = [new_ebuild_path]
327 files_to_remove = []
328 if stable_candidate and not stable_candidate.IsSticky():
329 osutils.SafeUnlink(stable_candidate.ebuild_path)
330 files_to_remove.append(stable_candidate.ebuild_path)
331
332 # Update ebuild manifest and git add it.
333 gen_manifest_cmd = ["ebuild", new_ebuild_path, "manifest", "--force"]
334 cros_build_lib.run(gen_manifest_cmd, extra_env=None, print_cmd=True)
335 files_to_add.append(os.path.join(package_dir, "Manifest"))
336
337 return (
338 f"{new_ebuild.package}-{new_ebuild.version}",
339 files_to_add,
340 files_to_remove,
341 )
David Rileyc0da9d92016-02-01 12:11:01 -0800342
Shao-Chuan Lee301a4192021-02-08 11:53:49 +0900343
Shao-Chuan Lee007dbe82021-02-09 14:05:39 +0900344def _PrepareGitBranch(overlay_dir):
Alex Klein1699fab2022-09-08 08:46:06 -0600345 """Prepares a git branch for the uprev commit.
Shao-Chuan Lee301a4192021-02-08 11:53:49 +0900346
Alex Klein1699fab2022-09-08 08:46:06 -0600347 If the overlay project is currently on a branch (e.g. patches are being
348 applied), rebase the new branch on top of it.
Shao-Chuan Lee007dbe82021-02-09 14:05:39 +0900349
Alex Klein1699fab2022-09-08 08:46:06 -0600350 Args:
351 overlay_dir: The overlay directory.
352 """
353 existing_branch = git.GetCurrentBranch(overlay_dir)
354 repo_util.Repository.MustFind(overlay_dir).StartBranch(
355 constants.STABLE_EBUILD_BRANCH, projects=["."], cwd=overlay_dir
356 )
357 if existing_branch:
358 git.RunGit(overlay_dir, ["rebase", existing_branch])
Shao-Chuan Lee301a4192021-02-08 11:53:49 +0900359
360
361def _CommitChange(message, android_package_dir, files_to_add, files_to_remove):
Alex Klein1699fab2022-09-08 08:46:06 -0600362 """Commit changes to git with list of files to add/remove."""
363 git.RunGit(android_package_dir, ["add", "--"] + files_to_add)
364 if files_to_remove:
365 git.RunGit(android_package_dir, ["rm", "--"] + files_to_remove)
Shao-Chuan Lee301a4192021-02-08 11:53:49 +0900366
Alex Klein1699fab2022-09-08 08:46:06 -0600367 portage_util.EBuild.CommitChange(message, android_package_dir)
David Rileyc0da9d92016-02-01 12:11:01 -0800368
369
370def GetParser():
Alex Klein1699fab2022-09-08 08:46:06 -0600371 """Creates the argument parser."""
372 parser = commandline.ArgumentParser()
373 parser.add_argument("-b", "--boards")
374 parser.add_argument(
375 "--android_bucket_url",
376 default=android.ANDROID_BUCKET_URL,
377 type="gs_path",
378 )
379 parser.add_argument(
380 "--android_build_branch",
381 choices=constants.ANDROID_BRANCH_TO_BUILD_TARGETS,
382 help="Android branch to import from, overriding default",
383 )
384 parser.add_argument(
385 "--android_package",
386 required=True,
387 choices=constants.ANDROID_ALL_PACKAGES,
388 help="Android package to uprev",
389 )
390 parser.add_argument(
391 "--arc_bucket_url", default=constants.ARC_BUCKET_URL, type="gs_path"
392 )
393 parser.add_argument("-f", "--force_version", help="Android build id to use")
394 parser.add_argument(
395 "-s",
396 "--srcroot",
397 default=os.path.join(constants.SOURCE_ROOT, "src"),
398 help="Path to the src directory",
399 )
400 parser.add_argument(
401 "--runtime_artifacts_bucket_url",
402 default=_RUNTIME_ARTIFACTS_BUCKET_URL,
403 type="gs_path",
404 )
405 parser.add_argument(
406 "--skip_commit",
407 action="store_true",
408 help="Skip commiting uprev changes to git",
409 )
410 parser.add_argument(
411 "--update_lkgb",
412 action="store_true",
413 help=(
414 "Update the LKGB file instead of uprevving ebuilds "
415 "and populating artifacts. "
416 "Requires --force_version be set."
417 ),
418 )
419 return parser
David Rileyc0da9d92016-02-01 12:11:01 -0800420
421
422def main(argv):
Alex Klein1699fab2022-09-08 08:46:06 -0600423 cbuildbot_alerts.EnableBuildbotMarkers()
424 parser = GetParser()
425 options = parser.parse_args(argv)
426 options.Freeze()
David Rileyc0da9d92016-02-01 12:11:01 -0800427
Alex Klein1699fab2022-09-08 08:46:06 -0600428 overlay_dir = os.path.abspath(_OVERLAY_DIR % {"srcroot": options.srcroot})
429 android_package_dir = android.GetAndroidPackageDir(
430 options.android_package, overlay_dir=overlay_dir
431 )
Shao-Chuan Lee3aa76522021-12-03 17:18:58 +0900432
433 if not options.skip_commit:
Alex Klein1699fab2022-09-08 08:46:06 -0600434 _PrepareGitBranch(overlay_dir)
Shao-Chuan Lee3aa76522021-12-03 17:18:58 +0900435
Alex Klein1699fab2022-09-08 08:46:06 -0600436 if options.update_lkgb:
437 if not options.force_version:
438 raise Exception("--force_version is required with --update_lkgb")
Shao-Chuan Leea4b4f302021-05-12 14:40:20 +0900439
Alex Klein1699fab2022-09-08 08:46:06 -0600440 # Attempt to read current LKGB, if available.
441 current_lkgb = None
442 try:
443 current_lkgb = android.ReadLKGB(android_package_dir)
444 except android.MissingLKGBError:
445 logging.info("LKGB file is missing, creating a new one.")
446 except android.InvalidLKGBError:
447 logging.warning("Current LKGB file is invalid, overwriting.")
Hidehiko Abe1ebc25d2016-07-28 02:24:37 +0900448
Alex Klein1699fab2022-09-08 08:46:06 -0600449 # Do nothing if LKGB is already set to the requested version.
450 if current_lkgb == options.force_version:
451 logging.warning(
452 "LKGB of %s is already %s, doing nothing.",
453 options.android_package,
454 options.force_version,
455 )
456 cbuildbot_alerts.PrintBuildbotStepText(
457 "LKGB of %s unchanged @ %s"
458 % (options.android_package, options.force_version)
459 )
460 return
David Rileyc0da9d92016-02-01 12:11:01 -0800461
Alex Klein1699fab2022-09-08 08:46:06 -0600462 # Actually update the LKGB.
463 path = android.WriteLKGB(android_package_dir, options.force_version)
464 cbuildbot_alerts.PrintBuildbotStepText(
465 "LKGB of %s updated %s -> %s"
466 % (options.android_package, current_lkgb, options.force_version)
467 )
David Rileyc0da9d92016-02-01 12:11:01 -0800468
Alex Klein1699fab2022-09-08 08:46:06 -0600469 if not options.skip_commit:
470 _CommitChange(
471 _GIT_COMMIT_MESSAGE_LKGB
472 % {
473 "android_package": options.android_package,
474 "android_version": options.force_version,
475 },
476 android_package_dir,
477 [path],
478 [],
479 )
480 return
Shao-Chuan Lee301a4192021-02-08 11:53:49 +0900481
Alex Klein1699fab2022-09-08 08:46:06 -0600482 # Use default Android branch if not overridden.
483 android_build_branch = (
484 options.android_build_branch
485 or android.GetAndroidBranchForPackage(options.android_package)
486 )
Shao-Chuan Leedea458f2021-11-25 23:46:53 +0900487
Alex Klein1699fab2022-09-08 08:46:06 -0600488 (unstable_ebuild, stable_ebuilds) = FindAndroidCandidates(
489 android_package_dir
490 )
491 # Mirror artifacts, i.e., images and some sdk tools (e.g., adb, aapt).
492 version_to_uprev = android.MirrorArtifacts(
493 options.android_bucket_url,
494 android_build_branch,
495 options.arc_bucket_url,
496 android_package_dir,
497 options.force_version,
498 )
David Rileyc0da9d92016-02-01 12:11:01 -0800499
Alex Klein1699fab2022-09-08 08:46:06 -0600500 stable_candidate = portage_util.BestEBuild(stable_ebuilds)
Shao-Chuan Leedea458f2021-11-25 23:46:53 +0900501
Alex Klein1699fab2022-09-08 08:46:06 -0600502 if stable_candidate:
503 logging.info("Stable candidate found %s", stable_candidate.version)
504 else:
505 logging.info("No stable candidate found.")
506
507 revved = MarkAndroidEBuildAsStable(
508 stable_candidate,
509 unstable_ebuild,
510 options.android_package,
511 version_to_uprev,
512 android_package_dir,
513 android_build_branch,
514 options.arc_bucket_url,
515 options.runtime_artifacts_bucket_url,
516 )
517
518 output = dict(revved=bool(revved))
519
520 if revved:
521 android_atom, files_to_add, files_to_remove = revved
522 if not options.skip_commit:
523 _CommitChange(
524 _GIT_COMMIT_MESSAGE
525 % {
526 "android_package": options.android_package,
527 "android_version": version_to_uprev,
528 },
529 android_package_dir,
530 files_to_add,
531 files_to_remove,
532 )
533 if options.boards:
534 cros_mark_as_stable.CleanStalePackages(
535 options.srcroot, options.boards.split(":"), [android_atom]
536 )
537
538 output["android_atom"] = android_atom
539 # This field is read by the PUpr uprev handler for creating CLs. We cannot
540 # return absolute paths because this script runs inside chroot but the uprev
541 # handler runs outside.
542 # Here we return paths relative to |overlay_dir|.
543 output["modified_files"] = [
544 os.path.relpath(f, overlay_dir)
545 for f in files_to_add + files_to_remove
546 ]
547
548 # The output is being parsed by service.packages.uprev_android and has to be
549 # in its own single line. When invoked from chromite API endpoints, entering
550 # chroot can generate junk messages on stdout, so we prefix our output with a
551 # line break to further ensure that.
552 print("\n" + json.dumps(output, sort_keys=True))