blob: bd021abf8f9ba5335dd02e8e4ad0bee9a2bb1623 [file] [log] [blame]
Cindy Linc06b4ea2022-01-27 18:13:04 +00001# Copyright 2022 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""build_packages updates the set of binary packages needed by Chrome OS.
6
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
10bootable Chrome OS image.
11"""
12
Alex Kleinfba23ba2022-02-03 11:58:48 -070013import logging
Cindy Linc06b4ea2022-01-27 18:13:04 +000014import os
Alex Kleinfba23ba2022-02-03 11:58:48 -070015import urllib.error
16import urllib.request
Cindy Linc06b4ea2022-01-27 18:13:04 +000017
Alex Kleina39dc982022-02-03 12:13:14 -070018from chromite.lib import commandline
Cindy Linc06b4ea2022-01-27 18:13:04 +000019from chromite.lib import constants
20from chromite.lib import cros_build_lib
21
22
23def main(argv):
Alex Kleina39dc982022-02-03 12:13:14 -070024 commandline.RunInsideChroot()
25
Cindy Linc06b4ea2022-01-27 18:13:04 +000026 cmd = [
27 'bash',
28 os.path.join(constants.CROSUTILS_DIR, 'build_packages.sh'),
29 '--script-is-run-only-by-chromite-and-not-users'
30 ]
31 cmd.extend(argv)
32 try:
Cindy Line4b243a2022-02-04 22:15:37 +000033 # TODO(b/187793559): Don't pass in print_cmd once we switch to argparse
34 cros_build_lib.dbg_run(cmd, print_cmd=False)
Cindy Linc06b4ea2022-01-27 18:13:04 +000035 except cros_build_lib.RunCommandError as e:
Alex Kleinfba23ba2022-02-03 11:58:48 -070036 try:
37 request = urllib.request.urlopen(
38 'https://chromiumos-status.appspot.com/current?format=raw')
39 logging.notice('Tree Status: %s', request.read().decode())
40 except urllib.error.HTTPError:
41 pass
Cindy Linc06b4ea2022-01-27 18:13:04 +000042 cros_build_lib.Die(e)