Cindy Lin | c06b4ea | 2022-01-27 18:13:04 +0000 | [diff] [blame] | 1 | # 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 | |
| 7 | The build_packages process cross compiles all packages that have been |
| 8 | updated into the given sysroot and builds binary packages as a side-effect. |
| 9 | The output packages will be used by the build_image script to create a |
| 10 | bootable Chrome OS image. |
| 11 | """ |
| 12 | |
Alex Klein | fba23ba | 2022-02-03 11:58:48 -0700 | [diff] [blame] | 13 | import logging |
Cindy Lin | c06b4ea | 2022-01-27 18:13:04 +0000 | [diff] [blame] | 14 | import os |
Alex Klein | fba23ba | 2022-02-03 11:58:48 -0700 | [diff] [blame] | 15 | import urllib.error |
| 16 | import urllib.request |
Cindy Lin | c06b4ea | 2022-01-27 18:13:04 +0000 | [diff] [blame] | 17 | |
Alex Klein | a39dc98 | 2022-02-03 12:13:14 -0700 | [diff] [blame] | 18 | from chromite.lib import commandline |
Cindy Lin | c06b4ea | 2022-01-27 18:13:04 +0000 | [diff] [blame] | 19 | from chromite.lib import constants |
| 20 | from chromite.lib import cros_build_lib |
| 21 | |
| 22 | |
| 23 | def main(argv): |
Alex Klein | a39dc98 | 2022-02-03 12:13:14 -0700 | [diff] [blame] | 24 | commandline.RunInsideChroot() |
| 25 | |
Cindy Lin | c06b4ea | 2022-01-27 18:13:04 +0000 | [diff] [blame] | 26 | 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 Lin | e4b243a | 2022-02-04 22:15:37 +0000 | [diff] [blame] | 33 | # 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 Lin | c06b4ea | 2022-01-27 18:13:04 +0000 | [diff] [blame] | 35 | except cros_build_lib.RunCommandError as e: |
Alex Klein | fba23ba | 2022-02-03 11:58:48 -0700 | [diff] [blame] | 36 | 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 Lin | c06b4ea | 2022-01-27 18:13:04 +0000 | [diff] [blame] | 42 | cros_build_lib.Die(e) |