blob: eea6533f089d5986ef7f6c4e038d9a964077bd85 [file] [log] [blame]
Ram Chandrasekar913c0422022-05-09 23:41:22 +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_image is used to build a Chromium OS image.
6
7Chromium OS comes in many different forms. This script can be used to build
8the following:
9
10base - Pristine Chromium OS image. As similar to Chrome OS as possible.
11dev [default] - Developer image. Like base but with additional dev packages.
12test - Like dev, but with additional test specific packages and can be easily
13 used for automated testing using scripts like test_that, etc.
14factory_install - Install shim for bootstrapping the factory test process.
15 Cannot be built along with any other image.
16
17Examples:
18
19build_image --board=<board> dev test - builds developer and test images.
20build_image --board=<board> factory_install - builds a factory install shim.
21
22Note if you want to build an image with custom size partitions, either consider
23adding a new disk layout in build_library/legacy_disk_layout.json OR use
24adjust_part. See build_image help, but here are a few examples:
25
26adjust_part='STATE:+1G' -- add one GB to the size the stateful partition
27adjust_part='ROOT-A:-1G' -- remove one GB from the primary rootfs partition
28adjust_part='STATE:=1G' -- make the stateful partition 1 GB
29"""
30
31from pathlib import Path
32from typing import List, Optional
33
34from chromite.lib import commandline
35from chromite.lib import constants
36from chromite.lib import cros_build_lib
37
38
39def 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)