MCPcopy Index your code
hub / github.com/ClangBuiltLinux/boot-utils / build_image

Function build_image

buildroot/rebuild.py:41–77  ·  view source on GitHub ↗
(architecture, edit_config, savedefconfig)

Source from the content-addressed store, hash-verified

39
40
41def build_image(architecture, edit_config, savedefconfig):
42 buildroot_make('clean')
43
44 config = Path(ROOT_FOLDER, f"{architecture}.config")
45 # Python documentation notes that when subprocess.Popen()'s env parameter
46 # is not None, the current process's envirionment is not inherited, which
47 # causes issues because PATH is not inherited. Add BR2_DEFCONFIG to the
48 # environment, rather than replacing it (we support Python 3.8, so we
49 # cannot use 'os.environ | {...}').
50 buildroot_make('defconfig', env={**os.environ, 'BR2_DEFCONFIG': config})
51 if edit_config:
52 buildroot_make('menuconfig')
53 if edit_config or savedefconfig:
54 buildroot_make('savedefconfig')
55
56 buildroot_make()
57
58 OUT_FOLDER.mkdir(exist_ok=True, parents=True)
59
60 images = [Path(SRC_FOLDER, 'output/images/rootfs.cpio')]
61 # For x86_64, we also build an ext4 image for UML
62 if architecture == 'x86_64':
63 images.append(images[0].with_suffix('.ext4'))
64
65 for image in images:
66 if not image.exists():
67 msg = f"{image} could not be found! Did the build error?"
68 raise FileNotFoundError(msg)
69 zstd_cmd = [
70 'zstd',
71 '-f',
72 '-19',
73 '-o',
74 Path(OUT_FOLDER, f"{architecture}-{image.name}.zst"),
75 image,
76 ]
77 subprocess.run(zstd_cmd, check=True)
78
79
80def download_and_extract_buildroot():

Callers 1

mainFunction · 0.85

Calls 2

buildroot_makeFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected