Ram Chandrasekar | 913c042 | 2022-05-09 23:41:22 +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_image is used to build a Chromium OS image. |
| 6 | |
| 7 | Chromium OS comes in many different forms. This script can be used to build |
| 8 | the following: |
| 9 | |
| 10 | base - Pristine Chromium OS image. As similar to Chrome OS as possible. |
| 11 | dev [default] - Developer image. Like base but with additional dev packages. |
| 12 | test - Like dev, but with additional test specific packages and can be easily |
| 13 | used for automated testing using scripts like test_that, etc. |
| 14 | factory_install - Install shim for bootstrapping the factory test process. |
| 15 | Cannot be built along with any other image. |
| 16 | |
| 17 | Examples: |
| 18 | |
| 19 | build_image --board=<board> dev test - builds developer and test images. |
| 20 | build_image --board=<board> factory_install - builds a factory install shim. |
| 21 | |
| 22 | Note if you want to build an image with custom size partitions, either consider |
| 23 | adding a new disk layout in build_library/legacy_disk_layout.json OR use |
| 24 | adjust_part. See build_image help, but here are a few examples: |
| 25 | |
| 26 | adjust_part='STATE:+1G' -- add one GB to the size the stateful partition |
| 27 | adjust_part='ROOT-A:-1G' -- remove one GB from the primary rootfs partition |
| 28 | adjust_part='STATE:=1G' -- make the stateful partition 1 GB |
| 29 | """ |
| 30 | |
| 31 | from pathlib import Path |
| 32 | from typing import List, Optional |
| 33 | |
| 34 | from chromite.lib import commandline |
| 35 | from chromite.lib import constants |
| 36 | from chromite.lib import cros_build_lib |
| 37 | |
| 38 | |
| 39 | def main(argv: Optional[List[str]] = None) -> Optional[int]: |
| 40 | commandline.RunInsideChroot() |
| 41 | |
| 42 | cmd = [ |
| 43 | 'bash', |
| 44 | Path(constants.CROSUTILS_DIR) / 'build_image.sh', |
| 45 | '--script-is-run-only-by-chromite-and-not-users', |
| 46 | ] |
| 47 | cmd.extend(argv) |
| 48 | try: |
| 49 | cros_build_lib.sudo_run(cmd, print_cmd=False) |
| 50 | except cros_build_lib.RunCommandError as e: |
| 51 | cros_build_lib.Die(e) |