blob: fdf73d455a15b6b8d4d5648b6a6b8e8bf8281969 [file] [log] [blame]
Mike Frysingerf1ba7ad2022-09-12 05:42:57 -04001# Copyright 2022 The ChromiumOS Authors
Cindy Linc06b4ea2022-01-27 18:13:04 +00002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Jack Rosenthal769a0512023-05-25 18:04:50 -06005"""build_packages updates the set of binary packages needed by ChromiumOS.
Cindy Linc06b4ea2022-01-27 18:13:04 +00006
7The build_packages process cross compiles all packages that have been
8updated into the given sysroot and builds binary packages as a side-effect.
9The output packages will be used by the build_image script to create a
Jack Rosenthal769a0512023-05-25 18:04:50 -060010bootable ChromiumOS image.
Ram Chandrasekarbaa89632022-02-11 23:22:09 +000011
Jack Rosenthal769a0512023-05-25 18:04:50 -060012If packages are specified in the command line, only build those specific
13packages and any dependencies they might need.
Cindy Linc06b4ea2022-01-27 18:13:04 +000014"""
15
Ram Chandrasekarbaa89632022-02-11 23:22:09 +000016import argparse
Alex Kleinfba23ba2022-02-03 11:58:48 -070017import logging
Cindy Linc06b4ea2022-01-27 18:13:04 +000018import os
Mike Frysinger807d8282022-04-28 22:45:17 -040019from typing import List, Optional, Tuple
Alex Kleinfba23ba2022-02-03 11:58:48 -070020import urllib.error
21import urllib.request
Cindy Linc06b4ea2022-01-27 18:13:04 +000022
Lizzy Presland453237c2023-05-31 00:16:15 +000023from chromite.third_party.opentelemetry import trace
Anuj Jamwal50db51b2023-06-12 17:03:53 +000024from chromite.third_party.opentelemetry.trace import status
Lizzy Presland453237c2023-05-31 00:16:15 +000025
Cindy Lin7487daa2022-02-23 04:14:10 +000026from chromite.lib import build_target_lib
Alex Kleina39dc982022-02-03 12:13:14 -070027from chromite.lib import commandline
Cindy Linc06b4ea2022-01-27 18:13:04 +000028from chromite.lib import cros_build_lib
Cindy Lin7487daa2022-02-23 04:14:10 +000029from chromite.lib import sysroot_lib
Anuj Jamwal50db51b2023-06-12 17:03:53 +000030from chromite.lib import workon_helper
Ram Chandrasekarbdec0f02022-02-24 01:20:17 +000031from chromite.service import sysroot
Cindy Linb7f89a42022-05-23 16:50:00 +000032from chromite.utils import timer
Cindy Linc06b4ea2022-01-27 18:13:04 +000033
34
Alex Klein1699fab2022-09-08 08:46:06 -060035def build_shell_bool_style_args(
36 parser: commandline.ArgumentParser,
37 name: str,
38 default_val: bool,
39 help_str: str,
40 deprecation_note: str,
41 alternate_name: Optional[str] = None,
42) -> None:
43 """Build the shell boolean input argument equivalent.
Alex Kleina39dc982022-02-03 12:13:14 -070044
Alex Klein1699fab2022-09-08 08:46:06 -060045 There are two cases which we will need to handle,
46 case 1: A shell boolean arg, which doesn't need to be re-worded in python.
47 case 2: A shell boolean arg, which needs to be re-worded in python.
48 Example below.
49 For Case 1, for a given input arg name 'argA', we create three python
50 arguments.
51 --argA, --noargA, --no-argA. The arguments --argA and --no-argA will be
52 retained after deprecating --noargA.
53 For Case 2, for a given input arg name 'arg_A' we need to use alternate
54 argument name 'arg-A'. we create four python arguments in this case.
55 --arg_A, --noarg_A, --arg-A, --no-arg-A. The first two arguments will be
56 deprecated later.
57 TODO(b/218522717): Remove the creation of --noargA in case 1 and --arg_A and
58 --noarg_A in case 2.
Ram Chandrasekarbaa89632022-02-11 23:22:09 +000059
Alex Klein1699fab2022-09-08 08:46:06 -060060 Args:
Trent Apted66736d82023-05-25 10:38:28 +100061 parser: The parser to update.
62 name: The input argument name. This will be used as 'dest' variable
63 name.
64 default_val: The default value to assign.
65 help_str: The help string for the input argument.
66 deprecation_note: A deprecation note to use.
67 alternate_name: Alternate argument to be used after deprecation.
Alex Klein1699fab2022-09-08 08:46:06 -060068 """
69 arg = f"--{name}"
70 shell_narg = f"--no{name}"
71 py_narg = f"--no-{name}"
72 alt_arg = f"--{alternate_name}" if alternate_name else None
73 alt_py_narg = f"--no-{alternate_name}" if alternate_name else None
74 default_val_str = f"{help_str} (Default: %(default)s)."
Ram Chandrasekarbaa89632022-02-11 23:22:09 +000075
Alex Klein1699fab2022-09-08 08:46:06 -060076 if alternate_name:
77 parser.add_argument(
78 alt_arg,
79 action="store_true",
80 default=default_val,
81 dest=name,
82 help=default_val_str,
83 )
84 parser.add_argument(
85 alt_py_narg,
86 action="store_false",
87 dest=name,
88 help="Don't " + help_str.lower(),
89 )
90
Ram Chandrasekarbaa89632022-02-11 23:22:09 +000091 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -060092 arg,
93 action="store_true",
Ram Chandrasekarbaa89632022-02-11 23:22:09 +000094 default=default_val,
95 dest=name,
Alex Klein1699fab2022-09-08 08:46:06 -060096 deprecated=deprecation_note % alt_arg if alternate_name else None,
97 help=default_val_str if not alternate_name else argparse.SUPPRESS,
98 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +000099 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600100 shell_narg,
101 action="store_false",
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000102 dest=name,
Alex Klein1699fab2022-09-08 08:46:06 -0600103 deprecated=deprecation_note % alt_py_narg
104 if alternate_name
105 else py_narg,
106 help=argparse.SUPPRESS,
107 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000108
Alex Klein1699fab2022-09-08 08:46:06 -0600109 if not alternate_name:
110 parser.add_argument(
111 py_narg,
112 action="store_false",
113 dest=name,
114 help="Don't " + help_str.lower(),
115 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000116
117
118def get_parser() -> commandline.ArgumentParser:
Alex Klein1699fab2022-09-08 08:46:06 -0600119 """Creates the cmdline argparser, populates the options and description.
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000120
Alex Klein1699fab2022-09-08 08:46:06 -0600121 Returns:
Trent Apted66736d82023-05-25 10:38:28 +1000122 Argument parser.
Alex Klein1699fab2022-09-08 08:46:06 -0600123 """
124 deprecation_note = "Argument will be removed July, 2022. Use %s instead."
125 parser = commandline.ArgumentParser(description=__doc__)
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000126
Alex Klein1699fab2022-09-08 08:46:06 -0600127 parser.add_argument(
128 "-b",
129 "--board",
130 "--build-target",
131 dest="board",
132 default=cros_build_lib.GetDefaultBoard(),
133 help="The board to build packages for.",
134 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000135
Alex Klein1699fab2022-09-08 08:46:06 -0600136 build_shell_bool_style_args(
137 parser,
138 "usepkg",
139 True,
140 "Use binary packages to bootstrap when possible.",
141 deprecation_note,
142 )
143 build_shell_bool_style_args(
144 parser,
145 "usepkgonly",
146 False,
147 "Use binary packages only to bootstrap; abort if any are missing.",
148 deprecation_note,
149 )
150 build_shell_bool_style_args(
151 parser, "workon", True, "Force-build workon packages.", deprecation_note
152 )
153 build_shell_bool_style_args(
154 parser,
155 "withrevdeps",
156 True,
157 "Calculate reverse dependencies on changed ebuilds.",
158 deprecation_note,
159 )
160 build_shell_bool_style_args(
161 parser,
162 "cleanbuild",
163 False,
164 "Perform a clean build; delete sysroot if it exists before building.",
165 deprecation_note,
166 )
167 build_shell_bool_style_args(
168 parser,
169 "pretend",
170 False,
171 "Pretend building packages, just display which packages would have "
172 "been installed.",
173 deprecation_note,
174 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000175
Alex Klein1699fab2022-09-08 08:46:06 -0600176 # The --sysroot flag specifies the environment variables ROOT and PKGDIR.
177 # This allows fetching and emerging of all packages to specified sysroot.
178 # Note that --sysroot will setup the board normally in /build/$BOARD, if
179 # it's not setup yet. It also expects the toolchain to already be installed
180 # in the sysroot.
181 # --usepkgonly and --norebuild are required, because building is not
182 # supported when board_root is set.
183 parser.add_argument(
184 "--sysroot", type="path", help="Emerge packages to sysroot."
185 )
186 parser.add_argument(
187 "--board_root",
188 type="path",
189 dest="sysroot",
190 deprecated=deprecation_note % "--sysroot",
191 help=argparse.SUPPRESS,
192 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000193
Alex Klein1699fab2022-09-08 08:46:06 -0600194 # CPU Governor related options.
195 group = parser.add_argument_group("CPU Governor Options")
196 build_shell_bool_style_args(
197 group,
198 "autosetgov",
199 False,
200 "Automatically set cpu governor to 'performance'.",
201 deprecation_note,
202 )
203 build_shell_bool_style_args(
204 group,
205 "autosetgov_sticky",
206 False,
207 "Remember --autosetgov setting for future runs.",
208 deprecation_note,
209 alternate_name="autosetgov-sticky",
210 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000211
Alex Klein1699fab2022-09-08 08:46:06 -0600212 # Chrome building related options.
213 group = parser.add_argument_group("Chrome Options")
214 build_shell_bool_style_args(
215 group,
216 "use_any_chrome",
217 True,
218 "Use any Chrome prebuilt available, even if the prebuilt doesn't "
219 "match exactly.",
220 deprecation_note,
221 alternate_name="use-any-chrome",
222 )
223 build_shell_bool_style_args(
224 group,
225 "internal",
226 False,
Alex Kleind7197402023-04-05 13:05:29 -0600227 "Build the internal version of chrome (set the chrome_internal USE "
228 "flag).",
Alex Klein1699fab2022-09-08 08:46:06 -0600229 deprecation_note,
230 )
231 build_shell_bool_style_args(
232 group,
233 "chrome",
234 False,
235 "Ensure chrome instead of chromium. Alias for "
236 "--internal --no-use-any-chrome.",
237 deprecation_note,
238 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000239
Alex Klein1699fab2022-09-08 08:46:06 -0600240 # Setup board related options.
241 group = parser.add_argument_group("Setup Board Config Options")
242 build_shell_bool_style_args(
243 group,
244 "skip_chroot_upgrade",
245 False,
246 "Skip the automatic chroot upgrade; use with care.",
247 deprecation_note,
248 alternate_name="skip-chroot-upgrade",
249 )
250 build_shell_bool_style_args(
251 group,
252 "skip_toolchain_update",
253 False,
254 "Skip automatic toolchain update",
255 deprecation_note,
256 alternate_name="skip-toolchain-update",
257 )
258 build_shell_bool_style_args(
259 group,
260 "skip_setup_board",
261 False,
262 "Skip running setup_board. Implies "
263 "--skip-chroot-upgrade --skip-toolchain-update.",
264 deprecation_note,
265 alternate_name="skip-setup-board",
266 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000267
Alex Klein1699fab2022-09-08 08:46:06 -0600268 # Image Type selection related options.
269 group = parser.add_argument_group("Image Type Options")
270 build_shell_bool_style_args(
271 group,
272 "withdev",
273 True,
274 "Build useful developer friendly utilities.",
275 deprecation_note,
276 )
277 build_shell_bool_style_args(
278 group,
279 "withdebug",
280 True,
281 "Build debug versions of Chromium-OS-specific packages.",
282 deprecation_note,
283 )
284 build_shell_bool_style_args(
285 group, "withfactory", True, "Build factory installer.", deprecation_note
286 )
287 build_shell_bool_style_args(
288 group,
289 "withtest",
290 True,
291 "Build packages required for testing.",
292 deprecation_note,
293 )
294 build_shell_bool_style_args(
295 group,
296 "withautotest",
297 True,
298 "Build autotest client code.",
299 deprecation_note,
300 )
301 build_shell_bool_style_args(
302 group,
303 "withdebugsymbols",
304 False,
305 "Install the debug symbols for all packages.",
306 deprecation_note,
307 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000308
Alex Klein1699fab2022-09-08 08:46:06 -0600309 # Advanced Options.
310 group = parser.add_argument_group("Advanced Options")
311 group.add_argument(
312 "--accept-licenses", help="Licenses to append to the accept list."
313 )
314 group.add_argument(
315 "--accept_licenses",
316 deprecated=deprecation_note % "--accept-licenses",
317 help=argparse.SUPPRESS,
318 )
319 build_shell_bool_style_args(
320 group,
321 "eclean",
322 True,
323 "Run eclean to delete old binpkgs.",
324 deprecation_note,
325 )
326 group.add_argument(
327 "--jobs",
328 type=int,
329 default=os.cpu_count(),
Trent Apted66736d82023-05-25 10:38:28 +1000330 help="Number of packages to build in parallel. (Default: %(default)s)",
Alex Klein1699fab2022-09-08 08:46:06 -0600331 )
332 build_shell_bool_style_args(
333 group,
334 "rebuild",
335 True,
336 "Automatically rebuild dependencies.",
337 deprecation_note,
338 )
339 # TODO(b/218522717): Remove the --nonorebuild argument support.
340 group.add_argument(
341 "--nonorebuild",
342 action="store_true",
343 dest="rebuild",
344 deprecated=deprecation_note % "--rebuild",
345 help=argparse.SUPPRESS,
346 )
347 build_shell_bool_style_args(
348 group,
349 "expandedbinhosts",
350 True,
351 "Allow expanded binhost inheritance.",
352 deprecation_note,
353 )
354 group.add_argument(
355 "--backtrack",
356 type=int,
357 default=sysroot.BACKTRACK_DEFAULT,
358 help="See emerge --backtrack.",
359 )
Alex Klein062d7282022-07-28 09:03:26 -0600360
Alex Klein1699fab2022-09-08 08:46:06 -0600361 # The --reuse-pkgs-from-local-boards flag tells Portage to share binary
362 # packages between boards that are built locally, so that the total time
363 # required to build several boards is reduced. This flag is only useful
364 # when you are not able to use remote binary packages, since remote binary
365 # packages are usually more up to date than anything you have locally.
366 build_shell_bool_style_args(
367 group,
368 "reuse_pkgs_from_local_boards",
369 False,
370 "Bootstrap from local packages instead of remote packages.",
371 deprecation_note,
372 alternate_name="reuse-pkgs-from-local-boards",
373 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000374
Alex Klein1699fab2022-09-08 08:46:06 -0600375 # --run-goma option is designed to be used on bots.
Alex Kleind7197402023-04-05 13:05:29 -0600376 # If you're trying to build packages with goma in your local dev env, this
377 # is *not* the option you're looking for. Please see comments below.
Alex Klein1699fab2022-09-08 08:46:06 -0600378 # This option; 1) starts goma, 2) builds packages (expecting that goma is
379 # used), then 3) stops goma explicitly.
380 # 4) is a request from the goma team, so that stats/logs can be taken.
Fumitoshi Ukai00becd42023-01-13 12:51:26 +0900381 # Note: GOMA_DIR is expected to be passed via env var.
Alex Klein1699fab2022-09-08 08:46:06 -0600382 #
383 # In local dev env cases, compiler_proxy is expected to keep running.
384 # In such a case;
385 # $ python ${GOMA_DIR}/goma_ctl.py ensure_start
386 # $ build_packages (... and options without --run-goma ...)
387 # is an expected commandline sequence. If you set --run-goma flag while
388 # compiler_proxy is already running, the existing compiler_proxy will be
389 # stopped.
390 build_shell_bool_style_args(
391 group,
392 "run_goma",
393 False,
Alex Kleind7197402023-04-05 13:05:29 -0600394 "When set, (re)starts goma, builds packages, and then stops goma.",
Alex Klein1699fab2022-09-08 08:46:06 -0600395 deprecation_note,
396 alternate_name="run-goma",
397 )
398 # This option is for building chrome remotely.
399 # 1) starts reproxy 2) builds chrome with reproxy and 3) stops reproxy so
400 # logs/stats can be collected.
401 # Note: RECLIENT_DIR and REPROXY_CFG env var will be deprecated July, 2022.
402 # Use --reclient-dir and --reproxy-cfg input options instead.
403 build_shell_bool_style_args(
404 group,
405 "run_remoteexec",
406 False,
407 "If set to true, starts RBE reproxy, builds packages, and then stops "
408 "reproxy.",
409 deprecation_note,
410 )
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000411
Ryo Hashimoto0845ebf2023-06-06 19:21:13 +0900412 build_shell_bool_style_args(
413 group,
414 "bazel",
415 False,
416 "Use Bazel to build packages.",
417 deprecation_note,
418 )
419
Alex Klein1699fab2022-09-08 08:46:06 -0600420 parser.add_argument("packages", nargs="*", help="Packages to build.")
421 return parser
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000422
423
Alex Klein1699fab2022-09-08 08:46:06 -0600424def parse_args(
425 argv: List[str],
426) -> Tuple[commandline.ArgumentParser, commandline.ArgumentNamespace]:
427 """Parse and validate CLI arguments.
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000428
Alex Klein1699fab2022-09-08 08:46:06 -0600429 Args:
Trent Apted66736d82023-05-25 10:38:28 +1000430 argv: Arguments passed via CLI.
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000431
Alex Klein1699fab2022-09-08 08:46:06 -0600432 Returns:
Trent Apted66736d82023-05-25 10:38:28 +1000433 Tuple having the below two,
434 Argument Parser
435 Validated argument namespace.
Alex Klein1699fab2022-09-08 08:46:06 -0600436 """
437 parser = get_parser()
438 opts = parser.parse_args(argv)
Ram Chandrasekarbdec0f02022-02-24 01:20:17 +0000439
Alex Klein1699fab2022-09-08 08:46:06 -0600440 if opts.chrome:
441 opts.internal_chrome = True
442 opts.use_any_chrome = False
Ram Chandrasekarbdec0f02022-02-24 01:20:17 +0000443
Alex Klein1699fab2022-09-08 08:46:06 -0600444 opts.setup_board_run_config = sysroot.SetupBoardRunConfig(
445 force=opts.cleanbuild,
446 usepkg=opts.usepkg,
447 jobs=opts.jobs,
448 quiet=True,
449 update_toolchain=not opts.skip_toolchain_update,
450 upgrade_chroot=not opts.skip_chroot_upgrade,
451 local_build=opts.reuse_pkgs_from_local_boards,
452 expanded_binhost_inheritance=opts.expandedbinhosts,
Cindy Linadc610a2023-05-23 18:46:12 +0000453 use_cq_prebuilts=opts.usepkg,
Alex Klein1699fab2022-09-08 08:46:06 -0600454 backtrack=opts.backtrack,
455 )
456 opts.build_run_config = sysroot.BuildPackagesRunConfig(
457 usepkg=opts.usepkg,
458 install_debug_symbols=opts.withdebugsymbols,
459 packages=opts.packages,
460 use_goma=opts.run_goma,
461 use_remoteexec=opts.run_remoteexec,
462 incremental_build=opts.withrevdeps,
463 dryrun=opts.pretend,
464 usepkgonly=opts.usepkgonly,
465 workon=opts.workon,
466 install_auto_test=opts.withautotest,
467 autosetgov=opts.autosetgov,
468 autosetgov_sticky=opts.autosetgov_sticky,
469 use_any_chrome=opts.use_any_chrome,
470 internal_chrome=opts.internal,
471 clean_build=opts.cleanbuild,
472 eclean=opts.eclean,
473 rebuild_dep=opts.rebuild,
474 jobs=opts.jobs,
475 local_pkg=opts.reuse_pkgs_from_local_boards,
476 dev_image=opts.withdev,
477 factory_image=opts.withfactory,
478 test_image=opts.withtest,
479 debug_version=opts.withdebug,
480 backtrack=opts.backtrack,
Ryo Hashimoto0845ebf2023-06-06 19:21:13 +0900481 bazel=opts.bazel,
Alex Klein1699fab2022-09-08 08:46:06 -0600482 )
483 opts.Freeze()
484 return parser, opts
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000485
486
Lizzy Presland453237c2023-05-31 00:16:15 +0000487tracer = trace.get_tracer(__name__)
488
489
Alex Klein1699fab2022-09-08 08:46:06 -0600490@timer.timed("Elapsed time (build_packages)")
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000491def main(argv: Optional[List[str]] = None) -> Optional[int]:
Alex Klein1699fab2022-09-08 08:46:06 -0600492 commandline.RunInsideChroot()
493 parser, opts = parse_args(argv)
Ram Chandrasekarbaa89632022-02-11 23:22:09 +0000494
Lizzy Presland453237c2023-05-31 00:16:15 +0000495 build_packages(parser, opts)
496
497
498@tracer.start_as_current_span("scripts.build_packages.build_packages")
499def build_packages(
500 parser: commandline.ArgumentParser, opts: commandline.ArgumentNamespace
501):
Anuj Jamwal50db51b2023-06-12 17:03:53 +0000502 span = trace.get_current_span()
503
Alex Kleind7197402023-04-05 13:05:29 -0600504 # If the opts.board is not set, then it means user hasn't specified a
505 # default board in 'src/scripts/.default_board' and didn't specify it as
506 # input argument.
Alex Klein1699fab2022-09-08 08:46:06 -0600507 if not opts.board:
Anuj Jamwal50db51b2023-06-12 17:03:53 +0000508 span.add_event(
509 "exception",
510 attributes={
511 "exception.type": "ArgumentMissingError",
512 "exception.message": "--board is required",
513 },
514 )
515 span.set_status(status.StatusCode.ERROR)
Alex Klein1699fab2022-09-08 08:46:06 -0600516 parser.error("--board is required")
Ram Chandrasekarbdec0f02022-02-24 01:20:17 +0000517
Alex Klein1699fab2022-09-08 08:46:06 -0600518 build_target = build_target_lib.BuildTarget(
519 opts.board, build_root=opts.sysroot
520 )
Anuj Jamwal50db51b2023-06-12 17:03:53 +0000521 span.set_attributes(
522 {
523 "board": build_target.name,
524 "workon_packages": workon_helper.WorkonHelper(
525 build_target.root
526 ).ListAtoms(),
527 }
528 )
529
Alex Klein1699fab2022-09-08 08:46:06 -0600530 board_root = sysroot_lib.Sysroot(build_target.root)
Cindy Lin7487daa2022-02-23 04:14:10 +0000531
Alex Kleinfba23ba2022-02-03 11:58:48 -0700532 try:
Alex Klein1699fab2022-09-08 08:46:06 -0600533 # TODO(xcl): Update run_configs to have a common base set of configs for
534 # setup_board and build_packages.
535 if not opts.skip_setup_board:
536 sysroot.SetupBoard(
537 build_target,
538 accept_licenses=opts.accept_licenses,
539 run_configs=opts.setup_board_run_config,
540 )
Sergey Frolovf988de72023-03-06 20:05:21 -0700541
Alex Klein1699fab2022-09-08 08:46:06 -0600542 sysroot.BuildPackages(build_target, board_root, opts.build_run_config)
543 except sysroot_lib.PackageInstallError as e:
544 try:
545 with urllib.request.urlopen(
546 "https://chromiumos-status.appspot.com/current?format=raw"
Sergey Frolov7cf6c0b2022-06-06 16:47:44 -0600547 ) as request:
Alex Klein1699fab2022-09-08 08:46:06 -0600548 logging.notice("Tree Status: %s", request.read().decode())
549 except urllib.error.HTTPError:
550 pass
Anuj Jamwal50db51b2023-06-12 17:03:53 +0000551 span.record_exception(e)
552 span.set_status(status.StatusCode.ERROR, str(e))
Alex Klein1699fab2022-09-08 08:46:06 -0600553 cros_build_lib.Die(e)
Anuj Jamwal50db51b2023-06-12 17:03:53 +0000554 except KeyboardInterrupt as e:
555 span.record_exception(e)
556 span.set_status(status.StatusCode.OK)
557 raise